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
- 10 RISC OS gift ideas for Christmas (News:)
- Drag'N'Drop Autumn edition now available (News:)
- !DualHead puts 2 screens in one (News:)
- RISC OS London Show 2017 - Notes from the talks (News:6)
- November News (News:)
- !Organizer 2.28 reviewed (News:2)
- !OBrowse reviewed (News:10)
- Aemulor (Gen:16)
- DDE reaches release 28 and above (News:)
- Elesar quicks dispels stormy clouds (News:2)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
Site Search
 
Article archives
The Icon Bar: 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 ]
 

The Icon Bar: Programming: BASIC output to file