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
- WROCC Newsletter Volume 41:11 reviewed (News:)
- WROCC March 2024 meeting o... Hughes and Peter Richmond (News:1)
- Rougol March 2024 meeting on monday with Bernard Boase (News:)
- Drag'n'Drop 13i2 edition reviewed (News:)
- South-West Show 2024 talks (News:4)
- February 2024 News Summary (News:1)
- Next developer fireside chat (News:)
- DDE31d released (News:)
- South-West Show 2024 Report (News:)
- South-West Show 2024 in pictures (News:)
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
Acorn Arcade forums: Programming: BASIC output to file
 
  BASIC output to file
  (13:58 15/6/2002)
  incubus (12:31 8/5/2001)
    guy (14:19 8/5/2001)
    Matthew (10:02 9/5/2001)
      guy (13:10 9/5/2001)
 
incubus Message #4767, posted at 12:31, 8/5/2001, in reply to message #4766
Unregistered user Try this:

CH = OPENOUT"test"
PRINT #CH,"Hello World"
CLOSE #CH

Will create a file called "test" and print "Hello World" into it.

To do byte writes to a file use
BPUT #CH, value
where value is 0 to 255

Reading from the file
CH = OPENIN"test"
INPUT#CH, text$
CLOSE #CH
PRINT text$

Also, other file commands:
PTR#CH = x sets the file pointer to x
PRINT PTR#CH to display the current file pointer
PRINT EXT#CH to display the file size

Hope this helps

  ^[ Log in to reply ]
 
guy Message #4768, posted at 14:19, 8/5/2001, in reply to message #4767
Unregistered user looks the biz.
wait till I get home!

many thanks.

  ^[ Log in to reply ]
 
Matthew Message #4769, posted at 10:02, 9/5/2001, in reply to message #4767
Unregistered user
CH = OPENOUT"test"
PRINT #CH,"Hello World"
CLOSE #CH

Will create a file called "test" and print "Hello World" into it.

I prefer BPUT#CH,"Hello World" (BPUT# can take a byte, as you said, but also a string). This puts the string in the file, but in a readable format. To get it back, use GET$#CH.

You can find help in BASIC by typing "HELP <command>" or "HELP ." for a list of all commands.

ATB,
Matthew

  ^[ Log in to reply ]
 
guy Message #4770, posted at 13:10, 9/5/2001, in reply to message #4769
Unregistered user
I prefer BPUT#CH,"Hello World" (BPUT# can take a byte, as you said, but also a string). This puts the string in the file, but in a readable format. To get it back, use GET$#CH.

Thanks, I'll try this too.

You can find help in BASIC by typing "HELP <command>" or "HELP ." for a list of all commands.

Great, if I knew what commands I was looking for...
.. but then I do now, don't I?
Thanks again.
  ^[ Log in to reply ]
 
guy Message #4766, posted at 13:58, 15/6/2002
Unregistered user Hi,

sounds so simple, but I don't have a BBC basic manual handy.

What are the BBC Basic commands to create/open an output file (on my A5000), send text to it and close it again?

A "hello world" example would be nice smile

If this is beneath the Icon Bar's dignity, what is the url of Archive-on-line?

  ^[ Log in to reply ]
 

Acorn Arcade forums: Programming: BASIC output to file