Boing Ball  Amiga Emulator FAQ

AmigaBasic Commands

Updated: 16/01/12

These are the commands found in AmigaBasic which comes on the Extras disk with Workbench 1.3 with an explaination of the commands or functions and an example.

ABS
Format: ABS(numeric-expression)
Purpose: Function to return the absolute (or positive) value of the numeric expression.
Input: Numeric expression
Output: Positive numeric expression
Example: ABS(-8) = 8, ABS(10) = 10

AND
Format: expr1 AND expr2
Purpose: Returns a true value if expr1 is true and expr2 is true.
Input: expr1, expr2 = Boolean expressions
Output: Boolean value (true, false)
Example: IF r>=50 AND r<=100 THEN GOTO 200

AREA
Format: Area [STEP] (x, y)
Purpose: To define the point of an area to be fill.
Options: STEP defines point to be relative to the last point.
Input: x, y are absolute or relative pixel position on the screen
Output: None
Example: Area (20,25), AREAFILL STEP (50, 50)

AREAFILL
Format: AreaFill [mode]
Purpose: To fill a polygon defined by Area statements using a mode.
Input: Mode = 0 (fill using a pattern, defined by Pattern statement) (default),
Mode = 1 (fill by inverting the area).
Output: Filled area
Example: AreaFill 0

ASC
Format: ASC(string-expression)
Purpose: Function to return the ASCII code of the first character in the string experssion.
Input: A string expression
Output: ASCII Code of the first character
Example: ASC("A") = 65

ATN
Format: ATN(numeric-expression)
Purpose: Function to return the arc tangent of the numeric expression, which is in Radians (-PI/2 to PI/2).
Input: Numeric expression (in Radians)
Output: Arc Tangent value
Example: ATN(33) = 1.540503

BEEP
Format: BEEP
Purpose: Command to flash the screen and give a beep sound.
Example: Beep

BREAK
Format: BREAK ON | OFF | STOP
Purpose: Command to enable (On), Disable (Off) or Suspend (Stop) error trapping in programs.
Options: ON = Enable error trapping,
OFF = Disable error trapping,
STOP = Suspend error trapping.
Example: BREAK ON

CALL
Format: CALL name [(argument-list])]
Purpose: To call a Subprogram or a machine language routine at a fixed address. If the word CALL is omitted,
then the parenthesis can also be omitted. Arguements to a machine language routine can only by short or long integers.
Input: Optional list of arguements to pass to the subprogram or machine code routine.
Example: CALL MYSUB(A,N,X), CALL MachineSub&(a, b), CALL Draw#(a, b)

CBDL
Format: CBDL(numeric-expression)
Purpose: Function to convert value to double-precision. (In AmigaBasic, double-precision variables are post-fixed with an
exclamation mark).
Output: Double-precision value
Example: CBDL(6666! * 100000!) = 66660000

CHAIN
Format: CHAIN [MERGE] filename [,line-number] [,ALL[ ,DELETE range]]]
Purpose: To load or merge and execute another program file into memory.
Options: MERGE = Merge the new program with the existing program into memory.
Line-number = This will specify where the program will start execution from.
ALL = All global variable are available to the called program.
DELETE = Remove a range of lines from the calling program.
Example: CHAIN MERGE "myprogram2"

CHDIR
Format: CHDIR "directory"
Purpose: To change the current directory.
Input: A string with the new drive and/or directory name.
Example: CHDIR "DH1:Work", CHDIR "DF1:"

CHR$
Format: CHR$(numeric-expression)
Purpose: Function to return the character string of the ASCII code equivalent in the numeric expression.
Input: An ASCII Code (0-255)
Output: A single character string
Example: CHR$(48) = "0"

CINT
Format: CINT(numeric-expression)
Purpose: Function to convert the numeric-expression to an integer to nearest frational portion.
Input: A numeric expression
Output: An integer value
Example: CINT(-5.4) = 5

CIRCLE
Format: CIRCLE [STEP] (x, y) ,radius [,colour-id [,start, end [,aspect]]]
Purpose: Command to draw a circle from co-ords x,y of a given radius in pixels.
Options: STEP = Use relative co-ordinates.
Input: x,y = Co-ordinates in screen in pixels,
radius = The Width of one-half of the circle in pixels,
colour-id = The colour of the cirle (id = 0 to 3, see Pattern command),
start, end = The start and end of the circle in Radians (-2*PI to 2*PI),
aspect = The ratio between width and height (default is .44 for a 2.25:1 aspect).
Output: A Circle or ellipses.
Example: CIRCLE (50,50), 40, 1

CLEAR
Format: CLEAR [,basicData] [,stack]
Purpose: Clears all variables, closes files and allocates memory for basic Data area and the stack.
Input: basicData = Amount of memory for text, variable, string and file data (1024 bytes or more),
stack = Amount of memory for system stack (1024 bytes or more).
Example: CLEAR ,,4096

CLNG
Format: CLNG(numeric-expression)
Purpose: Functio to convert number to a long-integer format.
Input: Numeric expression
Output: Long integer value
Example: CLNG(1000) = 1000, CLNG(156.7) = 157

CLOSE
Format: Close [[#]filenumber [,[#] filenumber ...]]
Purpose: To close a file and if its an output file, writes out the rest of the file buffer.
Input: File number (1 to 255)
Example: CLOSE 1,2,3

CLS
Format: CLS
Purpose: To clear the screen and set pen position to the top left corner.
Example: CLS

COLLISION
Format:
a) COLLISION(object-id)
b) COLLISION ON | OFF | STOP
Purpose:
a) Function to return the object-id of another object that has collided with this object. If the object-id is 0, then
it will return the object id of another object (it does not remove the object from the collision queue (upto 16),
if the object id is -1, then it will return the id of the window. If the result is negative then it return the border value:
-1 = Top border, -2 = Left border, -3 = Bottom border and -4 = Right border.
b) This statement will either enable (on), disable (off) or suspend (stop) Collision event trapping. See the ON
COLLISION GOSUB command.
Options: ON = enable collision trapping, OFF = disable collision trapping, STOP = suspend collision trapping
Input: object-id = -1, 0 or number of object
Output: Windows id, border or object id.
Examples: hit = COLLISION(1), COLLISION ON

COLOR
Format: COLOR [foreground-color] [, background-color]
Purpose: To set the foreground colour for draing points, lines, area fill and text, and to set the background colour for
the area surrounding drawn objects.
Input: Foreground color = Foreground colour specified by Palette statement (0-3).
Background color = Background colour specified by Palette statement (0-3).
Example COLOR 1,3

COMMON
Format: COMMON variable-list
Purpose: To pass variables to a chained program. The Common statement can be specified anywhere in a program.
To make all variables common, use the ALL option with the CHAIN command instead.
Input: List of variable names, arrays are specified with empty parenthesis.
Example: COMMON EmpNo, Name, Figures()

CONT
Format: CONT
Purpose: Statement to continue execution of a program after either a STOP statement or a Break (Amiga + period (.)).
Example: CONT

COS
Format: COS(numeric-expression)
Purpose: Function to return the cosine of the numeric expression.
Input: Value in radians
Output: Cosine value
Example: COS(100) = 0.8623189

CSNG
Format: CSNG(numeric-expression)
Purpose: To covert numeric expression to a single precision number.
Input: Number
Output: Single precision number
Example: CSNG(6666 * 100000) = 6.66E+08

CSRLIN
Format: CSRLIN
Purpose: Function to return the line number of the pen or cursor.
Output: Line number of the cursor (>=1)
Example: y=CSRLIN

CVD
Format: CVD(8-byte string)
Purpose: Converts a numeric 8-byte string to a double-precision number.
Input: An eight byte string containing digits.
Output: a double-precision number.
Example CVD("87340921") = 87,340,921

CVI
Format: CVI(2-byte string)
Purpose: Converts a numeric 2-byte string to a short integer.
Input: A two byte string containing digits.
Output: A short integer
Example CVI("56") = 56

CVL
Format: CVL(4-byte string)
Purpose: Converts a numeric 4-byte string to a long integer.
Input: A four byte string containing digits.
Output: A long integer
Example CVI("2743") = 2743

CVS
Format: CVS(4-byte string)
Purpose: Converts a numeric 4-byte string to a single-precision number.
Input: A four byte string containing digits.
Output: A single-precision number
Example CVS("9073") = 9073.0

DATA
Format: DATA constant-list
Purpose: To store numeric and string values for the READ statement.
Input: Numeric or string values seperated by commas.
Example: DATA "David", 15, "15 Village Square", "Reading"

DATE$
Format: DATE$
Purpose: Function to return the current date.
Output: Return date in format mm-dd-yyyy (US Format).
Example: Today$ = DATE$ = 12-31-2011

DECLARE FUNCTION
Format: Declare Function function-name ([parameters]) LIBRARY
Purpose: Statement to cause Basic to search all opened Libraies for the machine language function.
Input:
function-name = Id of the library function to search for. May end with the declaration characters (%, &, ! or #).
parameters = List of parameters required by the function (optional).
Example: DECLARE FUNCTION ViewPortAddress&() LIBRARY

DEF FN
Format: DEF FN name[(parameter-list)] = function-definition
Purpose: Defines a user-specified function called 'name' with optional parameter list using the result from the function definition.
DEF defined before a chained program do not apply to the new program.
Input:
name = Name of the function.
parameter-list = List of required parameters for the function.
function-definition = Expression to be evaluated for the function.
Output: Numeric or string result.
Example: DEF FNMAX(A, B) = (ABS(A>B)*A) + (ABS(B>=A)*B)

DEFDBL
Format: DEFDBL letter-range
Purpose: Defines variables starting with the letter range are treated as double-precision variables.
Variables ending with hash (#) character are always treated as double-precision variables.
Input: Range of letters
Example: DEFDBL H-K

DEFINT
Format: DEFINT letter-range
Purpose: Defines variables starting with the letter range are treated as short integer variables.
Variables ending with percent (%) character are always treated as short integer variables.
Input: Range of letters
Example: DEFINT A-G

DEFLNG
Format: DEFLNG letter-range
Purpose: Defines variables starting with the letter range are treated as long integer variables.
Variables ending with ampersand (&) character are always treated as long integer variables.
Input: Range of letters
Example: DEFLNG T-V,Z

DEFSNG
Format: DEFSNG letter-range
Purpose: Defines variables starting with the letter range are treated as single-precision variables.
Variables ending with exclamation (!) character are always treated as single-precision variables. It is also the default variable format.
Input: Range of letters
Example: DEFSNG L,M,N

DEFSTR
Format: DEFDBL letter-range
Purpose: Defines variables starting with the letter range are treated as string variables.
Variables ending with dollar ($) character are always treated as string variables.
Input: Range of letters
Example: DEFDBL P,Q,R,W,X

DELETE
Format: DELETE [line] [-line]
Purpose: Delete one or a range of program lines.
Input: Line numbers or labels.
Example: DELETE 100-200

DIM
Format: DIM [SHARED] variable-list
Purpose: Dimensions or defines the maxmimum value for array subscipts and allocate storage.
Input: variable-list = List of array names and max subscript value(s) in parenthesis.
Options: SHARED = Make variables available to the main program and any sub-programs.
Example: DIM Names(100), Ages(100)

END
Format: END
Purpose: To end or terminate a program and closes any files. It is an optional statement in a program, if a program reaches the last line in a program, it will automatically end.
Example: END

EOF
Format: EOF(file-number)
Purpose: Function to test for the End of the File for the given file number.
Input: file-number = Number of the file Opened (1-255)
Output: -1 (True) if the end of file is reached, else a 0 (false).
Example: WHILE (EOF(1)=-1) ... WEND

EQV
Format: expr1 EQV expr2
Purpose: Returns the equivalence of the two values. If expr1 and expr2 are both the same, then the result is true, if they are different then the result is false.
Input: expr1, expr2 = Boolean expressions (True, False)
Output: Boolean value
Example: IF x<10 EQV y<100 GOTO 900

ERASE
Format: ERASE array-list
Purpose: To remove arrays from memory. Arrays can be redimensioned after they are erased.
Input: List of array variable names
Example: ERASE NamesArray

ERL
Format: ERL
Purpose: Function to return the line number of where the error occured. It may be used with the ON ERROR statement.
Example: PRINT "Error on line ";ERL

ERR
Format: ERR
Purpose: Function to return the error number of the last error that occured. It may be used with the ON ERROR statement.
Example: PRINT "Error number ";ERR

ERROR
Format: ERROR integer-expression
Purpose: To simuate the occurance of an error. It can be used in a program or on the command line.
Input: Error number (1-255). See Appendix A in AmigaBasic manual for what they mean.
Example: ERROR 53 = File not found

EXP
Format: EXP(numeric-expression)
Purpose: Function to return to the base (e) of the natural logarithm i.e. e^X (where X is the number given). If X is > 88 for Single-Precision numbers or 709 for double precision numbers then an Overflow error is given. Logarithms are used for half-life, decay constant, exponential decay and compound interest maths.
Input: Numeric expression
Output: Base of natural logarithm (X value)
Example: EXP(1) = 2.718282

FIELD
Format: FIELD [#] file-number, field-width AS string-variable,...
Purpose: Statement to allocate space for variables in a random file buffer. Ideally FIELD should be used after an OPEN statement.
Input:
File-number = Id number of the file (1-255)
Field-width = Number of characters for the string.
String-variable = Name of string for this field.
Example: FIELD #1, 25 AS Name$

FILES
Format: FILES [string]
Purpose: Statement to list all the files in a directory, or if a file exists or on a drive.
Input:
String = Directory: List of files in that directory, File: Lists file if it exists, Drive: Lists files on the drive.
Example: FILES "df0:"

FIX
Format: FIX(numeric-expression)
Purpose: Function to return the truncated integer part of the numeric-expression. It does no rounding unlike INT function.
Input: Numeric expression
Output: Truncated integer value
Example: FIX(32.15) = 32

FOR...NEXT
Format: FOR variable = start TO end [STEP inc]
NEXT variable [, variable...]
Purpose: Statement to preform one or more instructions for a given number of times.
Input:
variable = Name of variable to store the counter
start = Initial value of the counter
end = Final value of the counter
inc = Amount to increase (or decrease) the counter. Default is 1.
Example:
FOR N=1 to 20 STEP 2
PRINT N, N*10
NEXT N

FRE
Format: FRE(numeric-expression)
Purpose: Function to return the amount of free memory for system, stack or data segment.
Input: numeric expression which can be -1 (free system memory), -2 (free stack space) or other for free memory in Amiga Basic's data segment.
Output: Amount of free memory.
Example: FREE(-1) = 180,000

GET
Format:
a) GET [#] file-number [, record-number]
b) GET (x1,y1)-(x2,y2), array-name [(index[, index...])]
Purpose:
a) Statement to read a record from a random disk file. Use the FIELDed variables to retreive the data.
b) Statement to read an area of the screen and save the bitmap to an array. See PUT.
Input:
a) file-number = Id of the file to read from (1-255)
record-number = Id of the record to read from the file (1- 16m).
b) x1,y1 = Top left corner of the area of the screen.
x2,y2 = Bottom right corner of the area of the screen.
array-name = A numeric array to store the bitmap area.
index = Max number of elements required to store the bitmap.
Example:
a) GET #2, 10
b) GET (10,20)-(30,40), ARRAY%

GOSUB
Format: GOSUB line-number
Purpose: To call a subroutine at the given line-number. Subroutines always end with a RETURN statement.
Input: Line-number = start of subroutine
Example: GOSUB 1000

GOTO
Format: GOTO line-number
Purpose: To branch to the given line-number.
Input: Line-number =line of the instruction to jump to.
Example: GOTO 1000

HEX$
Format: HEX$(number)
Purpose: Function to convert the decimal value to a hexadecimal value.
Input: Number = Number to convert
Output: Hexadecimal value (0-9, A-F)
Example: HEX$(20) = 14

IF
Format:
IF expression GOTO line [ELSE else-clause]
IF expression THEN then-clause [ELSE else-clause]
IF expression THEN
statement(s)
ELSEIF expression THEN
statement(s)
ELSE
statement(s)
END IF
Purpose: Determines which statements to execute depending the the result of the expression which is either true or false. The first format, will branch to a specific line if the expression is true otherwise it will execute the else-clause or go to the next line (if no ELSE statement is provided).
The second and third else statements are similar, other than the third format allows for more statements to be included between the IF, THEN and
ELSE statements.
Input: Expression to be evaluated to a true or false value.
Example: IF age>50 THEN Insurance=60

IMP
Format: expr1 IMP expr2
Purpose: Returns the implication of the two expressions. Returns true except if expr1 is true and expr2 is false.
Input: expr1, expr2 = Boolean expressions (True, False)
Output: Boolean value
Example: IF x<10 IMP y<100 GOTO 900

INKEY$
Format: INKEY$
Purpose: Function to return a a character of the key entered from the keyboard.
Output: A string containing the key pressed.
Example: Ans$ = INKEY$: IF Ans$="Y" THEN GOTO 9999

INPUT
Format: INPUT [;][prompt-string;] variable-list
Purpose: To wait for input from the keyboard and store the result(s) in to one or more variables. If more than one variable is specified, then the input must be seperated by variables. A comma after the prompt string will suppress the question mark prompt.
Input: prompt-string = String to tell user what to type in, variable-list = Variables to store the data.
Example: INPUT "Age "; age

INPUT$
Format: INPUT$(length [, [#]file-number])
Purpose: Reads a number of characters (length) from a file using given file number or from the keyboard.
Input: Length = Number of characters to read from the file.
File-number = Optional file id of the file (1-255)
Output: String of characters.
Example: INPUT$(25, #1)

INPUT #
Format: INPUT #file-number, variable-list
Purpose: Reads data from a file and stores it in one or more variables.
Input: File-number = File id of the file to read from.
variable-list = List of numeric or string values to store the read data.
Example: INPUT #1, Name$,Age, Address$, PostCode$

INSTR
Format: INSTR([start,] full-string, search-string)
Purpose: Function to return the poistion of the search-string within the full-string, optionally starting from position 'start'.
Input: Start = Character position to start searching from.
Full-string = The string to be searched.
Search-string = The string to search for.
Output = Position of the search-string within the full-string

INT
Format: INT(numeric-expression)
Purpose: Function to return the largest integer less or equal to the given numeric expression.
Input: Numeric expression
Output: Integer part of the number rounded to value larger or equal to the given value.
Example: INT(3.4) = 3, INT(47.9) = 47, INT(-56.2) = -57

KILL
Format: KILL file-name
Purpose: To delete a file from disk. An open file will given an error.
Input: File name of the file to delete.
Example: KILL "OldDocument.doc"

LBOUND
Format: LBOUND (array-name[,dimension])
Purpose: Function to returns the lower bound (or lowest index value) of an array or a specific dimension of the array.
The OPTION BASE will determine whether the lowest index is 0 or 1.
Input: Array-name = Name of the array to find lower bound of.
Dimension = Which dimension of a multi-dimensional array to find the lower bound. Default is 1.
Output: Value of the lower bound
Example: FOR n=LBOUND(sales) TO UBOUND(sales)

LEFT$
Format: LEFT$(string, num-characters)
Purpose: Function to return the left most num-characters of the string.
Input: String = String to be looked at.
Num-characters = Number of characters to extract from the string.
Example: LEFT$("2011/01/03",4) = "2011"

LEN
Format: LEN(string)
Purpose: Function to return the number of characters or length of a string.
Input: String = String of characters to count
Output: Number of characters in the string.
Example: LEN("Hello World") = 11

LET
Format: [LET] variable = expression
Purpose: To assign the value of the expression on the right hand side to the variable on the left side of the equals sign.
Input: Expression = A string or numeric expression to be evaluated.
Variable: A string or numeric variable which will store the result of the expression
Example: LET v = 15 ^ 5 - 1

LIBRARY
Format:
a) LIBRARY "filename"
b) LIBRARY CLOSE
Purpose: To open a Amiga library of functions and subprograms provided by AmigaOS. These functions can be CALLed later in the program.
Libraries require a .bmap file for AmigaBasic to use it. Using CLOSE will close an open library.
Use the ConvertFd.bas program to create .bmap files from .FD files for use with AmigaOS (FD files are provided on the Extras disk)
Input: Filename = Name of the library to open, with the .library afterwards.
Example: OPEN "intuition.library"

LINE
Format: LINE [[STEP] (x1,y1)] - [STEP] (x2,y2), [colour-id][,b[f]]
Purpose: To draw a line or a box on the current window.
Input: x1,y1 = Starting points of the line
x2,y2 = Ending points of the line.
Colour-id = Colour id to be used for the line (0-3). See Palette.
b = A box is drawn in the forground
bf = A filled box is drawn using the colour id given
Options: STEP = Use relative co-ordinates, to the last point referenced. By defaul absolute points are used.

LINE INPUT
Format: LINE INPUT [;] ["prompt-string";] string-variable
Purpose: To read an entire line from the keyboard and the result into the string variable. A semi-colon after the command will not produce a carriage return on the screen.
Input: prompt-string = Some informative text to be shown on the screen.
string-variable = Result from the keyboard will be stored in the string-variable.
Example: LINE INPUT "Address, City, Postcode: "; Address$

LINE INPUT#
Format: LINE INPUT #file-number; string-variable
Purpose: To read an entire line from a file and the result into the string variable.
Input: file-number = File Id of the file to be read from (1-255)
string-variable = The line from the file will be stored in the string-variable.
Example: LINE INPUT #1; Address$

LIST
Format:
a) LIST [line]
b) LIST [line][-[line]], "filename"
Purpose: Lists the current program to a list window, a file or a device such as a printer e.g. PRT:
Input: Line = One line or a range of program lines to list.
filename = Name of the file or a device the list the program to.
Example: LIST 50-150

LLIST
Format: LLIST [line][-[line]]
Purpose: Lists the current program to printer i.e. PRT:
Input: Line = One line or a range of program lines to list.
Example: LLIST 10-200

LOAD
Format: LOAD ["filename" [,R]]
Input: filename = Name of the file to be loaded into AmigaBaisc.
Options: R = Autorun the program when the file is loaded.
Example: LOAD "Game",R

LOC
Format: LOC(file-number)
Purpose: Function to return the record number of the last record read or written from a random access file. For a sequential file, LOC returns the increment, which is the number of bytes read or written from the file divided by the the number of bytes in the default record size (128) or the size in the OPEN statement.
Input: File id (1-255)
Output: Record number or number of bytes.
Example: LOF(2)

LOCATE
Format: LOCATE [line] [,column]
Purpose: Changes the position of the pen to the specified line and column in the current window.
Input: line = Line or row number of the window,
Column = Column number of the window.
Example: LOCATE 10,15

LOF
Format: LOF(file-number)
Purpose: To return the length of a file in bytes. Other devices will always given 0 bytes.
Input: File id (1-255)
Output: Length of file in bytes
Example: document$=INPUT$(LOF(1), 1)

LOG
Format: LOG(numeric-expression)
Purpose: Function to return the natural logarithm of the numeric expressions (e ^ number).
Input: A non-zero value
Output: Natural logarithm
Example: LOG(1.6) = 0.4700037

LPOS
Format: LPOS(numeric-expression)
Purpose: Function to return the current position of the printer's print head within the line buffer.
Input: Dummy arguement
Output: Position of the print head (e.g. 1-80, 1-130)
Example: LPOS(0)

LPRINT
Format:
a) LPRINT [expression-list]
b) LPRINT USING format-string; expression-list
Purpose: To print results of the expression list to the printer.
Input: Expression-list = List of numeric and/or string expressions to print,
format-string = Specify string with formatting features to determine the layout of strings and numbers.
Example: LPRINT USING "$####.##"; transaction (print value of transaction with a dollar sign, 4 digit positions and two point positions).

LSET
Format: LSET string-variable = string-expression
Purpose: Left justifies the string-expression and places it in a random file buffer (See FIELDS). Number fields should be converted to strings using MKI$, MKL$, MKS$ or MKD$.
Input: String-expression = A string to be assigned which will be either truncated or padded with spaces,
string-variable = Random file buffer to be used.
Example: LSET value$ = MKL$(transvalue)

MENU
Format:
a) MENU menu-id, item-id, state [,title-string]
b) MENU RESET
c) MENU(n)
d) MENU ON | OFF | STOP
Purpose:
a) Statement to create a menu or a menu item in a menu.
b) Statement to reset the menus back to the AmigaBasic defaults.
c) Function to return the Menu id (n=0) or Item id (n-1) of a selected menu or item.
d) Statement to enable (ON) or disable (OFF) menus. STOP will suspend menu event trapping.
Input:
menu-id = Id of the full menu (1 to 10).
item-id = Id of the item on a menu (0 to 19).
state = To disable a menu, menu item (0), to enable a menu or item (1) or to enable an item and place a check mark (2).
title-string = Name given to the menu or menu item.
n = menu id or item id (0 or 1)
Example: MENU 1, 0, 1, "Open"

MERGE
Format: MERGE "filename"
Purpose: To append lines from from program file to the program in memory. The merged program must have been saved in ASCII format using the A option with the SAVE command.
Input: filename = Name of file to merge in.
Example: MERGE "Extrafunctions"

MID$
Format:
a) MID$(string1, pos [,len]) = string2
b) MID$(string1, pos [,len])
Purpose:
a) Replaces a portion of string from position 'pos' of optional length 'len' with string 2.
b) Function returns a substring of the given string, from position 'pos' of 'len' characters.
Input:
a) String1. The string of characters to be replaced or substringed.
b) pos = Position of first character.
c) Len = Length of charcters to be replaced or substringed.
Output: b) A substring of the given string
Example: MID$("07.01.2012",4,2) = "01"

MKI$
Format: MKI$(short-integer)
Purpose: Converts a short integer to a two byte string for insertion into a random access file.
Input: A short integer
Output: Two character string
Example MKI$(125)

MKL$
Format: MKL$(long-integer)
Purpose: Converts a long integer to a four byte string for insertion into a random access file.
Input: A long integer
Output: Four character string
Example MKL$(125000)

MKS$
Format: MKS$(single-precision-expr)
Purpose: Converts a single precision value to a four byte string for insertion into a random access file.
Input: A single precision expression
Output: Four character string
Example MKS$(1256.789)

MKD$
Format: MKD$(double-precision-expr)
Purpose: Converts a double precision value to a eight byte string for insertion into a random access file.
Input: A double precision expression
Output: Eight character string
Example MKS$(1205600.712)

MOD
Format: expr1 MOD expr2
Purpose: Returns the modulo or remainder of a division.
Input: expr1, expr2 = numeric expressions.
Output: The remainder from the division of the expr1 / expr2, as an integer.
Exameple: 63 MOD 4 = 3

MOUSE
Format:
a) MOUSE(n)
b) MOUSE ON | OFF | STOP
Purpose:
a) Function to return information about the left mouse button and location of mouse pointer.
MOUSE(0) = Status of mouse button (0 = not down, 1 = clicked once, 2 = clicked twice, -1 = button held down, -2 = button held down after clicking twice).
MOUSE(1) = Current horizontal poisiton, MOUSE(2) = Current vertical position, MOUSE(3) = Starting horizontal position,
MOUSE(4) = Starting vertical position, MOUSE(5) = Ending horiz. position, MOUSE(6) = Ending vert. position.
b) Enables (ON), Disables (OFF), or Suspends (STOP) mouse event trapping.
Input: n = Number of the type of mouse information required (0-6)
Output: Mouse button status or position.
Example: PRINT "Mouse position is ("; MOUSE(2); ", "; MOUSE(3);")."

NAME
Format: NAME "old-filename" AS "new-filename"
Purpose: Renames a file to a new name.
Input: old-filename = Name of an existing file,
new-filename = The name to change the file to.
Example: NAME "Landscape.jpg" AS "Countryside.jpg"

NEW
Format: NEW
Purpose: To remove the program from memory, clear all variables and clear the List window.
Example: NEW

NEXT
Format: NEXT [variable [,variable ...]]
Purpose: To start the next interaction of a FOR loop.
Input: variable = The name of the variable specified in the FOR loop. Multiple variable names can be used for nested FOR loops.
Example: NEXT count

NOT
Format: NOT expression
Purpose: To return the opposite value of the boolean expression. If the expression is True, then Not will return False and vice versa.
Input: A boolean expression
Output: An opposite boolean value
Example: IF NOT (Age<50) GOTO 150

OBJECT.AX
Format: OBJECT.AX object-id, value
Purpose: Statement to specify the acceleration of an object (sprite or bob) in the horizontal direction.
Input: Object-id = Number of the object to change (1 to n)
value = Acceleration value in pixels/sec.
Example: OBJECT.AX 5, 5

OBJECT.AY
Format: OBJECT.AY object-id, value
Purpose: Statement to specify the acceleration of an object (sprite or bob) in the vertical direction.
Input: Object-id = Number of the object to change (1 to n)
value = Acceleration value in pixels/sec.
Example: OBJECT.AY 5, 20

OBJECT.CLIP
Format: OBJECT.CLIP (x1,y1)-(x2,y2)
Purpose: Statement to define the area of screen (clipping area) that objects are allowed to be drawn in.
Input: x1,y1 = Top left point of the area; x2,y2 = Bottom right point of the area.
Example: OBJECT.CLIP (0,0)-(512,256)

OBJECT.CLOSE
Format: OBJECT.CLOSE [object-id [,object-id ...]]
Purpose: Removes one or more objects from the screen and memory.
Input: Object-id = Number of the object to change (1 to n)
Example: OBJECT.CLOSE 1,2,3,4

OBJECT.HIT
Format: OBJECT.HIT object-id [,MeMask][,HitMask]
Purpose: Determines what the collision objects are for object-id. By default all ojbects collide with each other and the border.
Input: Object-id = Number of the object to change (1 to n),
MeMask = 16 bit mask that describes the object-id. If least sig bit is set, the object collides with the border. If MeMask is AND'd with the HitMask of another object and produce a non-zero result, then a collision event occurs.
HitMask = Bits of other objects and border added together.
Example: OBJECT.HIT 1,8,7 (object id 1 can collide with border (1), ship (id 2) and missle (id 3) (bits 1+2+4 = 7)

OBJECT.OFF
Format: OBJECT.OFF [object-id [,object-id ...]]
Purpose: Statement makes one or more objects invisible and also stops the object from moving.
Input: Object-id = Number of the object to change (1 to n).
Example: OBJECT.OFF 3,4,7

OBJECT.ON
Format: OBJECT.ON [object-id [,object-id ...]]
Purpose: Statement makes one or more objects visible and may re-start an object to move.
Input: Object-id = Number of the object to change (1 to n).
Example: OBJECT.ON 3,4,7

OBJECT.PLANES
Format: OBJECT.PLANES object-id [,plane-pick][, plane-on-off]
Purpose: Statement to set the objects Plane Pick and Plane on/off masks.
Input: Object-id = Number of the object to change (1 to n),
Plane-pick = Mask to select ILBM planes to show (0-255),
Plane-on-off = Mask to select which ILBM planes to show (0-255).
Example: OBJECT.PLANES 1, 80,80

OBJECT.PRIORITY
Format: OBJECT.PRIORITY object-id, priority
Purpose: Sets the priority of an object, so that objects with higher priority are shown in-front of other lower priority objects.
Objects with the same priority and drawn in random order.
Input: Object-id = Number of the object to change (1 to n),
Priority = Number from -32767 to 32767.
Example: OBJECT.PRIORITY 4,-40

OBJECT.SHAPE
Format:
a) OBJECT.SHAPE object-id, definition-string
b) OBJECT.SHAPE object-id, object-id2
Purpose: Creates or copies an object. An object can be a Bob (Blitter Object) or VSprite (Virtual Sprite) by using a definition string or a definition from an existing object.
Input: Object-id = Object number to be defined (0-n). 'n' is limited by memory.
definition-string = A string that describes the size, shape and colour of an object. See the Object Editor tool to create definitions.
Object-id2 = Object-id of an existing object to be copied to another object.
Example:
OPEN "mainchar" FOR INPUT AS 1
OBJECT.SHAPE 1, INPUT$(LOF(1),1)
CLOSE 1

OBJECT.START
Format: OBJECT.START [object-id [,object-id ...]]
Purpose: Statement to set one or more objects in motion Motion is defined by OBJECT.VX and VY statements.
Input: object-id = Object number to be changed (0-n).
Example: OBJECT.START 1,4,5,6

OBJECT.STOP
Format: OBJECT.STOP [object-id [,object-id ...]]
Purpose: Statement to stop one or more objects being in motion
Input: object-id = Object number to be changed (0-n).
Example: OBJECT.STOP 1,4,5,6

OBJECT.VX
Format:
a) OBJECT.VX object-id , velocity
b) OBJECT.VX(object-id)
Purpose:
a) Statement to set the object's horizontal velocity for motion
b) Function to return the object's current velocity.
Input: object-id = Object number to be changed (0-n).
velocity = Amount of velocity in pixels/sec.
Output: Current x velocity
Example: OBJECT.VX 1,10

OBJECT.VY
Format:
a) OBJECT.VY object-id , velocity
b) OBJECT.VY(object-id)
Purpose:
a) Statement to set the object's vertical velocity for motion
b) Function to return the object's current velocity
Input: object-id = Object number to be changed (0-n).
velocity = Amount of velocity in pixels/sec.
Output: Current y velocity
Example: OBJECT.VY 1,5

OBJECT.X
Format:
a) OBJECT.X object-id , x-position
b) OBJECT.X(object-id)
Purpose:
a) Statement to set the object's horizontal (x) position
b) Function to return the object's current x position.
Input: object-id = Object number to be changed (0-n).
x-position = Object's x position
Output: Current x position
Example: OBJECT.X 1,150

OBJECT.Y
Format:
a) OBJECT.Y object-id , y-position
b) OBJECT.Y(object-id)
Purpose:
a) Statement to set the object's vertical (y) position
b) Function to return the object's current y position.
Input: object-id = Object number to be changed (0-n).
x-position = Object's y position
Output: Current y position
Example: OBJECT.Y 1,50

OCT$
Format: OCT$(numeric-expression)
Purpose: Returns the octal representation of the integer value of the numeric expression.
Input: Numeric-expression (integer part used only)
Output: Octal string
Example: OCT$(25) = "31"

ON BREAK
Format: ON BREAK GOSUB label | 0
Purpose: To tell AmigaBasic to call the routine if the user press CTRL+C or selects Stop from the Run menu.
Input: label = Line number or label name of the start of the routine. A zero (0) will stop On Break event captures.
Example: ON BREAK GOSUB 800

ON COLLISION
Format: ON COLLISION GOSUB label | 0
Purpose: To tell AmigaBasic to call the routine if an object (sprite) collides with another object or the border
Input: label = Line number or label name of the start of the routine. A zero (0) will stop On Collision event captures.
Example: ON COLLISION GOSUB 400

ON ERROR
Format: ON ERROR GOTO label | 0
Purpose: To tell AmigaBasic to call the routine if the program encounters an error in the program.
Input: label = Line number or label name of the start of the routine. A zero (0) will stop On Error event captures.
Example: ON ERROR GOTO 700

ON GOSUB
Format: ON expression GOSUB line-list
Purpose: To tell AmigaBasic to call a routine from the list of line numbers depending on the value of the expression. If the expression
is 1 then the first line number is selected, 2 then the second line number etc. A RETURN statement in the routine will return to line following ON GOSUB.
Input: expression = A numeric expression (rounded to nearest integer) to determine which line to Gosub to,
line-list = List of line numbers or labels to gosub to.
Example: ON selection GOSUB 450, 500, 560, 620, 690, 810

ON GOTO
Format: ON expression GOTO line-list
Purpose: To tell AmigaBasic to jump to a routine from the list of line numbers depending on the value of the expression. If the expression is 1 then the first line number is selected, 2 then the second line number etc.
Input: expression = A numeric expression (rounded to nearest integer) to determine which line to jump to,
line-list = List of line numbers or labels to jump to.
Example: ON selection GOTO 620, 660, 700, 750, 820

ON MENU
Format: ON MENU GOSUB label | 0
Purpose: To tell AmigaBasic to call the routine if the user selects a menu item (MENU(0) is non-zero).
Input: label = Line number or label name of the start of the routine. A zero (0) will stop On Menu event captures.
Example: ON MENU GOSUB 550

ON MOUSE
Format: ON MOUSE GOSUB label | 0
Purpose: To tell AmigaBasic to call the routine if the user clicks the left mouse button.
Input: label = Line number or label name of the start of the routine. A zero (0) will stop On Mouse event captures.
Example: ON MOUSE GOSUB 650

ON TIMER
Format:
a) ON TIMER(time-elapse) GOSUB label
b) ON TIMER GOSUB 0
Purpose: To tell AmigaBasic to call the routine if the amount of time has elapsed after a certain number of seconds.
Input: label = Line number or label name of the start of the routine. A zero (0) will stop On Menu event captures,
time-elapse = Number of seconds to elapse before Timer event is called (1 - 86,400 secs).
Example: ON TIMER(20) GOSUB 1000

OPEN
Format:
a) OPEN mode, [#]file-number, filespec[,file-buffer-size]
b) OPEN filespec [FOR mode] AS [#]file-number [LEN=file-buffer-size]
Purpose: To open a file for read or write using a given filename and open mode.
Input:
Mode. For syntax (a), it is either O for output, I for input, R form random read/write, or A for append.
For syntax (b), it is either OUTPUT, INPUT or APPEND (Random by default).
File-number = A file id of the file (1 to 255)
File-spac = Path and filename of the file to read or write to.
File-buffer-size = The size of of the buffer of upto 32767 bytes, can be the size of the record length for random files.
Example: OPEN "addresses" FOR INPUT AS 1

OPTION BASE
Format: OPTION BASE 0 | 1
Purpose: Specifies the minimal value for array subscripts.
Input: Minimum script value (0 or 1). Default is 0.
Example: OPTION BASE 1

OR
Format: expr1 OR expr2
Purpose: Returns a true value if expr1 is true or expr2 is true or both are true.
Input: expr1, expr2 = Boolean expressions
Output: Boolean value (true, false)
Example: IF n<1 OR n>10 THEN GOTO 200

PAINT
Format: PAINT [STEP] (x,y) [,paintColour-id] [,borderColour-id]
Purpose: To paint an enclosed area with a specified colour and set the colour of the edges.
Input:
x,y = Any point within the area to be painted,
paintColour-id = The id of the colour to be used to paint the area (see Palette),
borderColour-id = The id of the colour for the edges of the area (see Palette).
Options: STEP = A relative location since the last referenced co-ordinates.
Example: PAINT STEP (+5, +5), 3, 0

PALETTE
Format: PALETTE colour-id, red, green, blue
Purpose: To define a colour using the red, green an blue components.
Input: Colour-id = The id of the colour to be defined (0-31). The default system colour ids are 0-3,
Red = The amount of red colour to be used (0.0 to 1.0),
Green= The amount of green colour to be used (0.0 to 1.0),
Blue= The amount of blue colour to be used (0.0 to 1.0).
Example: PALETTE 6, 1.00, 0.73, 0.00 (Orange)

PATTERN
Format: PATTERN [line-pattern] [, area-pattern]
Purpose: To defines the texture of text, lines and polygon interiors.
Input: line-pattern = A 16 bit integer that defines the mask for drawing lines,
area-pattern = An integer area consisting of 16-bit values of N-bits high (N is a power of 2 value).
Example: PATTERN &H8080, AREA%

PEEK
Format: PEEK(address)
Purpose: To return a one byte integer of the value at a given memory location.
Input: address = Memory address (0-16,777,215)
Output: An integer value (0-255)
Example: PEEK(500000)

PEEKL
Format: PEEKL(address)
Purpose: To return a long integer of the value at a given memory location.
Input: address = Memory address (0-16,777,215)
Output: A 32-bit value
Example: PEEK(600000)

PEEKW
Format: PEEKW(address)
Purpose: To return a short integer of the value at a given memory location.
Input: address = Memory address (0-16,777,215)
Output: A 16-bit value.
Example: PEEKW(400000)

POINT
Format: POINT (x,y)
Purpose: Function to return the colour-id of a point in the current window.
Input: x,y = Pixel co-ordinates in the current window.
Output: Colour-id of the point else -1.
Example: POINT(50,60)

POKE
Format: POKE address, value
Purpose: To write a value to a memory address.
Input: Address = Memory address (0-16,777,215)
value = A 8 bit byte value (0-255)
Example: POKE 670123, 55

POKEL
Format: POKEL address, value
Purpose: To write a long integer value to a memory address.
Input: Address = Memory address (0-16,777,215)
value = A 32 bit byte value (-2^32 - 2^32)
Example: POKEL 670123, 550671

POKEW
Format: POKEW address, value
Purpose: To write a short integer value to a memory address.
Input: Address = Memory address (0-16,777,215)
value = A 16 bit byte value (-2^32 - 2^32)
Example: POKEW 670123, 65535

POS
Format: POS(x)
Purpose: Returns the column of the pen in the current window.
Input: x = Dummy value, usually 0.
Output: Position of pen (1-n)
Example: PRINT "Column is ";POS(0)

PRESET
Format: PRESET [STEP] (x,y) [,colour-id]
Purpose: Sets a specified point in the window. If the colour-id is omitted, then the background colour is used.
Input: x,y = Point in window to be set,
colour-id = Colour to be used for the point.
Options: STEP = use relative co-ordinates.
Example: PRESET STEP (15, 8), 3

PRINT
Format:
a) PRINT expression-list
b) ? expression-list
c) PRINT #file-number, expression-list
Purpose: Statement to display information in the current window. Expressions are seperated by semi-colons or commans.
Numbers are always followed by a space, negative numbers are proceeded with a minus sign. A question mark can replace the word PRINT.
Input: expression-list = a list of one or more number or string expressions seperated by semi-colons or commas.
File-number = File id of file to write to (1-255)
Example: PRINT "Average is "; avg; " units/month."

PRINT USING
Format:
a) PRINT USING format-string; expression-list
b) PRINT #file-number, USING format-string; expression-list
Purpose: Statement to print numbers or strings in a specific format using the format-string.
Input: Format-string = Combinations of special characters to format strings or numbers.
String formatting: ! = print first char, \nspaces\ = 2 + n chars to print from string, & = for variable length strings.
Number formatting: # = No. of digits posittions, . (dot) = insert decimal point, + = Add + or - sign, - = add a trailing minus sign, ** = Fill leading spaces with stars, $$ = Add dollar sign to left of number, **$ = Insert leading stars and a dollar sign, , (comma) = Insert commas, ^^^^ = exponential format, _ = Literal character follows.
Expression-list = String or numeric expressions to print.
File-number = File id of file to write to (1-255)
Example: PRINT USING "$##,###.##"; amount

PSET
Format: PSET [STEP] (x,y) [,colour-id]
Purpose: Sets a specified point in the window.
Input: x,y = Point in window to be set,
colour-id = Colour to be used for the point.
Options: STEP = use relative co-ordinates.
Example: PSET STEP (15, 8), 3

PTAB
Format: PTAB(pixel-position)
Purpose: Moves the print position to a given pixel position.
Input: pixel-position = Pixel position (0-32767)
Example: PTAB(256)

PUT
Format:
a) PUT [#] file-number [,record-number]
b) PUT [STEP] (x,y), array [(index[,index...])] [,action-verb]
Purpose:
a) To write a record to a random file buffer to a random access file.
b) To draw a graphics image to a specific point. Image is grabbed by a GET command.
Input:
a) File-number = The file id of file to write to, record-number = Record number to write to file (1-16777215).
b) x,y = Pixel co-ordinates to put to image, array = Name of array containing the image,
index = Index of object in the array to Put (can be used to rapidly change images),
action-verb = Interaction between the image and the one on the screen. It can be PSET, PRESET,AND,OR, XOR.
Options: STEP = Use relative co-ordinates
Example: PUT #4, 500; PUT (50,60), image(1)

RANDOMIZE
Format: RANDOMIZE [expression] [TIMER]
Purpose: Statement to re-seed the random number generator for AmigaBASIC using value from expression or the current TIMER value.
Input: expression = Number to seed the generator (if no value given, then a prompt for a value is given),
Options: TIMER = Use timer source for seeding the generator
Example: RANDOMIZE TIMER

READ
Format: READ variable-list
Purpose: Read values from DATA statements and assign them to numeric or string variables:
Input: variable-list = List of numeric or string variables
Example: DATA 34, 56, "London"; READ A, B, C$

REM
Format: REM remark
Purpose: To allow explanatory remarks or comments to be inserted into a program to document what the program does.
Input: Remark = Some text
Example: REM Function to input data from file.

RESTORE
Format: RESTORE [line]
Purpose: To restore the point from where DATA statements either from the first DATA statement or a DATA statement on a particular program line or label.
Input: Line = Line number or label of a DATA statement.
Example: RESTORE 700

RESUME
Format: RESUME [ 0 | NEXT | line ]
Purpose: To continue or resume execution of a program from a error handling routing.
Input: No option or 0 (zero) will resume at the line that caused the error, NEXT will resume from the statement after the error, line = resume from a given line number or label.
Example: RESUME NEXT

RETURN
Format: RETURN [line]
Purpose: To return or exit from a subprogram and continue program execution after the GOSUB statement.
Input: line = Optional line number or label for a optional GOTO to a different line other than the one following GOSUB.
Example: RETURN 250

RIGHT$
Format: RIGHT$(string-expr, chars)
Purpose: Function to return the 'chars' number of characters from the right hand side of a string.
Input: String-expr = String to take substring from,
chars = number of characters to fetch from string.
Output: A substring of characters.
Example: RIGHT$("River Calder", 6) = "Calder"

RND
Format: RND[(x)]
Purpose: Function to return a random number between 0 and 1. It will produce the same random numbers unless a RANDOMIZE statement is run first.
Input: If x < 0 then it restarts the same sequence for any given value of x. If x>0 then it will generate the next random number in the sequence; if x = 0 then it repeats the last number generated.
Output: Random number between 0 and 1.
Example: result = INT(RND*50+1) = generate random number between 1 and 50.

RSET
Format: RSET string-variable = string-expression
Pupose: Sets a string variable (defined by FIELD statement) with value from string expression and right justify it.
Input: string-variable = Variable to be set in random file buffer,
string-expression = A string to be evaluated to be stored.
Example: RESET amount$ = STR$(value)

RUN
Format:
a) RUN [line]
b) RUN filename [,R]
Purpose: To execute a program currently loaded into memory. It will usually start at the first line in the program but you can optionally start at a specific line. If filename is used it will run that program using same name as it was saved as.
Input: line = line number or label to start execution from,
filename = programs, file name to load and run.
Options: R = all data files are remained open (Run usually closes files and clears memory first).
Example: RUN 200

SADD
Format: SADD (string-expression)
Purpose: Function to return the address of the first byte in the string expression.
Input:string-expression = A string variable or expression.
Output: Memory address of the string.
Example: SADD ("My program title")

SAVE
Format: SAVE [filename [,A | P | B]
Purpose: To save a program in memory to disk using given filename (ends with .BAS normally).
Input: filename = Name of file to save program to.
Options: A = Save in ASCII format (useful for MERGE), P = Protect file by using encoded binary format whcih allows program to run but not be listed or edited, B = Save in compressed format.
Example: SAVE "MyGame.bas",P

SAY
Format: SAY "string" [,mode-array]
Purpose: To speak the string using Amiga's translator routines.
Input: String = Words to speak, may contain phoneme codes (syllables and words). See TRANSLATE$ function,
mode-array = An array of 9 elements to define the characteristics of the voice. 0 = pitch (65-320), 1 = inflection (0,1), 2 = rate (40-400),
3 = Gender (0,1), 4 = tuning (5000-28000), 5 = volume (0-64), 6 = channel (0-3), 7 = mode (0,1), 8 = control (0-2).
Example: SAY "I am a computer."

SCREEN
Format:
a) SCREEN screen-id, width, height, depth, mode
b) SCREEN CLOSE screen-id
Purpose:
a) Statement to create a new screen of a specific size and depth.
b) To close an existing screen.
Input: screen-id = The id of a screen (1-4), width = Width of the screen in pixels (1-640), height = Height of the screen (1-400),
Depth = Number of bit planes (1-5) (2-32 colours), mode = low or high resolution and/or interlaced (1-4).
Example: SCREEN 1, 320,200,4,1

SCROLL
Format: SCROLL (x1,y1)-(x2,y2), delta-x, delta-y
Purpose: Scrolls a portion of the screen (rectangle shape), by number of pixels to the right or left (delta-x) or to scroll down or up (delta-y).
Input: x1,y1 = Point at the top left of the rectangular area,
x2,y2 = Point at the bottom right of the rectangular area,
delta-x = Number of pixels to scroll to the right (+x) or to the left (-x),
delta-y = Number of pixels to scroll down (+y) or up (-y).
Example: SCROLL (10,10)-(250, 250), 6, 0

SGN
Format: SGN(numeric-expression)
Purpose: To return the sign of the numeric expression.
Input: numeric-expression = A number to evaluate.
Output: Returns 1 if the number is position, 0 if the number is 0, or -1 is the number is negative.
Example: SGN(-156) = -1

SHARED
Format: SHARED variable-list
Purpose: To share variables within a subprogram to variables of the same name in the main program.
Input: variable-list = List of variables to share with the main program.
Example: SHARED names, amount, count

SIN
Format: SIN(numeric-expression)
Purpose: To return the sine of a number.
Input: numeric-expression = Value in radians.
Output: Sine value
Example SIN(100) = -0.5063657

SLEEP
Format: SLEEP
Purpose: Statement to temporarily suspend execution until an evert occurs. Event can be a mouse click, key press, object collision, menu
event or timer event.
Example: SLEEP

SOUND
Format:
a) SOUND frequency, duration, [, [volume] [,voice]]
b) SOUND WAIT | RESUME
Purpose: To create a sound from the speaker(s) or build a queue of sounds and play sounds from the queue.
Input: Frequency = Integer or single/double precision number (20 - 15000),
duration = Length of the sound (0-77) (1 sec = 18.2),
volume = Loudness of the sound (0-255),
voice = Audio channels (0-3).
Options: WAIT = Causes call following sounds to be queued, to allow synchronisation of sounds from the 4 channels,
RESUME = Causes all sounds that have been queued to be played.
Example: SOUND 523.25, 36.2, 35, 0

SPACE$
Format: SPACE$(length)
Purpose: Function to return a string of space characters of a given length.
Input: length = Number of space characters to produce (0-32767).
Output: String containing a number of space characters.
Example: PRINT SPACE$(10); name$

SPC
Format: SPC(length)
Purpose: Function to print a number of space characters in a [L]PRINT statement.
Input: length = Number of space characters to produce (0-32767).
Output: Prints a number of space characters.
Example: PRINT SPC(8); name$

SQR
Format: SQR(numeric-expression)
Purpose: Function to return the square root of a number.
Input: Numeric-expression = Number to evaluation (single or double precision).
Output: Square root of the number
Example: PRINT "Square root of 49 is "; SQR(49)

STICK
Format: STICK(n)
Purpose: To return the direction of the joystick (A = port 1; B = port 2).
Input: n = 0 or 1 for Joystick A in X or Y directorion, n =2 or 3 for Joystick B in X or Y direction.
Output: 1 = Movement is up or right, 0 = no direction, -1 = Movement down or left.
Example: PlayX = PlayX + Stick(0): PlayY = PlayY + Stick(1)

STOP
Format: STOP
Purpose: To stop a program execuring and return to immediate mode. A program can be resumed using CONT command.
Example: PRINT "Error found.": STOP

STRIG
Format: STRIG(n)
Purpose: Function to return the status of a joystick, in particular the fire button.
Input: n = 0 = Joystick A button pressed, 1 = Joystick A button is currently pressed, 2 = Joystick A button pressed, 3 = Joystick A button is currently pressed,
Output: Returns 1 if button on Joystick A is pressed, -1 if button on Joystick B is pressed or 0 if no button pressed.
Example: button = STRIG(0)

STR$
Format: STR$(numeric-expression)
Purpose: Function to return the string representation of a number. Adds a space for positive numbers or a minus sign for negative numbers.
Use MK$, MKS$ or MKD$ for converting numbers for random file operations.
Input: Numeric-expression = Number to be converted.
Output: String representation of the number.
Example: STR$(132.56) = "132.56"

STRING$
Format:
a) STRING$(len, ascii)
b) STRING$(len, string)
Purpose:
a) Returns a string of characters represented by the ascii code of a given length.
b) Returns a string of characters using the first character of the string of a given length.
Input:
len = Number of characters to return.
ascii = The ASCII code of the character to repeat.
string = A string to use for repeating. Only first character is used.
Output: A repeated string of a given character.
Example: STRING$(10, "Monday") = "MMMMMMMMMM"

SUB
Format: SUB subprogram-name [(parameter-list)] STATIC
Purpose: Defines a user defined subprogram.
Input: subprogram-name = name of the subprogram of upto 30 characters long,
parameter-list = List of simple variables and array variables. Array indexes should contain the number of dimensions e.g. 1 for single dim arrays, 2 for 2 dim arrays etc. STATIC specifies that all variables on the subprogram keep their values from one call to the next. Use an END SUB or EXIT SUB to finish a subprogram.
Example:
SUB PrintRoutine(score)
LOCATE 1,70
PRINT "SCORE ";score
END SUB

SWAP
Format: SWAP, variable1, variable2
Purpose: To swap the values between two variables. The types of the variables must be the same.
Input: variable1, variable2 = Names of variables to swap values.
Example: IF B$<A$ THEN SWAP A$, B$

SYSTEM
Format: SYSTEM
Purpose: To close all files, clear memory and exit AmigaBasic back to Workbench.
Example: SYSTEM

TAB
Format: TAB(n)
Purpose: Function to tabulate to n characters in a [L]PRINT statement.
Input: length = Number of tabular postion (0-155).
Example: PRINT TAB(8); name$

TAN
Format: TAN(numeric-expression)
Purpose: Function to calculate the tangent of the expression, which is in radians.
Input: Numeric-expression = Number to evaluate (in radians)
Output: Tangent value
Example: TAB(1.777) = -4.780646

TIME$
Format: TIME$
Purpose: Returns the current time in a string.
Output: Time in the format hh:mm:ss, as a string.
Example: PRINT "Start time "; TIME$

TIMER
Format: TIMER ON | OFF | STOP
Purpose: To enable (on), disable (off) or suspend (stop) time event trapping.
Options: ON = Enable timer events, OFF = Disable timer events, STOP = Suspend timer events.
Example: TIMER OFF

TRANSLATE$
Format: TRANSLATE$("sentence")
Purpose: To translate the text sentence into phonemes for use by the SAY command to speak out.
Input: Sentence = A string containing the words to be converted.
Output: A String containing words converted into phonemes.
Example: SAY(TRANSLATE$("Please enter your name?"))

TROFF
Format: TROFF
Purpose: Statement to disable Tracing (debugging) of program statements when it is executing.
Example: TROFF

TRON
Format: TRON
Purpose: Statement to enable Tracing (debugging) of program statements when it is executing. When it is enabled the current executed then the current executed program list is highlighted in the List window. Use extra PRINT statements in the program to view variable contents.
Example: TRON

UBOUND
Format: UBOUND(array-name [,dimension])
Purpose: Function to return the highest index value of a specific dimension in an array.
Input: array-name = Name of the array variable to examine,
dimension = Number of the dimension to examine.
Output: Largest index in the array.
Example: FOR N=1 TO UBOUND(names)

UCASE$
Format: UCASE$(string-expression)
Purpose: Function to convert all the letters in the string to upper case.
Input: String-expression = string to be converted.
Output: String with all the letters in upper case.
Example: UCASE("Green") = "GREEN"

VAL
Format: VAL(string-expression)
Purpose: Returns the numeric value of the string. Use CVI, CVL, CVS or CVD for strings for random access files.
Input: string-expression = String to be evaluated.
Output: Returns the numeric value of a string. Any leading blanks, tabs and linefeeds are removed.
Example: VAL(" -109") = -109

VARPTR
Format: VARPTR(variable)
Purpose: Function to return the memory address of the variable. It is usefull to get address of an array of machine code instructions and pass the address for the CALL function and for addresses to variables for system functions. For Strings use SADD.
Input: Name of any variable.
Output: Memory address of the data for the variable.
Example:
MyCode = VARPTR(code%())
CALL MyCode(param1, param2)

WAVE
Format: WAVE voice, wave-definition
Purpose: Statement to define a sound wave for a given audio channel.
Input: voice = Audio channel (0-3)
wave-definition = Defines change sound wave for voice. This can be an array of 256 integers with values in the range -128 to 127 or the word SIN.
Example: WAVE 0, wavearray

WEND
Format: WEND
Purpose: States the end of a WHILE loop.
Example: WEND

WHILE
Format: WHILE expression
Purpose: Defines the start of a while loop and executes the statement between WHILE and WEND while the expression is true.
Input: expression = boolean expression (True or false)
Example: WHILE count < 100

WIDTH
Format: WIDTH [LPRINT | output-device | #filenumber ] [,][size] [,print-zone]
Purpose: Defines the printed line width and print zone width of a device.
Input: output-device = A device name e.g. SCRN:, COM1:, LPT1.
#filenumber = ID for a file (1-255),
size = number of characters for the device. 255 = infinite width.
print-zone = number of characters for print-zone.
Options: LPRINT = Set width for printer instead of using LPT1:
Example: WIDTH LPRINT 80

WINDOW
Format:
a) WINDOW window-id [,[title] [,[(x1,y1)-(x2,y2)][,[type][,screen-id]]]]
b) WINDOW CLOSE | OUTPUT window-id
c) WINDOW(n)
Purpose:
a) To create a new output window.
b) To close a window or set it the current output window.
c) Function to return information about a window.
Input:
a) Window-id = the id number of a window (1-n)
title = String which is display in the title bar,
x1,y1 = Defines top left position of the window,
x2,y2 = Defines the bottom right position of the window,
type = Defines windows features. 1 = Add sizing gadget, 2 = Drag bar, 4 = Windows moved back to front etc, 8 = Close gadget, 16 = Auto refresh of window if uncovered from under another window.
screen-id = Id number of the screen to display window on.
b) Window-id = the id number of a window (1-n).
c) n = 0 = Window-id of selected window, 1 = window id of current window, 2 = width, 3 = height, 4 = x co-ord of next character
postion, 5 = y co-ord of next character position, 6 = max legal colour, 7 = pointer to Intuition window, 8 = pointer to Rastport record.
Output (c): Some information about a window depending on parameter n.
Example: WINDOW 1, "My Program", (10,10)-(200,100), 32

WRITE
Format: WRITE [#filenumber,] [expression-list]
Purpose: To output data to the screen or to a sequential file.
Input: filenumber = Id of the file to write to,
expression-list = List of numeric or string expressions to write.
Example: WRITE #2, Results