Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / how to decrement for loop

Author
Message
0x7f
8
Years of Service
User Offline
Joined: 1st Apr 2016
Location:
Posted: 4th Jan 2017 00:43
i've been trying to decrement a loop like:
"for i=10 to 1"
the manual on the website also mentions its possible to decrement loops, but only prtovides examples where they are being incremented.
but that doesn't seem to work in AGK2 ? i saw a few examples which do it that way, but the posts are old so i assume that info is outdated.
as workaround i did: "if(i>1) then i=i-1" but i'd rather know what the proper method is ?
thanks in advance
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Jan 2017 07:16 Edited at: 4th Jan 2017 07:17
You need to include a STEP, which can also be used for other purposes....

For i = 10 to 1 STEP -1


This can be used for positive and negative increments with larger steps...

For i = 1 to 1000 STEP 5

...which will give values for i of 1,6,11,16...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
0x7f
8
Years of Service
User Offline
Joined: 1st Apr 2016
Location:
Posted: 4th Jan 2017 23:01
thanks!

Login to post a reply

Server time is: 2024-04-24 22:28:37
Your offset time is: 2024-04-24 22:28:37