GW-BASIC for IBM PC compatible and Tandy computers ABS(n) n must be a numeric expression. Example: 100 PRINT ABS(7*(-5))
ASC (char) Returns numeric value of a single character.
ATN(n) n must be a numeric expression Example: 100 PRINT ATN(5)
AUTO Command
BEEP The BEEP Statement is used to create a sound with the internal speaker at 800 Hz (800 cycles per second) for 1/4 of a second. Examples: 100 BEEP 100 IF X>20 THEN BEEP Note: PRINT CHR$(7) has the same effect.
BLOAD filename[,offset] The BLOAD Command is used to load an image file anywhere in user memory. Comments: filename is a valid string expression containing the device and filename. offset is a valid numeric expression within the range of 0 to 65535. This is the offset into the segment, declared by the last DEF SEG statement, where loading is to start. If offset is omitted, the offset specified at BSAVE is assumed; that is, the file is loaded into the same location it was saved from. Example: 100 DEF SEG=&HB800 110 BLOAD "PICTURE", 0
BSAVE Command
CALL Statement
CDBL Function
CHAIN Statement
CHDIR Command
CHR$ (number) CHR$ can be used to convert a number between 0 and 255 into an ASCII character Example: 100 PRINT CHR$(122)
CINT Function
CIRCLE Statement
CLEAR The CLEAR Command is used toset all numeric variables to zero, all string variables to null, and to close all open files.
CLOSE file-device-number The CLOSE command is used for closing currently opened files or drive number. Example: 100 CLOSE 4
CLS Statement To clear the screen. Syntax: CLS [n] Note: n is one of the following values: Value of n Effect 0 Clears the screen of all text and graphics 1 Clears only the graphics viewport 2 Clears only the text window Example: 100 CLS
COLOR Statement To select display colors Syntax: COLOR [foreground][,[background][,border]] Note: Color numbers are dependent on the SCREEN command mode used.
COM(n) Statement
COMMON Statement
CONT Command
COS (radian-expression) Returns trigonometric cosine. Example: 100 X = 2*COS(.4)
CSNG Function
CSRLIN Variable
CVD Function
CVI Function
CVS Function
DATA The DATA command is used to store constant information in the program code, and is used with the BASIC command READ. Example: 100 DATA 156,243,311,22,99,500,111,132,101,909,33,35 110 FOR X=0 TO 11 120 READ A 130 PRINT A 140 NEXT
DATE$ Statement
DEF FN Statement The DEF FN combo commands defines a function with exactly one single numeric argument which can be executed with FN afterwards. Example: 100 DEF FN LOG10(X) = LOG(X)/LOG(10) 110 Y = 10 120 Y = Y * 10 : PRINT FN LOG10(Y); " "; 130 IF Y<1E38 THEN 120
DEFINT Statement
DEFDBL Statement
DEFSNG Statement
DEFSTR Statement
DEF SEG Statement
DEF USR Statement
DELETE Command
DIM The DIM command allocates space in array memory for a new array. Example: 100 DIM T(8,1,5) Example creates a three-dimensional array.
DRAW Statement
EDIT Command
END Stops the execution of code. Example: 100 IF X>200 END
ENVIRON Statement
ENVIRON$ Function EOF Function ERASE Statement ERDEV($) Variables ERL Variable
ERR Variable
ERROR Statement
EXP Function
EXTERR Function
FIELD Statement
FILES Command
FIX Function
FOR The FOR...NEXT loop commands are executed until counter variable equals the value in the TO clause Example: 100 FOR X=1 TO 5 110 PRINT X". OUTPUT OF THIS LINE" 120 NEXT X
FRE Function GET Statement (Files) GET Statement (Graphics) GOSUB-RETURN Statement GOTO Statement HEX$ Function
IF Statement The IF command is used to test a "condition". If the condition produces a non-zero value, the statements after the THEN or GOTO are performed. When the condition is false then the BASIC interpreter will ignore the rest of the BASIC commands in the line. For the condition the following relational operators are useful: = equal <> unequal < less than > greater <= less-equal >= greater-equal Furthermore, logical operators like AND, OR or NOT can be used to combine several conditions, and parentheses () to override precedence order. When the command is GOTO, GOSUB or THEN , the system will perform a branch. The performance of branches gets progressively worse as the program size grows. This can be addressed to some degree by understanding the line-lookup process. Example: 100 IF A$="" OR B$="" THEN 200 In this example, if string A$ OR string B$ is empty, got line 200
INKEY$ Variable INP Function
INPUT Statement INPUT# Statement INPUT$ Function
INSTR Function INT (float-number) INT is used to round numbers, whereas rounding is different from its common mathematical definition. By positive numbers the fractional part will be cut, while by neagtive numbers the next lower integer value is returned. Example: 100 PRINT INT(1.55) The example will display 1
IOCTL Statement IOCTL$ Function
KEY Statement KEY(n) Statement
KILL Command LEFT$ Function LEN Function LET Statement LINE Statement LINE INPUT Statement LINE INPUT# Statement
LIST Command
LLIST Command
LOAD Command
LOC Function LOCATE Statement LOCK Statement LOF Function LOG Function LPOS Function LPRINT Statement LPRINT USING Statement LSET Statement MERGE Command MID$ Function MID$ Statement MKDIR Command MKD$ Function MKI$ Function MKS$ Function NAME Command NEXT Statement NEW Command OCT$ Function
ON COM(n) Statement ON KEY(n) Statement ON PEN Statement ON PLAY(n) Statement ON STRIG(n) Statement ON TIMER(n) Statement ON ERROR GOTO Statement ON-GOSUB Statement ON-GOTO Statement
OPEN Statement OPEN "COM(n) Statement OPTION BASE Statement OUT Statement PAINT Statement PALETTE Statement PALETTE USING Statement PCOPY Command
PEEK Function
PEN Statement and Function
PLAY Statement PLAY(n) Function
PMAP Function
POINT Function
POKE Statement
POS Function
PRESET Statement
PSET Statement
PRINT Statement PRINT USING Statement PRINT# Statement PRINT# USING Statement outputs to the display screen and optionally to an external file or device. ; can be used between numbers and strings Examples: 100 PRINT "HELLO WORLD" 100 PRINT A;" ";B
PUT Statement (Files)
PUT Statement (Graphics)
RANDOMIZE Statement
READ variable The READ command is used to store values into a variable from the DATA command Example: 100 DATA 156,243,311,22,99,500,111,132,101,909,33,35 110 FOR X=0 TO 11 120 READ A 130 PRINT A 140 NEXT
REM Program documentation. Documentation can be entered after the statement without effecting the program. Example: 100 REM THIS LINE DOES NOTHING
RENUM Command RESET Command RESTORE Statement RESUME Statement RETURN Statement RIGHT$ Function RMDIR Command RND Function RSET Statement RUN Command SAVE Command SCREEN Function SCREEN Statement SGN Function SHELL Statement SIN Function
SOUND freq,duration freq is the desired frequency in Hertz (cycles per second). freq is a numeric expression within the range of 37 to 32767. duration is the desired duration in clock ticks. Clock ticks occur 18.2 times per second. duration must be a numeric expression within the range of 0 to 65535. Examples: 100 SOUND 1000, 5 Relationships of Notes and Frequencies Note Frequency Note Frequency C 130.810 C* 523.250 D 146.830 D 587.330 E 164.810 E 659.260 F 174.610 F 698.460 G 196.000 G 783.990 A 220.000 A 880.000 B 246.940 B 987.770 C 261.630 C 1046.500 D 293.660 D 1174.700 E 329.630 E 1318.500 F 349.230 F 1396.900 G 392.000 G 1568.000 A 440.000 A 1760.000 B 493.880 B 1975.500 *Middle C.
SPACE$ Function
SPC Function
SQR (numeric-expression) Returns the square root.
STICK Function To return the x and y coordinates of two joysticks. Stores the x and y values for both joysticks for the following 3 function calls. Syntax: x=STICK(n) Notes: x is a numeric variable for storing the result. n is a valid numeric expression within the range of 0 to 3. Value of n Coordinate Returned 0 x coordinate of joystick A. 1 y coordinate of joystick A. 2 x coordinate of joystick B. 3 y coordinate of joystick B.
STOP Statement STR$ Function STRIG Statement STRIG(n) Statement STRING$ Function SWAP Statement
SYSTEM Command
TAB Function
TAN Function
TIME$ Statement TIMER Function TROFF Command
TRON Command
UNLOCK Statement USR Function VAL Function VARPTR Function VARPTR$ Function VIEW Statement VIEW PRINT Statement
WAIT Statement
WHILE-WEND Statement WIDTH Statement
WINDOW Statement
WRITE Statement WRITE# Statement