step with a file read variable

Blitz3D Forums/Blitz3D Programming/step with a file read variable

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The most flexible way is to use a While loop instead of For-Next.

If you know the step size is positive then the equivalent loops look like this:

; Set values for xFirst and xLast here. xStep must be constant.

For x = xFirst To xLast Step xStep
	; do something
Next



; Set values for xFirst, xLast and xStep here.

x = xFirst

While x <= xLast
	; do something
	x = x + xStep
Wend

If xStep is negative then you would use "While x >= xLast".

If you don't know the sign of xStep in advance then you must write code to handle both cases.
This complication is the reason For-Next insists on a constant step value.