Hello Charles..others
does o2 support
Do
...
...
...
Loop While expr
?
I mean i always use Do / End Do
or
While / Wend
or can i replace
Do /Loop While with...
Do loop ? and how ?
Yes,
uses console
int i
do
i++
print i cr
'OPTIONS:
'loop while i<10
'loop when i<10
'loop until i>9
'loop if i<10
loop if not i>9
wait
Similar option exist for exit and continue
or can i use just this :
int i
do
i++
print i cr
if i=10 : exit do : end if
end do
Hi Aurel,
While waiting for Charles answer,
on my side, one thing I like is to be able to
put dual conditions, one in the do line and also one in the loop line.
This make the code more compact and often easier to read.
// KickSwitch -64 -r
// KickEnd
include once "console.inc"
include once "windows\msvcrt.inc"
%BCRYPT_USE_SYSTEM_PREFERRED_RNG = 2
! BCryptGenRandom lib "bcrypt.dll"(sys hAlgorithm, sys pbBuffer, dword cbBuffer, dword dwFlags) as long
'_____________________________________________________________________________
SetConsoleTitle("loop")
long index = 0
byte RandomByte
printl
printl "do until RandomByte > 245"
do until RandomByte > 245
BCryptGenRandom(0, @RandomByte, 1, %BCRYPT_USE_SYSTEM_PREFERRED_RNG)
printl " index = " index ", RandomByte = " RandomByte
index ++
loop while index <= 5
printl "loop while index <= 5"
printl
printl : printl "Press a key or click to end"
waitkey
end
'_____________________________________________________________________________
'
The compiler has to break all these looping expressions into a simple do .. loop containing one or more conditionals, containing an exit/continue instruction.
They are all luxury items for hand-coding. If you use an AI agent to produce the code, you might find it simpler to eliminate all while and for constructs.
Hi Pierre....Charles
my intention is to avoid Loop While in this loop construct
because really i don't use in any of my programs Do/Loop While
i prefer Do/End Do and While/Wend
in first place i was asking because this is used in many C or Java programs
and i am doing some translation