Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Warnings by "Check script" when populating an array in a loop with an INPUT() test as the condition

MetalFingerz
Booster

Hello,

 

I have an issue with an array in a loop iterating a text file. I'm in the Interface script and here is the code :

DIM array[]
n = 0
i = 1
line = 2
row = 2
value = ""

channel = OPEN("TEXT", "text.txt", "SEPARATOR='\t', MODE = RO, LIBRARY")
REPEAT
	n = INPUT(channel, line, row, value)
	array[i] = i
	line = line + 1
	i = i + 1
UNTIL n < 1
CLOSE channel

! Values are 1, 2, 3 and 4

 

So my array gets populated properly (with numbers in the example but the idea is to populate it with values from the text file), I can reference the array members individually and so on. But every time I check the script, it gives me warnings telling me the indexes are outside the range. This happens with DO WHILE and REPEAT UNTIL loops (didnt try WHILE DO but it's probably the same) but not if I manually input

	n = INPUT(channel, line, row, value)
	array[i] = i
	line = line + 1
	i = i + 1

x number of times that I need. For example if my text file is 10 lines long and I copy paste that code 9 times, no error is being thrown when I check the script. However that's not an acceptable solution as I need to iterate through the array with a loop.

 

I think I zero'd the issue at the UNTIL condition. If I put

UNTIL i > 4

there's no error being throw but not if I keep the INPUT() test

UNTIL n < 1

 

When I use the object and its interface in a project, there's no errors that pops up in the Report window, it's only when I get to check my script in the Interface script that something is shown.

 

Any idea what I'm doing wrong with my loops ? I'm using AC 24 6004.

1 ACCEPTED SOLUTION

Solution
MetalFingerz
Booster

Well I fixed the issue by initializing all members of the array first.

Don't know why that worked though.

View solution in original post

2 REPLIES 2

Solution
MetalFingerz
Booster

Well I fixed the issue by initializing all members of the array first.

Don't know why that worked though.

Hi,

 

Did you paste the exact code that gave the warning? Because "line" is a reserved keyword with error message "Keywords can't be used as variables at line 4". If I change that, there are no warnings.

 

 

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!