
-----------------------------------
Zorg
Fri Jan 23, 2004 3:28 pm

how do i store words into arrays? (from text file)
-----------------------------------
How do i store each word into an array from a text file?

-----------------------------------
Tony
Fri Jan 23, 2004 3:30 pm


-----------------------------------
you read from the textfile one word at a time, keep a running counter and save each word into an array with counter as the index

-----------------------------------
Zorg
Fri Jan 23, 2004 3:32 pm


-----------------------------------
can you give me a simple example?

-----------------------------------
Tony
Fri Jan 23, 2004 3:34 pm


-----------------------------------

my_Array(counter) := tempWord

 :?

we have tutorials on reading from file and using arrays in [turing tutorials], you'll find them helpful :)

-----------------------------------
Zorg
Fri Jan 23, 2004 5:32 pm


-----------------------------------
you read from the textfile one word at a time, keep a running counter and save each word into an array with counter as the index

How exactly do I take one word at a time?

-----------------------------------
JHDK
Fri Jan 23, 2004 8:30 pm


-----------------------------------
lol. i had to do this for database.
just declare some variables as an array and load your file, then save your text to the variables in the array.

-----------------------------------
Thuged_Out_G
Fri Jan 23, 2004 11:50 pm


-----------------------------------

var stream:int
var line:string
var count:=0
var words:array 1..1000 of string
open:stream,"filename.txt",get
assert stream >0

loop
count +=1
if count > 1000 then
exit
else
get:stream,skip
exit when eof(stream)
get:stream,line
words(count):=line
end if
end loop

for i:1..1000
put words(i)
if words(i)="" then
if words(i+1)="" then
exit
end if
end if
end for


-----------------------------------
Zorg
Fri Jan 23, 2004 11:54 pm


-----------------------------------
Thank you so much! :D

-----------------------------------
McKenzie
Sat Jan 24, 2004 12:07 am


-----------------------------------
but put 
get:stream,skip
above
exit when eof(stream)
