Page 1 of 1
STEP Variable !
Posted: Sun Sep 04, 2011 11:03 am
by GeBonet
Hi !
Now for the STEP in the FOR/NEXT is a constant and Integer !
How to do, if the Step is dependent on a result from the code ? And more, if is not integer ?
As in other language, whether the STEP must be VARIABLE
Maintenant, le PAS dans une boucle FOR/NEXT doit être une constante et de plus entier.
Comment faire si le PAS est dépendant d'un RESULTAT qui peut être décimal = 0.02 ??? Ou autre ?
Dans d'autre language c'est possible... Alors PB non ?
Merci.
Re: STEP Variable !
Posted: Sun Sep 04, 2011 11:17 am
by gnasen
For this case you normally use a While : Wend complex. I never noticed in another language if it is possible, however I wouldnt think its necessary.
Re: STEP Variable !
Posted: Sun Sep 04, 2011 4:05 pm
by Demivec
GeBonet wrote:Hi !
Now for the STEP in the FOR/NEXT is a constant and Integer !
How to do, if the Step is dependent on a result from the code ? And more, if is not integer ?
As in other language, whether the STEP must be VARIABLE
Code: Select all
myStep.f = 0.2
i.f = 1.0
Repeat
Debug i
;myStep + 0.1 ;variable step
i + myStep
Until i > 10.0
Debug "----"
myStep.f = 0.2
i.f = 1.0
While i <= 10.0
Debug i
;myStep + 0.1 ;variable step
i + myStep
Wend
@Edit: I updated the work-around to use floats.

Re: STEP Variable !
Posted: Sun Sep 04, 2011 5:58 pm
by GeBonet
HI !
I Thing you not have understand what i mind !
If i one part of the code give me 0.05 and this value is the STEP for a evolution of the space between 2 limits into one curve...
The sample code :
VariationOffCode=0.05
For i=lowLimit TO Highlimit STEP VariationOffCode
Result(k)=value*sin(angle+i):k+1
next i
Therefore, we need "i" and the value of STEP must be floating or double precision ...
Or it would be easier!

Note : There are obviously other way to get around this, but it would be a bypass, i know this and tanks.

Re: STEP Variable !
Posted: Sun Sep 04, 2011 6:06 pm
by STARGÅTE
swap
i and
k:
Code: Select all
VariationOffCode.f=0.05
maxk = (Highlimit-lowLimit)/VariationOffCode
i.f = lowLimit
For k=0 To maxk
Result(k)=value*Sin(angle+i) : i+VariationOffCode
Next k
Re: STEP Variable !
Posted: Sun Sep 04, 2011 6:23 pm
by GeBonet
Thank you, thank you very much
But here it is "Feature Requests and Wishlists" and that's what I want!
Just One for Sample : "For i.f = 2.5 to 25.5 Step 0.5"
and the 0.5 can be given by a variable is all ...
Tanks you.
Re: STEP Variable !
Posted: Sun Sep 04, 2011 6:42 pm
by STARGÅTE
you can not increment floats!!
Example:
From 0.00 to 1.00 in 0.02 steps you need 50 steps right ?
but look this:
Code: Select all
Count = 0
Float.f = 0.00
While Float <= 1.00
Count + 1
Float + 0.02
Debug Float
Wend
Debug "---"
Debug "steps: "+Str(Count)
Debug "---"
problem here: +0.02 not finished by 1.00 !!!
it finished at 0.99999958276749 and thats smaler then 1.0, so +1 step