log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- Will we see 5.30 released at Wakefield show? (News:)
- Prizes for Wakefield Show announced (News:)
- Heretic update from R-Comp (News:)
- Wakefield Show 2024 is next Saturday (News:)
- Git client updated to 0.07 (News:2)
- Archive Edition 27:1 reviewed (News:)
- Rougol April 2024 meeting on monday is Anniversary time (News:1)
- WROCC April 2024 meeting o...changes to our phone lines (News:1)
- April developer 'fireside' chat is on saturday night (News:)
- March 2024 News Summary (News:4)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
 
View on Mastodon
@www.iconbar.com@rss-parrot.net
Site Search
 
Article archives
The Icon Bar: Programming: Read tes=xt files in BASIC
 
  Read tes=xt files in BASIC
  (20:02 1/8/2001)
  Matthew (14:58 15/6/2002)
    rich (11:05 2/8/2001)
      Matthew (14:58 15/6/2002)
  RevinKevin (14:58 15/6/2002)
    monkeyson (14:58 15/6/2002)
      RevinKevin (14:58 15/6/2002)
        RevinKevin (16:20 15/9/2001)
 
RevinKevin Message #4801, posted at 20: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 etc

And 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 11: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 16: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 14: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 etc

And 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. smile 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 14: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. smile 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 14: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 ADFSDisc4tonguerog.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 14: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"wink

from your program

  ^[ Log in to reply ]
 
RevinKevin Message #4807, posted at 14:58, 15/6/2002, in reply to message #4806
Unregistered user Thanks thats just what I wanted smile
  ^[ Log in to reply ]
 

The Icon Bar: Programming: Read tes=xt files in BASIC