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:)
- Announcing the TIB 2024 Advent Calendar (News:1)
- Code GCC produces that makes you cry #12684 (Prog:39)
- RISCOSbits releases a new laptop solution (News:)
- 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)
- RISC OS London Show Report 2024 (News:1)
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: Tokenised Basic
 
  Tokenised Basic
  (19:43 21/3/2002)
  monkeyson (12:00 22/3/2002)
    Phlamethrower (19:18 22/3/2002)
      Chris (14:48 23/3/2002)
      ninj (18:16 26/3/2002)
        Chris (18:18 28/3/2002)
          Matthew (19:53 28/3/2002)
            Chris (23:53 28/3/2002)
 
Chris Message #4998, posted at 19:43, 21/3/2002
Unregistered user Hi.

I just got a copy of Virtual Acorn and it prompted me to get back into a little programming again. Last I did was years ago on an A3000. I don't have access to the PRMs or much documentation any more.

I'd appreciate some help with the following. I'm trying to write an app in BASIC that generates new BASIC programs and saves them into a file. I thought this would be reasonably straightforward until I remembered that BBC BASIC files are tokenised. I've since been struggling to work out the format of the tokenised files. What I'm stuck on is what the first three bytes on each line do. I guess they're something to do with the line numbers, but any informed information on how to manipulate them (or how to write to BASIC files in general) would be much appreciated.

If this is a stupid or oft-repeated query I apologise: as I say, I've only got back into programming recently. I did look around on the net for info, though, without much luck.

Cheers,
Chris

  ^[ Log in to reply ]
 
monkeyson Message #4999, posted at 12:00, 22/3/2002, in reply to message #4998
Unregistered user BASIC programs don't have to be be tokenised. You could write them as plain ASCII, and with the right filetype, they should work.

Or are you trying to read IN basic files as well?

Probably a look at the StrongEd or Zap source code would help.

  ^[ Log in to reply ]
 
Phlamethrower Message #5000, posted at 19:18, 22/3/2002, in reply to message #4999
Unregistered user
BASIC programs don't have to be be tokenised. You could write them as plain ASCII, and with the right filetype, they should work.

I think you actually have to get BASIC to load the text and re-save it before you can run it normally. I may be wrong though.

You could have a look at Brandy, a cross-platform BASIC interpreter:

http://www.argonet.co.uk/users/dave_daniels/

The source will be in C though, so might not be the easiest to understand if you only know BASIC.

All I can offer you is what's in an old BBC machine code book, which features a couple of BASIC fiddling programs:

The first byte is &D, the new line character.
The next two are the line number (high byte first)
The next is the line length; adding this to the address of the &D should find the next &D
Then you have the line itself.

The end of a file should be terminated by any top-bit set byte, after the last &D. This means the line number limit is 32767.

There are a couple of tokens given: &F1 is PRINT, and &E0 is END. Tokens range from &80 to &FF; anything else can be taken as plain text

  ^[ Log in to reply ]
 
Chris Message #5001, posted at 14:48, 23/3/2002, in reply to message #5000
Unregistered user Thanks - that looks very helpful. I'll see how I get on.

Cheers.

  ^[ Log in to reply ]
 
ninj Message #5002, posted at 18:16, 26/3/2002, in reply to message #5000
Unregistered user The BBC User Guide, I think it was, used to contain amonst other miscellanea, a list of the tokens for Basic II. Using that I remember writing a BASIC program lister in BASIC back in the day - that line header information is spot on, if I remeber rightly. That program's likely to be stored on a forgotted corroding tape somewhere only though.

Loading plain text into BASIC (a feature implemented in BASIC V, I think) does work quite well, although it does have to tokenise it and store it in memory before running it. Bear in mind that it is possible to write a tokenised program that can't be generated from any plain text - not all programs will survive being converted to plain text and back.

  ^[ Log in to reply ]
 
Chris Message #5003, posted at 18:18, 28/3/2002, in reply to message #5002
Unregistered user I've managed to get hold of a list of the tokens by peering into the source of another program. The line header information was, as you say, spot on. Thanks to all.

If anyone's interested, I could post the list of tokens somewhere. Perhaps on the Iconbar BASIC pages?

  ^[ Log in to reply ]
 
Matthew Message #5004, posted at 19:53, 28/3/2002, in reply to message #5003
Unregistered user
If anyone's interested, I could post the list of tokens somewhere. Perhaps on the Iconbar BASIC pages?

If you like; just email them to me (apologies again for lack of progress with programming section; and now Finals looming...). But I've done a search on Google (for BBC Basic tokens) and found:

http://www.geocities.com/SoHo/6413/BBC-Ch47.html
http://www.geffers.demon.co.uk/files/chap2.htm
http://www.cix.co.uk/~rrussell/products/bbcwin/manual/bbcwinb.html

Are any of them any good?

ATB,
Matthew

  ^[ Log in to reply ]
 
Chris Message #5005, posted at 23:53, 28/3/2002, in reply to message #5004
Unregistered user The middle link is for BASIC on the Oric (!), while the other two are for BBC BASIC (First is from the BBC Micro User Guide, third from BBC BASIC for Windows). I guess either of these would be fine.
  ^[ Log in to reply ]
 

Acorn Arcade forums: Programming: Tokenised Basic