GSAK (Geocaching Swiss Army Knife)
Contents - Index

While (command)

WHILE <expression>

Use this command to repeat a sequence of statements while a certain condition exists. The expression used must return a Boolean true or false value. You must end the group of statements being executed with the ENDWHILE command. Use the Break command to exit the loop at any time. For example
 

# Test to see if the 10 files test1.zip to test10.zip exist, then do some action
$Count = 1
$File = "Test"
WHILE $Count <= 10
IF FileExists($File + "$Count" + ".zip")
   commands ...
ENDIF
$Count = $Count + 1
ENDWHILE
 


Notice the use of the "$Count" (using double quotes) in the FileExists expression. By surrounding the Numeric variable $Count in double quotes, you are typecasting it on the fly to a string value. This enables the expression to work because you can't just add a numeric variable to a string variable as in $File + $Count

Related Repeat() Break()

Alpha List         Category List


Copyright 2004-2019 CWE Computer Services  
Privacy Policy Contact