Task

Demonstrate the language's ability to include source code from other files.




See Also
 Compiler/Simple file inclusion pre processor




/******************************************************************************* 
*   /#   @INCLUDE file:"filename.filetype"     
*        - file: is just the filename 
*        - actual full pathname is VERBEXX_INCLUDE_PATH\filename.filetype  
*          where VERBEXX_INCLUDE_PATH is the contents of an environment variable
*
*   /#   @INCLUDE file:"E:\xxx\xxx\xxx\filename.filetype"
*        - file: specifies the complete pathname of file to include
*   
*   @INCLUDE verb can appear only in pre-processor code (after /#  /{  etc.) 
*******************************************************************************/
 
/{  //////////////////////////////////////////////// start of pre-processor code
 
    @IF (@IS_VAR include_counter) 
        else:{@VAR include_counter global: = 0};  // global, so all code sees it
 
    include_counter++; 
    @SAY "    In pre-processor -- include counter = " include_counter; 
 
    @IF (include_counter < 3) 
        then:{@INCLUDE file:"rosetta\include_a_file.txt"};     // include self
 
}/  ////////////////////////////////////////////////// end of pre-processor code
 
@SAY "Not in pre-processor -- include_counter = " include_counter;
/]
Output:      In preprocessor -- include_counter = 1
             In preprocessor -- include_counter = 2
             In preprocessor -- include_counter = 3 
         Not in preprocessor -- include_counter = 3 
         Not in preprocessor -- include_counter = 3
         Not in preprocessor -- include_counter = 3