[Coco] Basic09

Wayne Campbell asa.rand at gmail.com
Sun Apr 28 14:22:21 EDT 2013


I want to go further on this subject. My last response was done on my
android, so I could not say all I was thinking.

Line numbers in Basic09 are optional. They are essentially like labels in
C, except they are required to be numbers in Basic09. When you pack your
code to i-code, all unused line numbers are stripped. "Valid" line numbers
are referenced by the use of GOTO or GOSUB statements, IF-THEN <ln>
statements (ex IF x>y THEN 100), ON <exp> GOTO/GOSUB statements, and
RESTORE <ln> statements that include a line number reference. RESTORE
without a line reference restores to the first DATA statement and does not
have a line reference.

TYPE and DIMension statements can occur anywhere in the source listing. If
you attempt to use a variable name before the occurance of the DIM
statement, the variable will be of type REAL regardless of what type you
named in the DIM statement (unless the name ends with $), and Type Mismatch
errors will occur. Let me repeat this. By-use variables are only of type
REAL (myReal) or STRING (myString$). If you want to use BYTE, INTEGER,
BOOLEAN or any STRING < or > 32 characters, you must use a DIM statement.
Using the DIM :STRING type, you are NOT required to use the $ character as
the last character of the variable name. DIM :STRING with no length
modifier ([1-32767]) results in a 32-character string. As by-use variables
default to type REAL, use of DIM :REAL statements are optional. That said,
I DIM all variables because I can find mistakes more easily, The most
common problem is misspelled variable names. Example:

DIM next,prev:INTEGER

next:=prev+1

IF nxet=5 THEN
...
ENDIF

nxet will be a REAL variable because next is the integer and nxet has not
been DIMed. It will also contain a random value.

There was a post recently that referenced the source listings for inkey and
syscall. The inkey listing is in the level 1 and level 2 manuals. The
syscall listing I only found in one manual (but I believe it applies to
earlier versions as well) which was the Basic reference in the OSK 2.4
manuals that came with a TC-70(?) that was owned by Alan Sheltra. I have
never seen a source listing for the 6809 version of syscall. And yes, they
are very different due to the register differences between 6809 and 680x0.

valid variables:

by use:

name:=10. (REAL type 5 bytes)
name$:="hello world" (STRING type 32 characters in length)

DIM:

DIM alpha:BYTE (1-byte variable)
DIM beta:INTEGER (2-byte variable)
DIM theta:REAL (5-byte variable)
DIM delta:BOOLEAN (1-byte variable, true or false values only)
DIM aString:STRING[3] (3-byte string)
DIM anotherStr:STRING (32-byte string)
DIM another$:STRING[500] (500-byte string)

Variables can contain numbers and the _, but the first character has to be
a letter (I think or the _, but not sure). Variable names can be 29
characters in length maximum.

Hope this helps.

Wayne

On Sun, Apr 28, 2013 at 5:28 AM, Wayne Campbell <asa.rand at gmail.com> wrote:

> You do not have to declare all variables in Basic09. By use allows type
> real (ex funds) or type string (ex comment$).
>
> Also dim statements can appear anywhere in the program, but the variable
> cant be used prior to it or you will get wrong type errors.
> Type mismatch I think.
>
>
> Bill Pierce <ooogalapasooo at aol.com> wrote:
>
> >
> >Frank, if I remember right, you had to save the Basic program in Ascii,
> then use an OS9 text editor and save before loading into Basic09. There
> will be more errors than imaginable, but Basic09 mkarks them for easy
> editing.
> >I remember moving several simple Basic files to Basic09 back in the 80s.
> The biggest thing is the Data structure. Basic allowed you to introduce
> variables at any time just by using them. In Basic09, you had to declare
> all variables. I would always go through the prorgam and fix all the
> variables. It eventually became a habit in Basic to declare my variables
> early as a habit because of my work in Basic09.
> >
> >Bill Pierce
> >My Music from the Tandy/Radio Shack Color Computer 2 & 3
> >https://sites.google.com/site/dabarnstudio/
> >Co-Webmaster of The TRS-80 Color Computer Archive
> >http://www.colorcomputerarchive.com/
> >Co-Contributor, Co-Editor for CocoPedia
> >http://www.cocopedia.com/wiki/index.php/Main_Page
> >E-Mail: ooogalapasooo at aol.com
> >
> >
> >
> >
> >-----Original Message-----
> >From: Frank Swygert <farna at att.net>
> >To: coco <coco at maltedmedia.com>
> >Sent: Sun, Apr 28, 2013 7:51 am
> >Subject: Re: [Coco] OS-9 History
> >
> >
> >Date: Sun, 28 Apr 2013 02:39:51 -0400
> >From: Aaron Wolfe<aawolfe at gmail.com>
> >
> >You may find this summary of OS9 print ads interesting or informative :
> >
> >http://aaronwolfe.com/coco/earlyos9/
> >==================================================
> >
> >Very informative indeed, Aaron! That's a nice compilation of OS-9 ads and
> >information. I never knew that one could program in BASIC09 with a line
> number
> >structure just like DECB! If I'd known that I may have tried to port a
> couple
> >BASIC programs I'd written years a go to BASIC09. Would have been neat to
> run
> >them under OS-9, and not too hard to port using the same structure.
> >
> >
> >--
> >Coco mailing list
> >Coco at maltedmedia.com
> >http://five.pairlist.net/mailman/listinfo/coco
> >
> >
> >
> >--
> >Coco mailing list
> >Coco at maltedmedia.com
> >http://five.pairlist.net/mailman/listinfo/coco
>



More information about the Coco mailing list