
-----------------------------------
m84uily
Wed Mar 11, 2009 12:01 pm

Input Output help?
-----------------------------------
What I'm attempting to do here is get numbers from files A.txt and B.txt and put them into C.txt, however I'm having trouble with the get part.
I followed the guide : http://compsci.ca/v3/viewtopic.php?t=12972
And I do realize that I'm using a different array than the one in the tutorial, although I'm quite sure it works as another person in my class used it with success. 

[code]
var streamA, streamB, streamC : int
var numberA, numberB : array 1 .. 6 of string
open : streamA, "C:\\A.txt", get
open : streamB, "C:\\B.txt", get
open : streamC, "C:\\C.txt", put
get streamA, numberA 
put : streamC, "This is how you put something to file"
[/code]

The problem is on the line:

[code]
get streamA, numberA 
[/code]

I get the error "illegal get item". Could someone explain to me why this is happening and how I can fix it?
Thanks in advance.

-----------------------------------
DemonWasp
Wed Mar 11, 2009 12:07 pm

RE:Input Output help?
-----------------------------------
You're missing the colon between get and streamA. You want this instead:

[code]get : streamA, numberA [/code]

-----------------------------------
m84uily
Wed Mar 11, 2009 12:09 pm

Re: RE:Input Output help?
-----------------------------------
You're missing the colon between get and streamA. You want this instead:



Thanks! But it still gives me the same error  :(

-----------------------------------
DemonWasp
Wed Mar 11, 2009 12:22 pm

RE:Input Output help?
-----------------------------------
Ah, yes...and you also need to specify an element of the array. You can't just get an array, you have to get the strings that compose the array. Specifically:

[code]
get : streamA, numberA(1)
[/code]

etcetera.

-----------------------------------
m84uily
Wed Mar 11, 2009 12:26 pm

Re: RE:Input Output help?
-----------------------------------
Ah, yes...and you also need to specify an element of the array. You can't just get an array, you have to get the strings that compose the array. Specifically:



Thanks, but, is there any way to get them all at once? I could definitely work with this, though.

-----------------------------------
TheGuardian001
Wed Mar 11, 2009 2:02 pm

Re: Input Output help?
-----------------------------------
Yes, you can use a for statement to repeat the process for however many elements you have in your array.
[code]
for i : 1 .. 4
put "This is repetition ", i, "!"
end for
[/code]

-----------------------------------
andrew.
Wed Mar 11, 2009 3:47 pm

RE:Input Output help?
-----------------------------------
Use "upper (arrayName)" to find the highest index you have (the number of elements). So, it would be like:
for i : 1..upper (arrayName)
    %code
end for


Just change arrayName to the name of your array.
