This reference should help you to quickly answer most questions you have about BASIC on the TRS-80 Model 100. It includes a list of all commands with explanations as well as documentation about behavior, data types, and I/O devices
Loading and saving is done using the LOAD and SAVE instructions from most devices (including tape), or CLOAD and CSAVE for tape only.
Maximum safe serial speed for loading is 600 baud. For saving, the maximum possible port speed (19200 baud) can be used.
You cannot load tokenized BASIC programs over modem or serial, only ASCII versions. When saving, BASIC automatically forces ASCII mode for those devices.
After the file, 0x1A
is sent over the line to signify the end of load/save.
This chapter explains syntax and its behavior.
This version of BASIC is of the numbered type. Execution starts at the lowest line number in incremental order. It is common to have 10 as the first number and then increment in steps of 10. This allows insertion of up to 9 lines between two existing lines. The exact line range on the Model 100 is from 0 to 65529.
Line numbers cannot contain decimals. Trying to enter 1.5 PRINT "A"
will instead store .5 PRINT "A"
at line 1,
and subsequently cause a syntax error when run.
Note: Using higher line numbers does not use more memory than lower line numbers. Line numbers are always stored as an unsigned 16 bit integer.
Instructions can be combined into a single line using :
.
Example: 10 PRINT 1 : PRINT 2
will print "1", then "2"
Note: you can only jump and call line numbers but not instructions contained within. This means you can create useless instructions this way:
10 PRINT "L10.1" : GOSUB 30 : PRINT "L10.2"
20 PRINT "L20" : END
30 PRINT "L30"
40 PRINT "L40.1" : RETURN : PRINT "L40.2"
If you run this program, "L10.2" and "L40.2" are never printed. Line 10 is shortcut by the GOSUB, which will jump away to line 30. Line 40 is shortcut by RETURN, which jumps to the line after GOSUB: line 20.
Various optimizations for speed and memory can be performed by the developer.
Putting computationally expensive routines first:
Every time a line completes, BASIC searches the next line by scanning through all lines in ascending order from the start until it finds the next line, or reaches the end of the program. This means a FOR loop at the beginning of your program runs faster than one further down in the program. In other words, you may want to have the most computationally expensive routines at the start.
Note: BASIC automatically sorts line numbers as you type them. Fast routines need to have low line numbers and not necessarily need to be typed first.
Note: Higher line numbers are not automatically slower than lower numbers. Starting to number at 1 is just as fast as starting to number at 60'000. For speed it only matters how many actual lines preceed the current line.
Saving memory:
Saving memory has two important purposes:
Each valid line takes at least 6 bytes of storage as follows:
You can save 5 bytes for every instruction you concatenate using :
Example:
10 PRINT 1
20 PRINT 2
30 PRINT 3
Each of these lines uses 8 bytes. 6 as shown above and 2 for the space and the number that follows the PRINT keyword, totalling to 24 bytes.
The lines could be combined to save storage and speed up your program:
10 PRINT 1 : PRINT 2 : PRINT 3
This only uses 20 bytes as shown in the hex dump below:
8F 80 0A 00 A3 20 31 20 3A 20 A3 20 32 20 3A 20 ....ú 1 : ú 2 :
A3 20 33 00 ú 3.
Formatted (O=Offset, L=Line, I=Instruction, E=End marker, .=As-is):
OO OO LL LL II .. .. .. .. .. II .. .. .. .. .. OOLLI.....I.....
II .. .. EE I..E
You can further optimize it by removing unnecessary whitespace. BASIC is very special in how it reads instructions. It basically stops reading data as soon as an instruction has been found, then it tokenizes the instruction and keeps the rest as a string. All of these lines are considered a valid comment:
10 REM Comment
20 REMComment
30 Remoulade sauce
This means the example print statements can be optimized down to this:
10 PRINT1:PRINT2:PRINT3
This uses only 13 bytes as shown below:
9C 80 14 00 A3 31 3A A3 32 3A A3 33 00 ....ú1:ú2:ú3.
Formatted:
OO OO LL LL II .. .. II .. .. II .. EE OOLLI..I..I.E
Note: The space beweeen the line number and the instruction you see in the listing is not stored anywhere.
It's only shown for display purposes.
Typing 10PRINTA$
is the same as 10 PRINTA$
At this point you may notice that the code becomes harder to read. There is a tradeoff between memory optimizations and readability. The line below is as optimized as possible but may be hard to read.
3 IFITHENPRINTI
This means IF I THEN PRINT I
, which can be translated to "If I is not zero, print it"
Stripping comments:
Do not write excessive comments, or use a tool that removes them before publishing. Comments take up memory like any other line does, and they're processed like any other line. This means they take up memory and processing power.
Referencing strings:
If your program gets so big that free memory starts to become a problem, you can reference strings instead of using constants.
PRINT E$
is shorter than PRINT "Some string"
if you need "Some string" in at least two locations.
The longer the string you can reference, the bigger the memory savings.
Minimize output:
One of the biggest performance killers is the LCD output. The display is abysmally slow, especially when it has to scroll a line. Writing 10 lines in sequencs is slower than writing 5 lines, clearing the display, then writing the other 5.
If you need to output a lot of data, consider writing it to file, or offering the option to dump it to the serial port.
Operating modes are the modes that BASIC can be in. These are entry, edit, and run mode. By default BASIC is in entry mode.
Entry mode is the default mode. In entry mode, lines without a line number are run as you commit them. If a line starts with a number, it's stored in memory. This overwrites existing lines. A lone line number can be used to delete a line.
BASIC will automatically re-sort lines when you insert one between two existing lines.
Edit mode can be entered by typing EDIT.
F8 ends edit mode and commits all changes.
Edit mode can only be entered if at least one instruction has been added in entry mode,
The shortest way to create a line is to type 1'
in entry mode.
This mode behaves like the built-in text editor, including saving and loading to/from tape.
When exiting edit mode, all changes will be applied. Depending on the number of lines you edit, this can take a long time, so it's advised to limit the edit range if possible.
It's not possible to exit edit mode without also saving your changes.
The lines are applied as if they were typed in entry mode. This means:
Additionally, lines you completely delete will also be deleted from your program.
If a line is invalid (for example missing a line number or over 255 characters long), an error message will be shown when you try to exit edit mode.
Note: Edit mode will not do syntax validation beyond checking for line numbers.
In run mode your program is run.
If the program won't exit, pressing [SHIFT]
+[PAUSE]
can be used to force it to stop.
BASIC knows 4 data types:
Double precision is the default type when no suffix symbol is supplied.
The default can be changed using the DEFxyz
series of commands.
There is no boolean type in BASIC.
BASIC uses the integer -1
to signify true
and 0
to signify false
.
In general, any non-zero value is considered true
however,
this means IF I%<>0 THEN
is the same as IF I% THEN
#
<decimal>D<int>
Note D
instead of the commonly used E
for exponential notation.
Using D
signifies double precision.
Examples:
A# = 12
B# = 1.23456789D5
C# = A# × B#
!
<decimal>E<int>
Note E
in this case means a single precision number
instead of a generic exponential notation.
The range of the exponent is identical to the double precision type. The decimal portion is given less memory space.
Examples:
A! = 12
B! = 1.234E5
C! = A! × B!
%
<int>
Integers are the most efficient type of number in terms of calculations and storage. Negative numbers are stored in two's complement form.
BASIC has no unsigned integer type.
Examples:
A% = 12
B% = -42
C% = B% + A%
$
"<chars>"
Examples:
A$ = "Test"
B$ = "String"
C$ = A$ + " " + B$
Variable names consist of a letter, followed by one or more numbers or letters. Only the first two characters of the variable name are significant. These names all represent the same variable:
SU, SUPER, SUPERSCRIPT
Additionally, certain combinations of letters are reserved by BASIC as keywords or "reserved words", which have special meaning to the BASIC Interpreter. You may not use such combinations as variable names. Example:
TOTAL, LAND, NAME, LENGTH
They cannot be used as variable names because they contain the keywords:
TO, AND, NAME, and LEN, respectively.
BASIC supports single and multi dimensional arrays. An array must be declared first using the DIM statement.
Note: When dimensioning arrays,
be aware that the number argument to DIM
is the upper array index,
and not the length. Array indexing starts at zero,
so an array made with DIM A%(3)
has 4 entries.
You may include more than one array per DIM statement, for example:
DIM MN$(12), JMPTB%(10,100)
How many dimensions you can use depends on the free memory. If, for example, you have 20000 bytes of memory free, you may define an integer array as:
DIM ARR%(5,5,5,5,5)
without error, since integers each take up two bytes of memory, so this array contains 15552 elements (6^5 × 2). However, if you try to dimension a double precision array with the statement:
DIM DBA#(5,5,5,5,5)
you’ll generate an error since this array requires 62208 bytes of memory. Remember that double precision numbers require eight bytes of memory each.
Entries in an array must all be of the same type.
BASIC understands many mathematical and logical operators.
+
Addition, or unary plus-
Subtraction, or unary minus*
Multiplication/
Division with decimals\
Integer division (always rounds down)^
ExponentiationMOD
Modulus\
can by typed with GRAPH
+-
BASIC automatically converts numbers to double precision or integer if needed.
Note: \
and MOD
are integer operations.
This means you cannot perform them if the arguments don't fit into a 16 bit signed integer.
c = a \ b
for large numbers you can use c=FIX(a/b)
c = a MOD b
for large numbers you can use c=b-a*FIX(a/b)
+
ConcatenationConcatenation is the only operator. It glues two strings together. Multiple variables and constants can be used at once:
A$="Wed"
B$="nes"
C$="day"
D$="To" + C$ + " is " + A$ + B$ + C$
D$ will contain "Today is Wednesday"
BASIC will throw an error if the result is longer than 255 characters.
Note: It's possible to reduce maximum string length using CLEAR. This can save memory if you happen to have lots of strings.
<
Less than>
Greater than=
Equal to<>
Not equal to><
Same as <>
>=
Greater than or equal=>
Same as >=
<=
Less than or equal=<
Same as <=
For numerical expressions, BASIC simply compares them mathematically.
Strings are compared using their ASCII code values. Comparison stops at the first mismatch. Example:
10 IF "AbC">"ABc" THEN PRINT "test"
This comparison is true
Comparing strings of different lengths adds implicit nullbytes to the shorter string. This makes the shorter string be less than the longer string if it's identical otherwise.
Logical expressions operate on the bits of integers. Floating point numbers are converted to integers first.
These operators are mathematical and logical at the same time.
3 OR 8
will not simply say true
but 11
,
which is true
because of how BASIC deals with boolean values.
Result is 1 if both inputs are 1
Left | Right | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
1 AND 2 = 0
3 AND 2 = 1
Result is 1 if at least one bit is 1
Left | Right | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
1 OR 2 = 3
3 OR 8 = 11
Result is 1 if exactly one bit is set.
This is like OR
but without accepting both bits set to 1 simultaneously
Left | Right | Result |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
2 XOR 3 = 2
8 XOR 2 = 10
Note: A speciality about XOR is that it's reversible.
These all hold for any given integer value of A,B,C:
C = A XOR B
B = A XOR C
A = B XOR C
Result is 1 if both bits are identical.
This is basically the inverse of XOR
.
It outputs 1 where XOR would output 0 and vice versa.
Left | Right | Result |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
The same reversibility as with XOR applies.
Result is 1 unless the first bit is 1 and the second bit is zero
Left | Right | Result |
---|---|---|
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 0 |
1 | 1 | 1 |
Note: I have no idea what they were consuming when this operator was made.
Inverts every bit. Note: This operator has only one argument
Right | Result |
---|---|
0 | 1 |
1 | 0 |
NOT 5
REM Results in -6
BASIC provides a means for "assigning" a value to given variable via the "assignment" statement. An assignment statement takes the form:
var = expression
Assignment statements tell the computer to replace the previous value of a variable with the value of the expression. For example:
A = A + 1
is a valid BASIC statement. It tells the computer to add 1 to the value currently in A, and store the new value back into A.
Note: BASIC does not support the ++
and --
operators from C.
BASIC allows you to combine expressions.
C = A + B
C = C / 5
C = C + 3
Is identical to
C = (A + B) / 5 + 3
Operands are processed as given below:
()
: Parentheses^
: Exponentiation+
,-
: Unary plus and minus (not to be confused with addition and subtraction)*
,/
,\
: Multiplication and divisionMOD
: Modulo+
,-
: Addition and subtraction<
,>
,=
,>=
,<=
,<>
: ComparisonNOT
: Logical negationAND
: Logical ANDOR
: Logical ORXOR
: Logical XOREQV
: Logical inverse XORIMP
: Logical bit selectionParentheses are processed from the inside out. Operators on the same level are processed left to right.
With these rules, BASIC performs operations mostly like other tools would.
Since BASIC supports multiple data types, conversion might be necessary.
Numeric types can be simply converted by assigning them to a different type. Example:
I% = 15.5
will assign 15 to I as it's declared as an integer.
BASIC will simply truncate the number, which means cutting off the decimals. This will not round the number mathematically, but always towards zero. This behavior is identical to the FIX function.
Trying to assign a number outside of the permitted range to an integer will throw an overflow error.
Assigning a double precision number to a single precision variable will cut off excess digits by rounding mathematically using 4/5 rule. Example:
A! = 1.2345678901234567
Assigns 1.23457 to A!
This always works because of the extended number range. BASIC adds trailing decimal zeros as needed.
To convert between numbers and strings, you must call VAL or STR$ to manually convert the value in the desired direction.
You may find yourself in the need to read and write to files or ports. BASIC treats files and ports in an identical fashion, this means the same code can be used to write to either a file or the serial port.
Known ports and their abbreviations:
Name | Mode | Device | Argument |
---|---|---|---|
CAS | R/W | Cassette tape | Filename |
RAM | R/W | Memory file | Filename |
COM | R/W | RS-232 port | Config |
MDM | R/W | Modem port | Config |
LPT | W | Printer | None |
LCD | W | Display | None |
Mode indicates whether you can Read or Write with this device.
CAS:FILENAME
Reads or writes a file to/from tape. File name consists of 1 to 6 characters, the first one must be a letter.
For some commands the file name may be optional. In that case BASIC will just read the first file it finds.
RAM:FILENAME.EXT
Reads or writes a file to/from memory.
Same file name rule as the CAS
device.
An extension is needed. Three extensions are supported:
Note: "RAM" itself is usually optional. BASIC assumes RAM if no device is specified.
COM:BDPSF
Each letter represents a single character setting:
The rates are represented with ascending integers: 1 = 75, 9 = 19200
Speeds above 300 tend to overflow the receive buffer of the device if you're not careful.
Mismatching with the remote end will yield none or garbled output.
Ranges from 6-8 and describes the data bits.
Almost always this will be 8. Setting this to 6 or 7 may prevent you from transmitting some characters.
Mismatching with the remote end will yield none or garbled output.
Either E,O,I, or N.
Note that N is not the same as I. I means that the parity bit is sent and received, but ignored. N does not send the bit at all and expects the other end to not send it either.
Mismatching with the remote end will yield garbled output or missing characters.
This is either 1 or 2, 1 is more common.
Mismatching with the remote end will yield none or garbled output.
Either E or D
When enabled, either the Model 100 or the computer on the other end of the RS-232C line can automatically transmit an XON or XOFF to start or stop transmission. When disabled, any XON or XOFF must either come from the program or by pressing CTRL+Q or CTRL+S, respectively.
Mismatching with the remote end may prevent the output from starting.
MDM:DPSF
Each letter represents a single character setting:
For the meaning of each of the settings, see the COM
chapter above.
Note: There is no baud rate setting for the modem. It always operates at 300 baud. Make sure you properly set the modem switches on the left side of the device. The Model 100 doesn't supports DTMF dialing.
LPT:
Simply sends all text to the printer port. Usually not needed as LPRINT does the same without the file I/O overhead.
LCD:
Sends all text to the LCD. Usually not needed as PRINT does the same.
The TRS provides 5 interrupts that the BASIC program can utilize.
The following interrupts are available:
COM
: Data received on serial portMDM
: Data received on modem portKEY
: Function key pressedTIME$
: Clock based interruptERROR is a special interrupt and has to be treated differently.
Sets the line number that BASIC jumps to on an interrupt. Registering an interrupt handler will not automatically enable interrupts.
Note: You must end interrupt processing using RETURN
ON
: Enables processing of the interrupt XOFF
: Disables processing of the interrupt XSTOP
: Halts processing of the interrupt X but still allows queuing"X" is one of the interrupt values from the list further above.
STOP
simply suspends interrupt processing temporarily,
but still allows an interrupt to be queued for later processing.
Enabling interrupts using ON
makes BASIC immediately jump to the interrupt handler if an interrupt is pending.
Code | Id | Description |
---|---|---|
1 | NF | Next without for |
2 | SN | Syntax Error |
3 | RG | Return without gosub |
4 | OD | Out of data |
5 | FC | Illegal function call |
6 | OV | Overflow |
7 | OM | Out of memory |
8 | UL | Undefined line |
9 | BS | Bad subscript |
10 | DD | Double dimensioned array |
11 | /0 | Divide by zero |
12 | ID | Illegal direct |
13 | TM | Type mismatch |
14 | OS | Out of string space |
15 | LS | String too long |
16 | ST | String formula too complex |
17 | CN | Can't continue |
18 | IO | IO error |
19 | NR | No resume |
20 | RW | Resume without error |
21 | UE | Undefined error |
22 | MO | Missing operand |
23-49 | UE | Undefined error |
50 | IE | Undefined error |
51 | BN | Bad file number |
52 | FF | File not found |
53 | AO | Already open |
54 | EF | Input past end of file |
55 | NM | Bad file name |
56 | DS | Direct statement in file |
57 | FL | Undefined error |
58 | CF | File not open |
59-255 | UE | Undefined error |
Below is a listing of all instructions in alphabetical order.
ATN(num)
Returns the arctangent of numeric expression (in radians). The resulting value ranges from -π to +π
BEEP
Emits a tone for approximately 0.5 seconds.
This command has no arguments. See SOUND for how to play specific sounds.
CALL addr
CALL addr, expr1, expr2
Calls into machine level code at address "addr". The "A" CPU register is set to "expr1" and the "HL" register to "expr2"
"expr1" and "expr2" are optional. If not specified, the register values are undefined. (Probably not true, but the manual makes zero mention about what happens by default)
CDBL(expr)
Converts "expr" into a double precision number. Value may be a string or number.
CHR$(num)
Converts "num" into the character with the given ASCII code. "num" must be in the range 0-255
with num=34 this can be used to print the double quote.
CINT(expr)
Converts "expr" into an integer. Value may be a string or number.
CLEAR
CLEAR num1
CLEAR num1,num2
Clears the values in all numeric and string variables, and closes all open files.
"num1" is optional, and if supplied defines how much memory to allocate for each string. If not supplied it defaults to 256 and cannot be set higher than that. Setting it higher will not throw an error though.
"num2" defines where the high memory starts. BASIC will not allocate memory above the specified number. This can be used to protect machine language programs and working memory from getting overwritten. If not supplied it defaults to the value of MAXRAM and effectively allows BASIC to use all RAM.
Note that when you enter BASIC, it always resets the string space allocation to 256 bytes. However, if you have protected a portion of high memory in a previous program, BASIC keeps this part of memory protected until you use CLEAR to change it.
CLOAD
CLOAD "filename"
CLOAD "filename",R
Loads a program from tape. Without any arguments will load the first program it finds.
"filename" can be used to specify the file to load. In this mode, BASIC prints every file name it skips over.
The R
argument immediately runs the program after it has been loaded.
Note the absence of quotes for this argument, it is just the literal R
.
This instruction is like LOAD but without having to specify the CAS device manually.
CAUTION! CLOAD clears the existing program from memory.
CLOAD? "filename"
Compares the current program in memory with the given program from tape. As BASIC searches the tape, it prints out the names of any files it skips over.
Prints "Verify failed" or "Ok" depending on whether the programs are identical or not.
CLOADM
CLOADM "filename"
Loads a machine language program from tape into memory. File name is optional. If not specified, BASIC loads the first program it finds. As BASIC searches the tape, it prints out the names of any files it skips over.
This instruction is like LOADM but without having to specify the CAS device manually.
CLOSE numlist
Closes all given file numbers. "numlist" is simply a comma separated list of integers.
CLS
Clears the screen and resets the cursor to the top left.
COM ON
COM OFF
COM STOP
Enables or disables the interrupt defined with ON COM.
Check the "Interrupts ON/OFF/STOP" chapter for more details.
CONT
Continues execution after a program was interrupted via BREAK key or a STOP command.
Note: Continuing is no longer possible if you insert/edit/delete lines. You can cheat the system by using a GOTO instead in that case, but you need to know the line number for this.
COS(num)
Calculates the cosine of the given angle in radians.
CSAVE "filename"
CSAVE "filename",A
Saves the program with the given file name to tape.
The literal A
argument stores the program in ASCII format.
If not supplied, the program is stored in a tokenized form to save some space.
To perform certain commands, such as MERGE, programs must be stored in ASCII format. However, for most uses, you'll want your programs stored in a compressed format to save space on the tape. Tokenization is not identical across different BASIC version, so ASCII should be used if you plan on deploying the program on a machine with a different BASIC.
CAUTION! Make sure you do not overwrite existing programs on tape! When you want to edit a program from tape, it's best to load it from tape, save to ram, then edit from there. Only copy it back to tape when you're completely done editing.
CSAVEM "filename",start,end
CSAVEM "filename",start,end,entry
Saves a machine level program to tape. This is done by storing the memory contens specified by "start" and "end".
"entry" specifies the entry point into the program. If not supplied, it's assumed that the program entry point is at "start"
CSNG(expr)
Converts the supplied number or string into a single precision number.
CSRLIN
Returns the vertical position (line number) of the cursor, where 0 is the top line and 7 is the bottom line.
See POS for horizontal position.
DATA constlist
Stores "constlist" in memory. "constlist" is a list of numerical and/or string constants that can be loaded using READ at runtime. Example of a list:
10 DATA 10,25,50,15,"Probabilities","Total"
DATE$
DATE$="value"
This is a global variable that holds the current date.
It can be read and set. The format of the value is mm/dd/yy
.
When setting, the value must be supplied within double quotes.
Note: The year is only two digits.
The main menu prefixes this with 19
.
The system has no real calendar however,
and you can overwrite the weekday using DAY$ to the correct weekday
you would expect for a year after 2000
The system is not aware of leap years.
DAY$
DAY$="day"
Gets or sets the weekday. Valid values are 3 letter weekdays: Mon,Tue,Wed,Thu,Fri,Sat,Sun
When setting, the value must be supplied within double quotes.
DEFDBL letterlist
Defines variables that are treated as double precision floating point by the first letter of the variable name. This allows you to omit the type suffix. "letterlist" can be a combination of individual letters or ranges.
Example: D,X-Z
is identical to D,X,Y,Z
Suffixes (see data types) override this setting.
Note: Since double is the standard type, you usually don't need this command, unless you want to revert some variable back to default.
See DEFDBL
This command is identical in syntax but defines variables as integers.
See DEFDBL
This command is identical in syntax but defines variables as single precision.
See DEFDBL
This command is identical in syntax but defines variables as strings.
DIM var(num)
DIM var(numlist)
Declares the variable "var" as array and defines the upper bound as "num"
multiple comma separated numbers can be supplied as "numlist" to create multi dimensional arrays.
Note: Contrary to most other languages,
the numbers specify the upper bound and not the array size.
Because arrays are indexed at zero,
it will be one bigger than the number specified.
DIM A(3)
thus has 4 indexes, from 0 to 3 inclusive.
Array size and dimensions are limited by available memory.
Multiple declarations on one line are possible: DIM A$(5), B%(10), ...
Note: You cannot change array sizes once set. You must use CLEAR to clear the entire variable space to re-declare an array. This will however delete all stored values too. Tip: You can use files to temporary store the values.
EDIT
EDIT line
EDIT line1-line2
EDIT line-
EDIT -line
EDIT .
EDIT -.
EDIT .-
Edits a BASIC program. Press F8
to exit the editor and commit changes.
If you edit a line in such a way that it is not a valid program line,
for example, longer than 255 chars, no line number, or invalid line number,
the Editor tells you Text Ill-formed
,
and pressing the space bar returns you to the Text Editor.
You can not just edit, but also insert and delete lines. Inserting a line will overwrite an existing line with the same number if it exists.
You do not need to enter the editor for all changes:
END
Terminates the program unconditionally. An END is implied after the last line and you don't need to explicitly add one.
EOF(num)
Returns "true" when the given file pointer is at the end. "num" is a file that has been opened with OPEN
This can be used with the devices that support reading.
ERL
Returns the line number of the last error. If the last error occured was from an instruction without a line number, the value 65535 is returned.
This behaves like a constant and not a function and thus can be used in conditional and print statements.
Example: PRINT "Error on line";ERL;"!"
ERR
Returns the numerical value of the last error. This behaves like a constant and not a function and thus can be used in conditional and print statements.
Example: PRINT "Error ";ERR;" on line ";ERL;"!"
ERROR num
Triggers the given error as if it really happened. Will invoke error handlers if defined using ON ERROR previously.
EXP(num)
Calculates the antilog. The number must be in the range ±87.3365 or an overflow error is triggered.
FILES
Shows all files from the RAM
device on the screen.
Note: This function directly writes to the LCD. It cannot be used to store file names in a variable. There is no way to retrieve a file listing in a BASIC program. You need to manually peek into memory for this.
FIX(num)
Returns the number without any decimals. Decimals are simply cut off.
The difference between FIX
and INT is that for negative numbers,
FIX
simply truncates the numeric expression (rounding towards zero)
while INT
returns the whole number not greater than the numeric expression.
FOR var=start TO final
FOR var=start TO final STEP increment
NEXT
NEXT var
NEXT varlist
Creates a loop.
Assigns "var" the value "start" before the first iteration.
After every iteration, "increment" is added to "var".
If not speficied, the default increment is 1.
Once "var" reaches or exceeds "final", the loop is terminated,
and code execution continues after the matching NEXT
statement.
Note: When checking for the end condition, BASIC is aware whether the loop is decrementing or incrementing, and it correctly checks for whether the value exceeds the set limit.
Example: FOR A%=8 TO -5 STEP -2 : ? A%;" "; : NEXT
will print the numbers 8, 6, 4, 2, 0, -2, -4
Note: The exit condition is checked after the code inside of the loop body is run. This means that the loop always executes at least once.
Note: if "start", "final", or "increment" are variables, BASIC will only scan them once at the first loop iteration, and changing them within the loop has no effect on the loop anymore.
Any number of loops can be nested until the memory limit is reached.
Specifying "var" in a NEXT
is optional, and in fact, slower than not specifying it.
BASIC keeps track of the loop nesting
and thus always knows which NEXT
corresponds to which FOR
.
You cannot use NEXT var
to jump out of an inner loop.
"varlist" in a NEXT
can be used to combine multiple instructions into one line.
The variables are given as a comma separated list with the innermost variable first.
A loop that is missing a NEXT simply runs once but will not throw an error when the program ends.
FRE(expr)
Returns the amount of free space.
Note: The value of "expr" is ignored. This function only cares about the type. It's common to use zero or an empty string constant respectively. The expression can also be a variable, in which case the variable type decides the behavior.
GOSUB line
Like GOTO but also remembers the current line number.
RETURN must be used to jump to the next line after the GOSUB
call.
"line" refers to any line in your program. It must be constant.
GOSUB
and RETURN
are used to implement primitive function calls.
Because this instruction remembers the current line, it will consume memory.
Make sure you always RETURN
from a GOSUB
or you eventually consume all memory.
There is no way to tell BASIC to forget GOSUB
lines you missed to return to.
The memory is cleared when your program ends.
CAUTION! Instructions on the same line after a GOSUB (added via :
) are ignored
Note: Skipping the THEN
statement does not work with GOSUB
like it does with GOTO
GOTO line
Unconditionally jumps to the given line and continues processing instructions from there.
You can jump conditionally by using GOTO
with an IF statement.
"line" refers to any line in your program. It must be constant.
Jumping to the current line will trap your program in an infinite loop.
CAUTION! Instructions on the same line after a GOTO (added via :
) are ignored
Instead of jumping to a piece of code only to jump back later,
consider a GOSUB
and RETURN
pair.
Note: When using GOTO
with an IF
you can skip the THEN
.
See the IF ... THEN ... ELSE chapter for details.
HIMEM
This function returns the top address of memory available to BASIC. You may change this value with the CLEAR command.
IF condition THEN cmd1
IF condition THEN cmd1 ELSE cmd2
Executes "cmd1" if "condition" is true, otherwise executes "cmd2" (if specified that is).
"cmd1" and "cmd2" can also be a plain line number to make basic treat it as a GOTO.
Example: These are all identical and jump to line 100 if A is 12:
10 IF A=12 THEN 100
10 IF A=12 GOTO 100
10 IF A=12 THEN GOTO 100
Also works with ELSE
like this: IF A=12 THEN 100 ELSE 200
To execute multiple commands in an IF statement, either a GOSUB can be used, or commands can be concatenated using a colon.
INKEY$
Gets the currently held down keyboard key.
If no key is held down, this value is an empty string.
Unsupported keys may result in a nullbyte being stored in the value.
Simple loop that waits for a key press: 10 IF INKEY$="" THEN 10
INP(port)
Reads an integer value from the given CPU port. "port" must be in the range 0-255.
INPUT varlist
INPUT "prompt";varlist
Reads a line from the keyboard and fills the variables in varlist. If supplied, "prompt" is shown on the screen before reading from keyboard begins. BASIC appends "?" to the prompt string when displaying it.
"varlist" is a comma separated list of variables.
Example: INPUT "Birthday";A$,B%
would expect an input like Apr, 25
You may enter enough data, separated by commas, for all of the variables in variable list, terminated with ENTER. Alternatively, you may enter each data item separately, pressing ENTER after each. In the latter case, after accepting the first value, BASIC displays two question marks as a prompt for subsequent input.
For string input, you may enclose the data in quotes, although BASIC doesn't require this. However, if the input string contains any leading blanks, commas, or colons, you must use quote marks.
BASIC lets you input numeric data into string variables. BASIC stores the ASCII value - not the numeric value!
For numeric input, BASIC performs any necessary conversion to the numbers so that they fit into the variable. This conversion is identical to other data conversions in the program. If you attempt to input string data into a numeric variable, BASIC displays the message "?Redo from start" followed by another "?", and lets you try again.
This chapter should be named "INPUT #" but is not due to technical reasons.
INPUT #num,varlist
Like regular INPUT, but reads values from the supplied file number into "varlist". You may input data with this command from these devices: RAM, CAS, COM, MDM
Note: The data in the file must be separated by commas, not whitespace
INPUT$(num)
INPUT$(num,file)
Reads "num" characters from the keyboard (or "file" if file number is specified).
Range for "num" is 1-255.
This function will not echo captured keys onto the screen.
This function blocks until exactly as many characters as specified have been read.
See INKEY$
for a non-blocking version.
Note: The BREAK key cannot be read this way.
INSTR(source,search)
INSTR(start,source,search)
Searches for the "search" string in the "source" string. Begins searching at position "start". If "start" is not specified, the entire string is searched.
Returns the string offset of where "search" was found. Returns zero if not found.
The search is case sensitive
Note: Unlike arrays, strings are indexed from 1, not zero.
INT(num)
Returns the largest integer not bigger than "num". For positive numbers, this is identical to FIX, but for negative numbers, this always rounds towards the next lower integer.
Example: INT(-5.1) is -6
while FIX(-5.1) is -5
Note: This function does in no way convert the argument to a 16 bit integer. It simply cuts off decimals as shown.
IPL
IPL "filename"
Defines the program that should be automatically run whenever the device turns on. This can only be used with files stored in RAM, and you do not need to specify the "RAM:" prefix.
If used without an argument, disables autorun again.
Note: The file does in no way need to be a BASIC program. It can also be a document or machine language file. You can even run the internal programs like TELCOM this way.
This command is the equivalent of you selecting a file or program from the list and pressing ENTER.
KEY num,"value"
Assigns "value" to the given function key "num" (1-8). Pressing the matching function key will pretend to type "value" on the keyboard.
Note: To reset the keys to their default, run these two instructions:
CALL 23164,0,23366
CALL 27795
KEY LIST
Shows the value of all 8 function keys on the screen
KEY (num) ON
KEY (num) OFF
KEY (num) STOP
Enables, disables or pauses function key interrupts for the given function key.
"num" must be in the range 1-8 inclusive.
Check the Interrupts ON/OFF/STOP chapter for more details.
KILL "file"
Deletes the given file. "RAM" doesn't needs to be specified as this function only works on RAM files.
Note: If you have 200 bytes or less of free memory, KILL may not delete a file. If this situation occurs, delete program lines manually or go to TEXT, "select" a file, and put it in the PASTE Buffer. Then return to BASIC and KILL the unwanted files.
LCOPY
Copies text currently shown on the screen to the printer. This is a one time operation and will not continue to print text written to the screen after this command is issued.
LEFT$(str,count)
Returns the leftmost "count" characters from "str".
LEN(str)
Returns the number of characters in "str".
LET var=assignment
Assigns "assignment" to "var".
This only exists for backwards compatibility with other BASIC versions.
On TRS BASIC you can just assign values as-is without using LET
The assignment must match the variable type (num vs string)
LINE (x1,y1)-(x2,y2)
LINE (x1,y1)-(x2,y2),switch
LINE (x1,y1)-(x2,y2),switch,B
LINE (x1,y1)-(x2,y2),switch,BF
Draws a line from the pixel "x1,y1" to "x2,y2".
The top left corner is "0,0", x is horizontal, y is vertical. The screen size of the model 100 is 240 by 64 pixels.
"switch" is numeric, and if supplied tells BASIC whether to set or clear pixels. Odd values set pixels and even values clear pixels. If not supplied, it's assumed to be odd. It must be supplied for the "B" or "BF" argument to be used.
"B" tells BASIC to draw a rectangular box instead of a line. "BF" is the same but fills the box.
Lists the current program on the screen.
The line numbers argument behave identical to the EDIT
command.
Like LIST but outputs on the printer.
LINE INPUT var
LINE INPUT "prompt";var
Reads a line from the keyboard as-is without processing. This differs from INPUT:
LOAD "dev:filespec"
LOAD "dev:filespec",R
Loads a program from the given device, and optionally runs it immediately if a literal R
is supplied.
Loading from cassette tape can also be done with CLOAD instead.
See "File and device I/O" for how to use devices.
LOADM "CAS:FILENAME"
LOADM "RAM:FILENAME"
Loads a machine language program from cassette or RAM. You cannot use this to load machine language programs from the serial port or modem.
Where exactly the file is loaded has to be defined previously with SAVEM.
LOG(num)
Calculates the natural logarithm of the supplied value.
LPOS(num)
Returns the current position of the printer print head. "num" is discarded, but the argument must be supplied and be a number type.
Prints out the supplied values on the printer.
If the expressions are separated by commas,
then the printer prints a value and advances to the next "print zone" before printing the next value.
The print zones are defined every 14 columns (at column 0, column 14, column 28, and so on).
Print zones can be skipped by not supplying arguments between commas.
Example: LPRINT X,,,Z
If the expressions are separated by semicolons, the printer pints each value with no space between. All numbers are printed with a trailing blank. If the number is negative, the sign precedes the number, otherwise a blank precedes the number. No blanks precede or follow strings.
Note: Unlike PRINT
, LPRINT
has no command shortcut.
LPRINT USING "format";expression
Prints the expression in a formatted manner on the printer. See PRINT USING for details.
MAXFILES
MAXFILES=num
Gets or sets the maximum number of files the current BASIC program can simultaneously have open at any given time. This behaves like a variable, and not a function. The default value is 1.
MAXRAM
Contains the memory size of your Model 100. You may access it like any variable, except that you may not redefine its value.
Can be used as the second argument to CLEAR to allocate all free memory to BASIC.
MDM ON
MDM OFF
MDM STOP
Enables or disables the interrupt defined with ON MDM
.
Check the Interrupts ON/OFF/STOP chapter for more details.
MENU
Exits BASIC and returns to the main menu. The current BASIC program is retained in a temporary invisible file but is overwritten silently if BASIC is launched again with an existing file.
MERGE "filespec"
Loads the supplied program from storage or serial port, then merges it with the existing program.
The merge algorithm is very simple. It simply loads all lines from the supplied file and pretends to type them. This adds new lines but also overwrites existing lines, but never deletes lines.
MID$(str,pos)
MID$(str,pos,length)
MID$(str,pos)=value
MID$(str,pos,length)=value
Without assigning "value":
Returns "length" characters of "str" beginning at "pos". Reads to the end of the string if "length" is not supplied.
With assigning "value":
Overwrites the substring defined by pos with "value". This mode always ignores "length" and simply overwrites as many characters as "value" is long. "str" is never extended. If "value" is too long, it's truncated to fit.
Example:
10 A$="1234567890"
20 MID(A$,8)="TEST"
30 PRINT A$
This overwrites the segment "890" with "TES". The last "T" is dropped because it will not fit. The result is "1234567TES"
MOTOR ON
MOTOR OFF
Turns the tape drive motor on or off. For this to work, you must have a tape drive that supports the "remote" 2.5 mm plug.
NAME "filespec1" AS "filespec2"
Renames a file. "filespec1" and "filespec2" must reference a "RAM" file. Other devices cannot be used.
Renaming is only performed if "filespec2" does not already exists.
Note: You cannot change the file extension with this.
NEW
Erases the current program, sets numeric variables equal to zero, and sets string variables equal to empty string.
This does not change the string space allocation.
See: FOR ... NEXT
ON KEY GOSUB linelist
ON x GOSUB line
Defines an interrupt handler. When an interrupt is triggered, it jumps to the given "line".
"linelist" must be supplied if the device is KEY. In that case, supply up to 8 line numbers (for F1-F8 keys) separated by comma. You can skip the value between commas to not define an interrupt for a given function key.
Possible values for "x":
COM
: Triggers when data on the serial port is receivedKEY
: Triggers when a function key is pressedMDM
: Triggers when data arrives at the modem portTIME$="HH:MM:SS"
: Triggers at the given timeON ERROR GOTO line
Jumps to the given line if an error occurs.
Note: This works similar to an interrupt, except that you can't turn it off, and you use RESUME instead of RETURN to continue regular execution.
Note: Use ERR and ERL to determine type and location of the error.
ON expr GOTO linelist
Evaluates "expr" to an integer "n", then branches to the nth line number in the linelist.
Numeric expression must evaluate to a non-negative number, which, if zero or greater than the number of line numbers in the list, tells BASIC to continue execution without branching.
Example: 10 ON X% GOTO 123,456,789
goes to 123, 456,
or 789 depending if X equals 1, 2, or 3, respectively.
Identical to ON ... GOTO except it uses GOSUB and thus allows RETURN
OPEN "filespec" FOR mode AS num
Opens a device for readon or writing. See "File and device I/O" for details on "filespec" and whether you can read and/or write.
"mode" is either OUTPUT, INPUT, or APPEND. OUTPUT silently overwrites existing data. APPEND is only supported by files from RAM.
"num" is a file number that is used in other file I/O commands to identify the file.
OUT port,byte
Writes "byte" (0-255) to the given CPU "port" (0-255). This is the matching opposite command of INP
PEEK(addr)
Reads a byte (0-255) from the given memory location.
POKE addr,val
Writes the byte "val" (0-255) to the memory address "addr".
CAUTION! Be careful with this! Writing to some locations can brick your device and requires a hard reset.
POS(num)
Returns the horizontal position of the cursor on the screen.
"num" is ignored but must be a numeric value or variable.
See CSRLIN for vertical position.
POWER num
Sets the automatic power down period. "num" has a range of 10 to 255. The Model 100 will automatically turn off after a period of "num"×0.1 minutes if you are neither running a program nor entering commands. The default value is 100 (10 minutes).
POWER CONT
Disables automatic shutdown on idle.
POWER OFF
POWER OFF,RESUME
Turns the device off.
If "RESUME" is supplied, the memory state of the current program is kept, and execution continues on the next power on. If not supplied, the device returns to the main menu.
PRESET(x,y)
Turn off an LCD pixel. To turn pixels on, use PSET
PRINT expr
? expr
Prints the given expression to the screen.
The items in expression list are separated by commas or semi-colons. If commas are used, the cursor automatically advances to the next "print zone" before printing the next item. Print zones are at column 0 and column 14. If semi-colons are used, no space is inserted between the items printed on the display.
Positive numbers are printed with a leading blank and all numbers are printed wtth a trailing blank. Trailing zeroes to the right of the decimal point are not printed. No blanks are printed before or after strings. BASIC automatically moves the cursor to the next line after printing the expression list.
?
may be used instead of PRINT
. They're identical in behavior.
PRINT@ pos, expr
?@ pos, expr
Like print, except it writes at the given display position.
"pos" is the offset in characters.
The display is 40*8
characters in size, so it should be in the range of 0-319.
Note: This variant of the print will also print a newline at the end. This means printing on the lowest display line scrolls the screen.
This chapter should be named "PRINT #" but is not due to technical reasons.
PRINT# filenum, expr
?# filenum, expr
Like print, except:
PRINT USING "format";expression
Prints the expression in a formatted manner to the screen.
"format" is made up of one or more tokens:
!
: Prints only the first character of the string\ \
: Prints the given number of spaces (+2) characters from the string#
: Prints the value as number. Token may be repeated to reach the desired width. Data is right-aligned+
: Prints "+" or "-" depending on the current number value-
: Like +
but prints a space instead of a plus for positive numbers.**
: For right-aligned numbers, uses asterisks instead of spaces to format the number$$
: Prints the $ sign before the number1**$
: Like **
but the last *
is instead printed as $
. Basically combines **
and $$
.
: Defines where the decimal point is. Example: ####.##
,
: Performs number grouping with a comma every 3 digits.^^^^
: Specifies exponential formatExample: PRINT USING "\ \ #####,.## #####,.##";A$,IBAL,OBAL
If A$ contains the string "Cramer,W D", IBAL equals 1440.44, and OBAL equals 980.00, then this statement prints:
Cramer,W.D 1,440.44 980.00
A single format may be specified for multiple values.
Example: PRINT USING "**####.## ";A,B,C
If A contains 34, B contains 44.323, and C contains 12333.33, then this statement prints out:
$34.00 $44.32 $12333.33
Note that the blanks in the format string are significant.
In addition, characters other than the field specifiers are insetted as is, provided there is enough space in the field.
PRINT #num USING "format";expr
Behaves like PRINT USING but writes to file instead of the screen.
PSET(x,y)
Turns the given pixel on. This is the opposite of PRESET
READ expr
Reads values from a DATA into the variables supplied by the comma separated expression. The variable types must match the types defined in the DATA statement.
Example:
100 DATA 0.4, 0.2, "Trinity River"
110 READ A,B%,C$
assigns A the value 0.4, B% the value 0.2, and C$ the string "Trinity River".
REM
REM any
'
' any
Inserts a comment into the program. Comments are ignored, but lines are still processed, meaning a program with comments runs slower than a program without.
Note: A comment always goes to the end of the instruction,
meaning a :
in a comment will end it. The line 10 REM PRINT 1 : PRINT 2
will print "2".
REM
cannot directly be used after an instruction and must be it's own command.
PRINT 1 REM Test
PRINT 1 : REM Test
The apostrophe however can be used directly:
PRINT 1 'Test
PRINT 1 : 'Test
Note: For some reason, '
is faster to process than REM
RESTORE
RESTORE line
Resets the pointer for DATA back to the start of the given "line".
If "line" is not supplied, the read pointer is restored to the first line that contains a DATA
instruction.
Note: There is only a single data read pointer in a given program.
RESUME
Resumes execution after the instruction that triggered an ON ERROR branch.
RETURN
Resumes execution after the last GOSUB instruction.
RIGHT$(str,count)
Returns the "count" rightmost characters of "str".
RND(num)
Returns a pseudorandom number between 0 and 1.
If "num" is non-zero, a new number is generated. If "num" is zero, the generator keeps returning the last number.
Note: RND
always generates the same random number series.
To make it appear more random you can use TIME$ to extract time component
and discard some samples from the RNG.
Example:
10 SEC%=VAL(RIGHT$(TIME$,2))
20 FOR I%=1 TO SEC%
30 DISCARD=RND(1)
40 NEXT
RUN
RUN line
RUN line,R
RUN "filespec"
RUN "filespec",R
Runs a program. Running a program will clear all variables.
Without any argument runs the current program from start.
With "line" runs the current program from the given line on.
With "filespec", loads the given program from storage media and runs it.
This is identical to LOAD "filespec" followed by RUN
without an argument.
The plain "R" tells run to not close open files.
RUNM "filespec"
Loads and runs the given machine language program. "filespec" must be a RAM or CAS file.
BASIC closes all open files before running the machine language program.
There is no "R" like regular RUN
has.
SAVE "filespec"
SAVE "filespec",A
Saves a BASIC program to the given device. "filespec" can also be LPT or LCD. When using RAM, existing files are overwritten. For writing the program to printer, consider simply using LLIST instead. CSAVE can be used as a shortcut to write to tape.
The plain "A" tells BASIC to not tokenize the program, and store as plain ASCII instead. A is automatically implied when not using CAS or RAM files.
SAVEM "filespec",start,end
SAVEM "filespec",start,end,entry
Saves a machine level program to a file. "filespec" must be a CAS or RAM file. Other devices are not supported.
using CAS is the same as using CSAVEM
"start" is the start memory offset to begin copying from. "end" is the last memory offset to copy. "entry" is the entry point. If not supplied, "start" is assumed to be the entry point.
SCREEN 0,0
SCREEN 0,1
Shows (0,1) or hides (0,0) the label line.
SGN(num)
Gets the sign of "num".
If "num" is zero, returns zero, otherwise returns 1 for positive "Num" or -1 for negative "num".
SIN(num)
Calculates sinus in radians of "num"
SOUND pitch,length
Emits a sound from the spaker.
"pitch" ranges from 0 to 16383 and approximately represents the inverse frequency in Hz. "length" ranges from 0-255. Dividing by 50 returns the approximate time in seconds.
Below is a table of pitch values for a given note and octave
Note | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
G | 12538 | 6269 | 3134 | 1567 | 783 |
G# | 11836 | 5918 | 2959 | 1479 | 739 |
A | 11172 | 5586 | 2793 | 1396 | 698 |
A# | 10544 | 5272 | 2636 | 1318 | 659 |
B | 9952 | 4976 | 2484 | 1244 | 622 |
C | 9394 | 4697 | 2348 | 1174 | 587 |
C# | 8866 | 4433 | 2216 | 1108 | 554 |
D | 8368 | 4184 | 2092 | 1046 | 523 |
D# | 7900 | 3950 | 1975 | 987 | 493 |
E | 7465 | 3728 | 1864 | 932 | 466 |
F | 7032 | 3516 | 1758 | 879 | 439 |
F# | 6642 | 3321 | 1660 | 830 | 415 |
SOUND ON
SOUND OFF
Enables or disables system generated beeps. These are:
Note: This command does not affect any other sound generating commands, such as BEEP and SOUND.
SPACE$(num)
Returns a string of length "num" that's entirely made up of spaces.
SQR(num)
Returns the square root of "num"
STOP
Stops execution of the program. CONT can be used to resume execution after where it was stopped. This command primarily functions as a way to define breakpoints for debugging.
Note: After stopping, you can only continue if you do not alter the program.
STR$(num)
Converts a number into a string representation.
Note: You only need this to assign numbers to string variables. Output functions like PRINT can handle numbers as-is.
STRING$(length,char)
Creates a string of length "length" made up exclusively of "char".
"length" can be 0-255. "char" can be a string or number. If a string, the first character of the string is used and duplicated. If a number, it's interpreted as an ASCII code and must be in the range of 0-255.
Note: STRING$(num," ")
and STRING$(num,32)
are identical to SPACE$(num)
TAB(num)
Advances the output cursor to the given offset from the beginning of the line. If the cursor is already past the offset, no action is taken.
Note: This can only be used as part of an output command like PRINT
Example: PRINT "TEST";TAB(10);"TEST"
prints "TEST",
then moves the cursor farther by 6 characters to the offset 10,
then prints another "TEST".
TAN(num)
Calculates the tangent of "num" in radians.
TIME$
TIME$="HH:MM:SS"
Gets or sets the current time in 24 hour format.
CAUTION! Setting hour above 24 will brick the time value until you manually set it to a valid value again
TIME$ ON
TIME$ OFF
TIME$ STOP
Enables or disables the interrupt defined with ON TIME$
.
Check the Interrupts ON/OFF/STOP chapter for more details.
VAL(str)
Interprets the value stored in a string as a number. It only returns the leading number found in a string. Returns zero if not able to convert the string to a number. This is the inverse of STR$.
VARPTR(var)
Gets the memory location of the given variable. Can be useful if you need to pass a variable to a machine language function.
This chapter contains commands sorted by category. This can help you discover commands for certain tasks. Some commands may be duplicated across multiple categories.
These commands change the program flow
These commands set, define, and handle interrupts
Commands regarding data input and oputput
This chapter contains functions and values not included in BASIC but which can be easily created from existing BASIC functions.
SEC(X) = 1/COS(X)
CSC(X) = 1/SIN(X)
COT(X) = 1/TAN(X)
ARCSIN(X) = ATN(X/SQR(-X*X+1))
ARCCOS(X) = -ATN(X/SQR(-X*X+1))+1.5708
ARCSEC(X) = -ATN(SQR(-X*X+1))+(SGN(X)-1)*1.5708
ARCCSC(X) = ATN(1/SQR(-X*X+1))+(SGN(X)-1)*1.5708
ARCCOT(X) = -ATN(X)+1.5708
SINH(X) = (EXP(X)-EXP(-X))/2
COSH(X) = (EXP(X)+EXP(-X))/2
TANH(X) = -EXP(X)/(EXP(X)+EXP(-X))*2+1
SECH(X) = 2/(EXP(X)+EXP(-X))
CSCH(X) = 2/(EXP(X)-EXP(-X))
COTH(X) = EXP(-X)/(EXP(X)-EXP(-X))*2+1
ARCSINH(X) = LOG(X+SQR(X*X+1))
ARCCOSH(X) = LOG(X+SQR(X*X-1))
ARCTANH(X) = LOG((1+X)/(1-X))/2
ARCSECH(X) = LOG((SQR(-X*X+1)+1)/X)
ARCCSCH(X) = LOG((SGN(X)*SQR(X*X+1)+1)/X)
ARCCOTH(X) = LOG((X+1)/(X-1)/2)
PI = 4*ATN(1)
This chapter contains test programs for your model 100.
Prints all 256 ASCII characters to the display. The top line may disappear due to the display size limit. You can add an INPUT$(1) to the end to prevent this temporarily, or use the version that skips the first 32 characters.
10 DEFINT I
20 FOR I=0 TO 255
30 PRINT @I,CHR$(I)
40 NEXT
Without unprintable chars:
10 DEFINT I
20 FOR I=32 TO 254
30 PRINT @I-32,CHR$(I)
40 NEXT
Compact versions:
FORI=0TO255:?@I,CHR$(I):NEXT
FORI=32TO254:?@I-32,CHR$(I):NEXT
This approximately plays the 3 tone sound you hear when you dial non existing numbers.
10 SOUND 2636,19
10 SOUND 2092,19
10 SOUND 1660,19
Compact version:
SOUND2636,19:SOUND2092,19:SOUND1660,19
Echoes all received characters back to the sender. Also shows them on screen if they're in the printable range The program doesn't actually cares about the file opened on line 50, but it's the easiest way of configuring and activating the serial port.
10 DEFINT I,J
20 J=0
30 ON COM GOSUB 200
40 COM ON
50 OPEN "COM:88N1D" FOR INPUT AS #1
100 PRINT "Echo program running"
110 PRINT "Connect remote computer and send data"
120 PRINT "Press any key to exit"
130 S$=INKEY$
140 IF LEN(S$)>0 THEN CLOSE #1:END ELSE 130
200 COM STOP
210 I=INP 200
220 IF I>31 THEN GOSUB 300
220 OUT 200,I
230 COM ON:RETURN
300 PRINT @J,CHR$(I)
310 IF J<239 THEN J=J+1 ELSE J=0
320 RETURN
Note: An easier way to test the port is to short the TxD and RxD lines together and then use the TELCOM program. Setting it to full duplex mode will show all characters on screen. In half duplex, they show up twice.
The pins you need to connect are 2 and 3. If you look at the port you may see faint numbers on it. 1 is top right, 13 is top left. 14 is bottom right, 25 is bottom left.
Copyright © 2022 by Kevin Gut 📧 | More services | Generated for 3.145.110.145