Flow Control
There are flow control constructs in SIMPOL that are similar to many other languages. The if … else if … else … end if construct is straightforward:
if (i == 3) j = 5 else if (i == 4) j = 6 else j = 7 end if
In some cases the .if() intrinsic function provides a better alternative to the if construct.
The while … end while can have conditional expressions at the beginning or the end, or both. The contained
block will be entered if the initial expression is absent or is considered to have passed. At the end of the block control will return to the first
test if the final condition is absent or is considered to have failed. The end while condition should therefore be thought of as an
end while if type of expression. For example the following kind of loop could be used to process the lines in an
autoexec.bat
file:
fsfileinputstream f string line boolean error f =@ fsfileinputstream.new("c:\autoexec.bat") error = .false while (f.endofdata == .false) line = f.getstring(.inf,1,.true,.char(13)+.char(10)) // ... // process the line maybe setting error to true // if an error is encountered // ... end while (error == .true)