|
Read tes=xt files in BASIC |
|
(19:02 1/8/2001) Matthew (13:58 15/6/2002) rich (10:05 2/8/2001) Matthew (13:58 15/6/2002) RevinKevin (13:58 15/6/2002) monkeyson (13:58 15/6/2002) RevinKevin (13:58 15/6/2002) RevinKevin (15:20 15/9/2001)
|
|
RevinKevin |
Message #4801, posted at 19:02, 1/8/2001 |
Unregistered user
|
Is it possible to read a text file in BASIC and display the info on screen e.g A text file contains word 1, word 2 word 3 etcAnd the BASIC program would print word 1 then word 2 on the next line and so on. Thanks |
|
[ Log in to reply ] |
|
rich |
Message #4803, posted at 10:05, 2/8/2001, in reply to message #4802 |
Unregistered user
|
That's from memory, so could be wrong (I'm not at home currently and have a horrible feeling about the while loop) I usually use...in%=OPENIN
"ADFS::4.$.file" REPEAT line$=GET$#in% PRINT line$ UNTIL EOF#in% CLOSE#in% |
|
[ Log in to reply ] |
|
RevinKevin |
Message #4808, posted at 15:20, 15/9/2001, in reply to message #4807 |
Unregistered user
|
Thanks to all who replied to my earlier questions. The results can be found on my web page http://www.oberon.spaceports.com/~kevsite/Computing And is called info. Any comments and tips for improvements will be greatfully recceived. |
|
[ Log in to reply ] |
|
Matthew |
Message #4802, posted at 13:58, 15/6/2002, in reply to message #4801 |
Unregistered user
|
Is it possible to read a text file in BASIC and display the info on screen e.g A text file contains word 1, word 2 word 3 etcAnd the BASIC program would print word 1 then word 2 on the next line and so on. You need something like this (assuming the text file has one word per line like you want the output) : I%=OPENIN("textfile" ) WHILE NOT EOF#I% A$=GET$#I% PRINT A$ ENDWHILE That's from memory, so could be wrong (I'm not at home currently and have a horrible feeling about the while loop...), but it's the sort of thing you want to be doing. Try typing HELP OPENIN etc. at the BASIC prompt to get some pointers, and there's a StrongHelp BASIC manual downloadable from http://www.users.zetnet.co.uk/kappa/Strong/basic.htm ATB, Matthew |
|
[ Log in to reply ] |
|
Matthew |
Message #4804, posted at 13:58, 15/6/2002, in reply to message #4803 |
Unregistered user
|
I usually use...in%=OPENIN "ADFS::4.$.file" REPEAT line$=GET$#in% PRINT line$ UNTIL EOF#in% CLOSE#in% But with this version, something is printed even if the file is empty, which you probably don't want. BTW, I have checked and my WHILE look is okay. But I forgot the vital CLOSE#I% at the end which closes the open file. ATB, Matthew |
|
[ Log in to reply ] |
|
RevinKevin |
Message #4805, posted at 13:58, 15/6/2002, in reply to message #4801 |
Unregistered user
|
Thanks That works. But is it possible to have a relitive file location i.e instead of ADFSDisc4rog.textfile just have texttile Because the textfile will be in the same directory as the progarm. Thanks |
|
[ Log in to reply ] |
|
monkeyson |
Message #4806, posted at 13:58, 15/6/2002, in reply to message #4805 |
Unregistered user
|
If you create an Obey file, with something like Set ilikemonkeys$dir <Obey$Dir> Wimpslot -min 32k -max 32k <ilikemonkeys$dir>.BasicFile - replace the 32k with the amount of memory needed by your program, and ilikemonkeys with something more sensible... Then you can do f = OPENIN("<ilikemonkeys$Dir>.Textfile" from your program |
|
[ Log in to reply ] |
|
RevinKevin |
Message #4807, posted at 13:58, 15/6/2002, in reply to message #4806 |
Unregistered user
|
Thanks thats just what I wanted |
|
[ Log in to reply ] |
|
|