![]() | ![]() | ![]() | ![]() | ![]() |
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.
;--- 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
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');^
![]() | ![]() | ![]() | ![]() | ![]() |