Viewing txt file
Author |
Message |
bc123

|
Posted: Tue Nov 03, 2009 7:54 pm Post subject: Viewing txt file |
|
|
Hey 2day at skewl i made this thing to view database but i forget code
need to know correction asap
Turing: |
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 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Superskull85
|
Posted: Tue Nov 03, 2009 11:25 pm Post subject: RE:Viewing txt file |
|
|
You will need to include a get statement inside your loop:
Turing: | 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

|
Posted: Wed Nov 04, 2009 1:31 pm Post subject: RE:Viewing txt file |
|
|
i dont undterstand |
|
|
|
|
 |
Kharybdis

|
Posted: Wed Nov 04, 2009 3:12 pm Post subject: RE:Viewing txt file |
|
|
If i remember it correctly...
Turing: | 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

|
Posted: Wed Nov 04, 2009 8:14 pm Post subject: 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
|
Posted: Wed Nov 04, 2009 10:02 pm Post subject: 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:
Turing: | 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:
Turing: | 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 ) |
|
|
|
|
|
 |
|
|