Here is my link : https://www.purebasic.fr/english/viewt ... 77#p622277
Hope you guys can help this tricky one
Thanks

Code: Select all
For a = 1 To 10
If a = 5
Break
EndIf
Next a
Debug a; * 5Code: Select all
For n=x to y step z ; (z=1 if step absent)
; 1) If 1st call of For: Initialization of variable n by assigning value x
; 2) Compare variable n to y : Continue loop processing if n is < to y (for a positive step) or n > y (for a negative step) otherwise end of loop process.
[...]
Next
; 1) Increment n with z (n = n + z)
; 2) Return to For instruction
Code: Select all
For n=1 to 2
[...] ; without Break instruction !important;
Next
If n=2
[...]
EndIf
Sorry for the redundancy, PBJim posted a reply while I was writing mine and I didn't see it. (French to English is a pain for me!PBJim wrote: In my experience, all the BASIC dialects I've worked with, exit the For/Next loop with the counter + 1. [...]
Code: Select all
iniCountStr = 2 ; the number of lines in the ini file is unknown in advance
iniCountStr2 = 2 ; - // -
For i = 1 To iniCountStr
Debug i
Next
Last = i - 1
Start2 = i
Last2 = Last + iniCountStr2
For i = Start2 To Last2
Debug i
Next
; Select EventMenu()
; Case 1 To Last
; Case Start2 To Last2
; EndSelect
Code: Select all
For n=0 To 2
n=10
Next
Debug n
; expected n = 10 , bcos it tell me what it's value above , and 10 is greater then 2 , so the loop ends , the value is 10
For n=0 To 2
...
Next
; after loop ends ,should retain the last n value , not increments it , implementation error
; Expected Implementation
;-----------------------------------------
n=0
x=n
loopagain:
if x>2 : goto endloop:
n=x
....
user code
....
x=n+1
goto loopagain:
endloop:
the logic is like this
moricode wrote: for a human understanding , this was confuse me long time
Code: Select all
For n=0 To 2
...
Next
; after loop ends ,should retain the last n value , not increments it , implementation error
Code: Select all
For n=0 To 2
n=10
Next
Debug n
; expected n = 10 , bcos it tell me what it's value above , and 10 is greater then 2 , so the loop ends , the value is 10
Code: Select all
; Expected Implementation
;-----------------------------------------
n=0
x=n
loopagain:
if x>2 : goto endloop:
n=x
....
user code
....
x=n+1
goto loopagain:
endloop:
boddhi wrote: Fri Jun 07, 2024 11:18 pm
It's for this kind of loops than Repeat...Until (or While...Wend) have been createdCode: Select all
; Expected Implementation ;----------------------------------------- n=0 x=n loopagain: if x>2 : goto endloop: n=x .... user code .... x=n+1 goto loopagain: endloop:![]()