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
- Elsear brings super-fast Networking to Risc PC/A7000/A7000+ (News:)
- Latest hardware upgrade from RISCOSbits (News:)
- RISCOSbits releases a new laptop solution (News:1)
- RISC OS London Show Report 2024 (News:1)
- Announcing the TIB 2024 Advent Calendar (News:1)
- Code GCC produces that makes you cry #12684 (Prog:39)
- Rougol November 2024 meeting on monday (News:)
- Drag'n'Drop 14i1 edition reviewed (News:)
- WROCC November 2024 talk o...ay - Andrew Rawnsley (ROD) (News:2)
- October 2024 News Summary (News:3)
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