|
03-26-2004 03:50
Posted by:
jamesg
Location:
Bozeman, Montana

|
Hello:
I am trying to convert a program to TNT Basic and ran into a hitch with a FOR loop.
The error message I am getting is:
The index variable in a for loop must be an integer variable or an item from an integer array.
The loop looks like this:
for A=0 to (PI+SP/2) step sp
This should be generating incremental non-integer values.
When the loop starts, the values are:
sd=10
size=150
pi=3.14159
sp=0.314159
pi+sp/2=3.29867
Yet since it appears the variable 'a' has to be an integer, I have a fundamental flaw here.
This code works on ancient Apple II basic and Metal Basic.
James
|
|
03-26-2004 07:05
Posted by:
-wyvern
Location:
Bedroom

|
Use the Round command in your loop so that it encloses that calculation you've got there. The progam is probably not happy about the division sign, and Round will effectively convert the number into an integer.
|
|
03-26-2004 12:15
Posted by:
eekaydee
Location:
CA, USA

|
Yeah, that's probably a problem. You could easily get around it, however, like this:
float A=0
Repeat
A=A+SP
Until A=(PI+SP/2)
|