PPWIZARD Manual
[Bottom][Contents][Search][Prev]: Commands[Next]: #}

#{

This command is used to define the start of a loop which ends with the "#}" statement.

You may use the #continue to restart at the top of the loop and #break will cause you to exit the loop.

Restrictions

  1. Both the start and end of a loop must occur within the same input file.

  2. Loops can't be nested (within a single file).

  3. Since PPWIZARD loads the whole loop without processing lines in between the affect of any intermediate "HashPrefix" option is ignored for the purposes of finding the end of the loop.

Example 1 - Loop 12 Times

    ;--- Output 12 text lines ---------------------------------------------------
    #RexxVar Count = 1              ;;"#RexxVar" is fastest way to set or update a rexx variable
    #{
       ;--- Output one line -----------------------------------------------------
       <B>From Loop #<??Count></B><BR>
    
       ;--- Only do 12 times ----------------------------------------------------
       #RexxVar Count + 1
       #if [<??Count> > 12]         ;;Note the square brackets to improve performance (since simple test)
           #break                   ;;Now done 12 times
       #endif
    #}
    <HR>                            ;;Break sends us here
    

Example 2 - Read File Until End

This example is used to load a list of languages and to create a directory for each ones generated html. The languages file looks like:

    en     ;;English
    it     ;;Italian
    fr     ;;French
    

The code to read the above file and create the directories is:

    ;--- Code written for OS/2 so gain access to rexx extensions ----------------
    #evaluate "" "call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'"
    #evaluate "" "call SysLoadFuncs"
    
    ;--- Define some directories ------------------------------------------------
    #define site.root            C:\sitetest
    #define site.out.dir         <$site.root>\html     ;;output root
    
    ;--- Make required base directories -----------------------------------------
    #evaluate "" "MkDirRc=SysMkDir('<$site.root>')"
    #evaluate "" "MkDirRc=SysMkDir('<$site.out.dir>')"
    
    ;--- Make language directories ----------------------------------------------
    #define    LanguageFile   "LANG.IH"           ;;Note in this case would be more CPU efficent if rexx variable
    #DependsOn INPUT <$LanguageFile>
    #evaluate "" ^CloseFileRc = stream(<$LanguageFile>, 'c', 'close');^
    #{
       ;--- Exit on EOF ---------------------------------------------------------
       #if  lines(<$LanguageFile>) = 0
            #break
       #endif
    
       ;--- Read the language line, strip out comment and make directory --------
       #evaluate "" "MkDirRc=SysMkDir('<$site.out.dir>\' || '<?=word(linein(<$LanguageFile>), 1)>')"
    #}
    #evaluate "" ^CloseFileRc = stream(<$LanguageFile>, 'c', 'close');^
    


[Top][Contents][Search][Prev]: Commands[Next]: #}

PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Tuesday January 02 2001 at 7:37am