
-----------------------------------
bc123
Tue Nov 03, 2009 7:54 pm

Viewing txt file
-----------------------------------
Hey 2day at skewl i made this thing to view database but i forget code
need to know correction asap



var input : int
var view : string
loop
open : input "brandon.txt", get
put "stats"
put input, view
exit when eof (input)
end loop
close (input)

i jus forgot a line or two

-----------------------------------
Superskull85
Tue Nov 03, 2009 11:25 pm

RE:Viewing txt file
-----------------------------------
You will need to include a get statement inside your loop:

get : input, view : * %Adding ": *" to the end gets the entire line instead of each word.
You also should not be opening the same file over and over unless you close it first (ei. you should not put an open statement in your loop).

-----------------------------------
bc123
Wed Nov 04, 2009 1:31 pm

RE:Viewing txt file
-----------------------------------
i dont undterstand

-----------------------------------
Kharybdis
Wed Nov 04, 2009 3:12 pm

RE:Viewing txt file
-----------------------------------
If i remember it correctly...

var input : int
var view : string
open : input, "brandon.txt", get

loop

exit when eof (input)
get : input, view 
put input, view

end loop

close (input)

-----------------------------------
bc123
Wed Nov 04, 2009 8:14 pm

RE:Viewing txt file
-----------------------------------
doesnt work for me
it says

attempted on unopen stream number -10. open on line 3 failed with message 'file

any idea???

-----------------------------------
Superskull85
Wed Nov 04, 2009 10:02 pm

RE:Viewing txt file
-----------------------------------
That means that went wrong when you tried to open that file (could be caused if the file did not exist in the same folder as your .t file).

Also to output the contents to the screen you do not need to include the file ID. So instead of this code:

var input : int
var view : string
open : input, "brandon.txt", get

loop

exit when eof (input)
get : input, view
put input, view

end loop

close (input)
Should be:

var input : int
var view : string
open : input, "brandon.txt", get

loop

exit when eof (input)
get : input, view
put view %File ID "input" is not needed.

end loop

close (input)
