forums

TNT Basic Forums > Programming Q&A
index variable in a for loop error
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-26-2004 03:50

Posted by:
jamesg

Location:
Bozeman, Montana

Find more posts by jamesg

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

Find more posts by -wyvern

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

Click Here to Email eekaydee   Find more posts by eekaydee

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)

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.