n88-basic-reference

This translation is a work in progress and does not contain all the commands possible in PC-88 BASICs.

Structures

Labels

A label provides a line reference that can be called by GOTO or GOSUB without having to manually track the line number and update it if it changes.

Example:

10 PRINT "HELLO"
20 GOSUB *WORLD
30 END
40 *WORLD: PRINT "WORLD"
50 RETURN

Commands

ASC

Usage: ASC([char])

Convert the first character of a string to the numeric ASCII index for it.

Examples:

BEEP

Usage: BEEP <mode>

It beeps.

Examples:

BLOAD

Usage: BLOAD [filename] <load address> <,R>

Load a machine-language program.

If load address is omitted, it will be loaded to the address specified when the binary was saved with BSAVE.

Append R to immediately run the program. If a load address is also specified, execution will begin from that address.

Examples:

CALL

Usage: CALL [variable] (,argument 1) (,argument 2) ...

Call a machine-language subroutine. The variable argument holds the address of the subroutine to execute from.

CHR$

Usage: CHR$([index])

Return the shift-JIS character corresponding to an integer character code.

Shift-JIS table for reference

Examples:

CINT

Usage: CINT([value])

Convert to a 16-bit signed integer.

Values between -32768 and 37267 are valid, everything else gets an overflow error.

Examples:

CLS

Usage: CLS <mode>

Clear the screen.

Modes:

CONSOLE

Usage: CONSOLE [scroll start], [scroll number of lines], [display function keys], [colour/monochrome]

Set modes for text screens.

Examples:

CONT

Usage: CONT

Resume execution from a STOP or END statement.

CSNG

Usage: CSNG([number])

Convert a number to a single-precision float.

Examples:

CSRLIN

Usage: CSRLIN

Return the screen row number that the cursor is on.

In 25-line mode, this will be 0-24. In 20-line mode, this will be 0-19.

0 is the topmost row of the screen.

DATE$

Usage DATE$

Variable containing the current date, in YY/MM/DD format.

Examples:

DEF FN

Usage DEF FN[NAME][ARGUMENTS] = [BODY]

Define a function.

Examples:

110 DEF FNDB(X)=X*2
120 PRINT "Twice 10 is";FNDB(10)

DELETE

Usage: DELETE [line number]

Delete a line number from the current BASIC program.

Examples:

DIM

Usage: DIM [NAME]([size0], [size ...])

Define an array.

If the array described by NAME already exists, you will get a “duplicate definition” error. Use ERASE to remove the variable definition and then you can recreate it.

Examples:

DSKF

Usage: DSKF([drive number]<, parameter>)

Get information on a floppy disk inserted into drive drive number. Note that drive numbers are 1-indexed.

Parameters you can extract are:

Examples

EXP

Usage: EXP([number])

Raise e to the power specified.

Examples:

FILES / LFILES

Usage: FILES <disk number>

List the files that are on disk

Examples:

FIX

Usage: FIX([decimal number])

Convert a decimal number to an integer, and floor it.

Examples:

FPOS

Usage: FPOS([file handle])

Get the current position in a file.

Examples:

110 OPEN "2:data" FOR OUTPUT AS #1
120 PRINT FPOS(1)

FRE

Usage: FRE([memory type])

Get free available memory.

Examples:

GET

Usage: GET [file handle], [variable]

Fetch a line from a file, refreshing any FIELD variables set previously.

Examples:

110 OPEN "2:address" AS #1
120 FIELD #1,30 AS A$,20 AS B$,50 AS C$
130 FOR I=1 TO LOF(1)
140	GET #1, I
150	PRINT "NAME",A$
160	PRINT "TEL",B$
170	PRINT "ADDRESS",C$
180 NEXT I
190 CLOSE:END

GOSUB / RETURN

Usage: GOSUB [line number or label], RETURN <line number>

Jump to a subroutine, or return from one.

RETURNing without GOSUB will throw an error.

Examples:

GOTO

Usage: GOTO [line number]

Jump to a line number of the program.

Examples:

HEX$

Usage: HEX$([decimal value])

Convert a decimal integer to hexadecimal.

Examples:

INKEY$

Usage: INKEY$

Get the currently held down key. Does not block. Returns empty string if no key is being held down.

Examples:

110 PRINT "Enter any key to end"
120 A$=INKEY$
130 IF A$="" THEN 110 ELSE END

INP

Usage: INP [I/O port address]

Read data from an I/O port specified by the address

Examples:

INPUT WAIT

Usage: INPUT WAIT [time span], [prompt]<;variables>

Put up an input prompt, but only wait a certain period of time before continuing.

Time span is in tenths of a second, so e.g. 50 is 5 seconds.

Examples:

INSTR

Usage: INSTR(needle, haystack)

Get the index of a substring inside a string. Returns 0 when not found, otherwise a 1-indexed character index of the start of the string.

Examples:

INT

Usage: INT([decimal number])

Convert a decimal number to an integer, with rounding.

Examples:

INP

Usage: INP([port])

Read data from the Z80 I/O port (0-255) specified by port.

Examples:

KILL

Usage: KILL [filename]

Delete a file from disk.

Examples:

LEN

Usage: LEN([string])

Get the length of a string or string variable.

Examples:

LOAD

Usage: LOAD [filename] <,R>

Load a program from disk.

Examples:

LOC

Usage: LOC [file handle]

Get the current location in an open file.

Examples:

LOCATE

Usage: LOCATE [x] [y] <Enable Cursor?>

Move the text cursor around the screen.

Examples:

LOF

Usage: LOF [file handle]

Get the size of a file.

Examples:

MON

Usage: MON

Enter machine-language monitor mode.

Press CTRL+B to return to BASIC.

NAME

Usage: NAME [old file] AS [new file]

Rename a file on disk.

Examples:

NEW

Usage: NEW

Obliterate the current program and start from scratch.

OUT

Usage: OUT [port], [data]

Write data to the Z80 I/O port (0-255) specified by port.

Examples:

PAINT

Usage: PAINT (Wx, Wy) <area colour> <border colour>

Fill the last shape rendered with the provided colour.

Examples:

110 SCREEN 0,0:CLS 3
120 X=INT(RND*639):Y=INT(RND*199)
130 R=RND*50+1:C=RND*6+1
140 CIRCLE(X,Y),R,C
150 PAINT(X,Y),C
160 GOTO 120

Randomly draws filled circles on the screen.

POS

Usage: POS <expression>

Returns the horizontal position of the cursor.

The value returned is an integer up to the character width of the display.

Useful for word wrapping.

expression has no meaning; normally it is 0.

Examples:

OUT

Usage: OUT [I/O address] [value]

Write a value to an I/O port specified by the address.

ROLL

Usage: ROLL [number of pixels]

Scroll the graphic screen upward by the pixel count.

Examples:

SAVE

Usage: SAVE [filename] <,A|,P>

Save the current program to a file on disk. If you provide the same name as an existing file, the existing file will be overwritten.

Examples:

Usage: SEARCH [array] <, start index> <,step>

Find an item in an array, returning the index of the item found.

Examples:

SGN

Usage SGN [number]

Get the negative/positive sign of a number.

Examples:

SPC

Usage: SPC [number]

Print a certain number of spaces. Useful for aligning screen elements in text mode?

Examples:

VAL

Usage: VAL([string])

Parses a string into a number variable.