Page 3 of 3

Re: naugty problem with for next in grid calculations

Posted: Mon Feb 28, 2022 1:54 pm
by wimapon
hi Infratec, long time no see. good to see you again.
Thanks for your replay.
I did in the early days a lot of assembler programming.
I do know what you mean, but in that days gwbasic and quickbasic did not have that problem.

My problem is: for i = a to b step c does not work if c is an integer.
for i = a to b step 5 does work okay.

So i can not calculate the value of c , and that looks strange.
Or is there a way to change an integer into a number in purebasic?

Wim

Re: naugty problem with for next in grid calculations

Posted: Mon Feb 28, 2022 2:07 pm
by RASHAD
My problem is: for i = a to b step c does not work if c is an integer.
for i = a to b step 5 does work okay.
c most likely is a variable and that is not supported by PB
So use maybe it will help

Code: Select all

  For i= a to b
  	your code here
  	calculate c or get it from previous calculation or read it from DataSection then
  	i + c 
  Next

Re: naugty problem with for next in grid calculations

Posted: Mon Feb 28, 2022 2:30 pm
by wimapon
okay Rashad,
Your idea is awesome

i like to do: for i = a to b step c
pure basic does not allow this.
only this works: for i = a to b step 5

so if i do it the way below, this problem is solved.
It is a bit dirty, but it works
Thanks.



Code: Select all

a = 5
b = 20
c = 5  

For i = a To b 
  ; do the calculations with i
  Debug i
  i = i + c - 1
Next i

Re: naugty problem with for next in grid calculations

Posted: Tue Mar 01, 2022 11:16 am
by RASHAD
You are welcome :)