Warning: Undefined variable $from in /is/htdocs/wp1075191_C81Z5VPZVZ/www/cbm2/basic4.php on line 13

CBM BASIC V 4.0   
Zurück   Index    FAQ        6 User online       

Warning: Undefined variable $A in /is/htdocs/wp1075191_C81Z5VPZVZ/www/cbm2/basic4.php on line 17

Deprecated: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated in /is/htdocs/wp1075191_C81Z5VPZVZ/www/cbm2/basic4.php on line 17


The BASIC commands. statements and functions below are explained in more detail in the Programmer's Reference Guide for the Commodore 500 and 600/700. This list is designed as a "quick reference" for someone already familiar with the BASIC programming language. For those who are just beginning to learn about BASIC, see Appendix 0 for a list of selftutorial-type books on learning BASIC.
The following conventions are used to describe the BASIC commands, statements, and functions in this appendix:

Keywords appear in uppercase letters. Keywords are the words that your Computer knows. These words cannot be used as part of your filenames or other variable names unless they are surrounded by quo- tation marks (" "). We do not recommend the use of any keywords for variable names. You must enter these keywords exactly as they appear.
Arguments appear in lowercase letters. Another word for argument is parameter. You select those arguments needed for your statement. Arguments indude: variables, expressions, linenumbers, etc.
A vertical bar (|)separates arguments in cases where you ran selert any one of a list of arguments.
Square brackets ([])  are used to show optional arguments. You selert any. or none, of the argu- ments listed, depending on your needs.
Angle brackets  (<>)  mean that you must choose one of the arguments.
An Ellipse, a sequence of three dots  (...) , means that an Option or argument can be repeated more than once, if necessary.
Quotation marks  (" ")  are used to endose char- acter strings, filenames and other items.
Variable means any valid BASIC variable name.
Expression means any valid BASIC expression, such as A+B+2 or .5+X.


The diskette in drive s is duplicated. Here "s" is the number
of your source drive, "d" is the number of your destination 
drive, and "z" is the drive unit number if you have more than 
one disk drive unit.

Displays the names of the files on your diskette.

COLLECT [Ds] [,ON Uy].
The diskette on drive "s" is collected. Here "s" is the drive
number and "y" is the drive unit number.

CONCAT [Ds,] "sourcefile" TO [Dd.]"destfile" [,ON Uz]
Concatenates two data files. Here "s" represents the drive
number of the disk drive containing the "sourcefile", "d" is 
the drive number of the "destfile", and "z" is the drive unit 
number if more than one drive unit is present.

Continues or re-starts the execution of a program which was
interrupted because you hit the STOP key or the program exe-
cuted a STOP statement or an END statement.

COPY [Ds,] "sourcefile" TO [Dd,]"destfile"[,ON Uz]
The file in drive "s" is copied onto the file in drive d of unit z.
Here "s" is the drive number of the file named "source file","d" is
the drive number of the file named "destfile" and "z" is the drive
unit number.

DELETEs [from linenumber]-[to linenumber]
DELETE from memory a group of Iinesfrom the BASIC pro-
gram currently in memory. When using DELETE be aware that:
1. DELETE (erases the entire program)
2. DELETE linenumber- (erases from linenumber to end)
3. DELETE-linenumber- (erases from Start to linenumber)
4. DELETE linenumber- (erases from linenumber to linenumber)

DIRECTORY [Dnumber] [,"filename"] [,ON Uy]
Displays the names of the files on your diskette. Only those files
that match the specified filename are displayed. Here "number" is
the number of the disk drive that contains the diskette.

DLOAD "filename" [,Ddrive-number] [,Uunit]
Loads (bring into memory) a BASIC program that is stored on
a disk. Here "drive-number" is the drive number of the disk and
"unit" is the drive unit number.

DSAVE "filename" [,Ddrive-number] [,Uunit]
Stores a BASIC program on disk. Here "drive-number" is the
drive number of the disk and "unit" is the drive unit number.

HEADER "diskname",Dd [,Ivvl [,ON Uz]
Formats a diskette, assigning it a disk name and identification
number. Here "d" is the disk drive number, "vv" can be any 
alphabetic characters you want to use as identification numbers, 
and "z" is the drive unit number if you have more than one drive unit.

LIST [[from linenumber] [-] [to linenumber]]
Displays one or more lines of the BASIC program currently in
memory. When using LIST be aware that:
1. LIST (lists the entire program)
2. LIST linenumber- (lists all lines from that number to the end)
3. LIST-linenumber (lists all lines up to that number)
4. LIST linenumber-(lists all lines from linenumber  to linenumber)

LOAD ["filename" [,device]]
LOADs (bring into memory) a program that is stored on an 
external device. Here "device" is the deviee number of the storage 
device you are using.

Erases the current BASIC program and data from memory so
that a new program can be loaded or entered.

RENAME [,Ddr] "oldname" TO "newname" [,ON Uz]
Changes the name of a file on a diskette without altering the
file. Here "dr" represents the number of the disk drive in 
which the files are located and "z" represents the drive unit 
number if you have more than one disk drive unit.

RUN [linenumber]
Begins executing the BASIC program currently in memory.
When using RUN be aware that:
1. RUN (starts a program from the beginning)
2. RUN linenumber (starts a program from that linenumber)
NOTE: If the line number does NOT exist you will get an error 

SAVE ["filename"[,device]]
Stores BASIC programs and data on an external storage medium.
Here "device" is the device number of the storage device you are

SCRATCH "filename" [,Dd] [,ON Uz]
Erases a single file from a diskette. Here "d" represents the
disk drive number where the file can be found, "z" represents 
the unit number of the disk drive if you are using more than one
drive unit.

VERIFY ["filename"] [,device]
Checks a program on disk against the program currently in
memory. Here "device" is the device number of the storage 
device you are using. When using VERJFY be aware that:
VERIFY "filename",8  (searches for filename on disk and then checks against memory)


[linenumber APPEND #lf, "filename" [,Dd] [,ON Uzl
Opens a sequential datafile called "filename" and positions
the file pointers beyond the current end of the file. Here "lf" 
represents the logical file number, "d" is the disk drive number 
and "z" is the unit number of the disk drive if more than one unit 
is present.

[linenumber] BANK expression
Sets the indirection bank numberfor use with some BASIC
commands such as PEEK, POKE, BLOAD, and BSAVE. Re-
member that you have 16 BANKs to choose from.

[linenumber] BLOAD [fileopts] [[ON] Bbanknumber] [,Plowoffset]
Loads a binaryfile into any memory beation. Here "fileopts"
is your file options, "banknumber" lets you select one of the 
16 Banks, and "lowoffset" is location in the bank to start 

BSAVE fileopts [][ON] Bbanknumber] [,Plowoffset] [TO Phighoffset]
Saves a binary file from any specified memory location. Here
"fileopts" is your file options, and "banknumber" lets you 
select one of the 16 banks. The "lowoffset" is the location in the 
bank beginning the information to be SAVEd. The "highoffset" is the
location in the bank ending the information to be SAVEd.

[linenumber] CLOSE filenunmber
CLOSEs a file whicn was opened with a previous OPEN
NOTE: The filename must be the same number used in the OPEN 
See your Disk Drive ar Printer manual(s) for more details.

[linenumber] CLR
Clears all BASIC variables in memory. but leave the pro-
gram itself intact. This statement is automatically executed
when a RUN command is given.

[linenumber] CMD filenumber [,printlist]
Redirects output. For example you should use the CMD
statement when you want to send output normaly directed to
the sereen to a file or the printer. Here "printlist" is a 
list of character strings, numeric variables, or expressions 
which is written to the device when the CMD statement is executed.
NOTE: The CMD statement must be used in conjunction wjth a corresponding
OPEN statement ond both the OPEN statement ond the CMD statement must
hove the some filenumber.

DATA [linenumber]
DATA value {,value,..., value]
Uses the DATA statemnent in conjunction with the READ
statement(s) to enter numeric and string constants into a program.

[linenumber] DCLOSE [#lf][,ON Uz]
Closes a singlefile or all the files currently open on a disk unit.
Here ,"lf" represents the logical file number of the file to be 
closed on the disk and "z" is the number of the disk drive unit if more than one unit is present. When using DCLOSE be aware that:
1. DCLOSE        (closes all files currently open on default device)
2. DCLOSE #lf    (closes the file associated with the logical file number "If")
3. DCLOSE ON Uz (doses all files currently open on unit "z")

[linenumber] DEF FNna (argument)=formula
DEF FN allows you to define a complex calculation as a
singlefunction with a short name. In the case of a long formula
that 15 used many times in your program, this statement can
save time and space. Here "na" represents any legal variable
name. When appended to the letters FN, this becomes the func-
tion name. The "(argument)" can be any numeric variable, and it
must be enclosed in parentheses.
NOTE: You must define your funtction witn this DEF FN statement 
betore you can "call" it using the function name.

[linenumber] DIM variable(subscript1[subscriptn]),
Allocates storage for an array and specifies the maximum
values for the array variable subscripts. Here "subscript" repre-
sents the size of the DIMensions of the array you are creating.
NOTE:You must use the DIM statement to DIMension arrays cantaining more
than 10 elements, and "subscripts" must be enclosed in parentheses. 
In addition, you should be aware of the fact that the number of elements 
in one dimension of an array equals the value of the "subscript" plus
1.EXAMPLE:  10 DIM A$(40),B7(15), CC%(4,4,4) 41 elements 16 elements  125 elements

[linenumben] DISPOSE <FOR | GOSUB>
Used in error trap processing to eliminate unwanted NEXT or
RETURN addresses from the stack.

DOPEN #lf, "filename" [,Ly] [,Dd] [,ON Uz] [,W]
Opens a data file for a read and/or write access. Here "lt"
represents the logical filenumber of the file to be opened."y" is
the record length for a nonsequential file, "d" is the disk 
drive number in which the disk containing the file is located, and 
"z" is the drive unit number if more than one drive unit is present.
A sequential file is opened for write access if "W" is not present;
It is opened for read access if "W" is present.

[linenumber] END
Finishes a program that is running and returns control to the

[linenumber] FOR variable=expressionl TO expression2 [STEP
Always associated with a NEXT statement, FOR...
TO. . STEP controls repetitive execution of a group of state-
ments called a loop. Here "variable" is the counter for the 
loop, "expressionl" represents the start value of the counter, "
expression2" is the end value of the counter, and "expression3" 
is the increment value, added to the current value of the counter.
When using FOR.. .TO.. . STEP be aware that:
1)FOR variable=expression 1 TO expression2 (increments a
STEP value of 1)

GET variable
Scans the keyboard buffer and reads a single character from
the buffer. If no character is typed, then a null (empty) 
character is assigned.
NOTE:GET is usually followed by a string variable. Is a 
numeric variable is used and a NONnumeric key is pressed, 
your program will halt  and you will get an error message. 
In addition, the GET statement may be placed in a loop to
check for a null string (" ") result. This loop will continue 
until a key is pressed.

[linenumber] GET# filenumber, variable
Reads a single character from logical file "filename".
NOTE: GET# can only be used with previously OPENed device or file.

[linenumber] GOSUB linenumber2
Always used with the RETURN statement, GOSUB is used to
branch to the subroutine whitch starts with the BASIC state-
ment labeled "linenumber2".
NOTE: GOSUBs without RETURNS will result in a buildup of return 
addresses, eventually causing an out of stack error.

[linenumber] GOTO linenumber2
Uncondititionally branches to the BASIC statement with the
line number "linenumber2".

[linenumber] IF expression GOTO linenumber2
Evaluate the conditions in "expression" and if these 
condittons are met, branch to the statement located at "linenumber2"

[linenumber] If expression THEN then-clause [: ELSE else-
clause] Evaluates the conditions in "expression", then, de-
pending on tile results. performs the action required in the
"then-clause" or the "else-clause".
NOTE:In most cases the ,expression" will involve one or more on 
the following relational operators:
= <  <=  >  >=  <>  AND  OR NOT

[linenumber] INPUT [promptstring ;] variable list
The INPUT statement allows the program to get information
from the person using the program by assigning that data to a
variable. Most of the time, the Information needed by the pro-
gram is in the form of a question. Therefore, after the INPUT
"prompt string" is printed, the program stops and a question
mark (?) 15 PRINTed to the screen. The Computer then waits for
the person using the program to type in a response and hit the
<RETURN>  key. Here the "promptstring" represents theprompt, 
which is usually in the form of a question, and "variable list"
is the list of variable names to associate with the data typed in.

linenumber INPUT# filenumber, variablelist
INPUT# is similar to the INPUT statement, except it takes
data from a previously OPENed file or device. The "filenumber"
represents the number the file has been OPENed. The "vari-
able list" represents the name(s) to assodate with the input 

[linenumber] [LET] variable = expression
The LET keyword is hardly ever used in BASIC programs be-
cause it is an optional keyword. However, the fact that lt is 
understood places it at the heart of all BASIC programs. Here LET
sets "variable" to the value defined by "expression"

[linenumber] NEXT {variable,...,variable]
Always used in conjunction with a FOR statement, NEXT is
used to mark the end of a FOR . . . NEXT loop. When the pro-
gram reaches a NEXT statement, it checks its corresponding
FOR statement to see if the limit of the loop has been reached.
If the limit has not been reached then the loop "variable" in the
FOR statement is increased by the STEP value. If the loop is
finished then execution continues with the statement(s) in the
line following the NEXT statement.
NOTE: NEXT may ar may not be followed bv a "variable" name. If 
no names are  listed, the last loop started is finished. if one 
"variable"  name is given, it must  correspond to an appropriately 
positioned FOR statement. If more thon one "variable" follows a single 
NEXT, each Ioop is finished, in order, from left to right and each 
"variable" must have a corresponding FOR with the same "variable" name. 
See FOR .. TO .. STEP for more information.

ON...GOSUB [linenumber] ON expression GOSUB linenumber list
ON  . GOSUB is similar to an IF. . THEN statement in that
it evaluates the "expression" found after ON and then, based
on the result, moves the program execution to Ihe corresponding
subroutine line numberfollowing the GOSUR. Here "expression 
represents the formula and ,,linenumber list" contains
the list of the line numbers for each subroutine. The appropriate
subroutine will be chosen depending upon the value of "expres-

[linenumber] ON expression GOTO linenumber list
ON   GOTO is similar to an IF. , THEN statemenl !n that
lt evaluates the ,,expression" found after ON and then, based
on the result, moves the program executI'on 10 Ihe correspond-
ing line number following the GOTO. Here ,,expression" repre-
sents the formula and ,,linenumber list" contains the list of 
the line numbers to GOTO. The appropriate statement will be cho-
sen depending upon the value of ,,expression".

[linenumber] OPEN filenumber [,devicenumber [,command [,openstring]]] 
The OPEN statement establishes an Input/Output (I/O) channel
to the screen or an external device, such as a disk drive, a 
printer, or to the IEEE serial bus. Here "filenumber" represents a number
between 0 and 255 that is used to specify in statements like CLOSE,
CMD, GET#, INPUT#, and PRINT# the specific file intended. Only
statements with a corresponding "filenumber" will be able to 
access the file. The label "devicenumber" refers to the appropriate 
external device as mentioned above. You should be aware that:
1. OPEN 1,3           (OPENs the screen as a device)
2. 2OOPEN3,4          (OPENs a channel to the printer)
3. 5OOPEN4,8,15       (OPENs the command channel on the disk)
NOTE:As is indicated, the OPEN statement may be executed in 
both direct and program mode's. Linenumber's are always necesssary in 
program mode. For more information ,see the Programmer's Reference Guide
for your Computer or any of the manual's that come with, your external
device's ,such as disk drive or printer.

[linenumber] POKE location, value
The POKE statement is alwaysfollowed by two numbers or
formulas. Here "location" represents a memory location from 0
through 65535 and "value" is a decimal value from 0 through
255 which 15 placed in "location" replacing any previously 
stored value. A prevlously executed BANK command selects the bank
poked to.

[linenumber) PRINT [printlist]
PRINT writes the information speclfied in "printlist" to the
screen. Here "printlist" can include any of the following:
1. Text which must always be enclosed in quotation marks
2. Variable names
3. Functions
4. Punctuation marks (used for formatting data)
NOTE: For more details ,see your Programmer's Refrerence Guide.

[linenumber] PRINT# filenumber, print list
The PRINT# statement writes the values specified in
"printlist" to the file associated with "filenumber".
NOTE: The "filenumber" used in the PRINT# ,statement must 
refer to the corresponding file number used with a device or 
file that has already been OPENed.

[linenumberj PRINT [#filenumber,] USING formatlist printlist
Allows you to define a "format list" controlling the appear-
ance of the string and numeric output specified in "print list"
See the Programmer's Reference Guide for details.

[linenumber] PUDEF control string
Redefines four symbols which are printed with the PRINT
USING statement's formatting options. See the Programmer's
Reference Guide for details. In this example, "controlstring"
represents the format that you've designed for your data.

[linenumber] READ variablelist
READ processes one or more DATA statements and assigns
the data item values, on a one-to-one basis, to the variables 
in "variable list".
If the data in a DATA statement is not the same type as the
variable in the "variablelist" a syntax error which refers to the
line nurnber of the DATA statement results.

[linenumber] RECORD# if, rno [,bno]
Adjusts a relative file pointer to select any byte (character) of
any record in the relative file. Consult the Programmer's Refer-
ence Guide for more details.

[linenumber] REM [text]
A nonexecuteable statement that is LISTed in your BASIC program.

[linenumber] RESTORE [linenumber2]
Resets the pointer for the current DATA statement to be pro-
cessed by READ statements to linenumber2.

[linenumber] RESUME [NEXT | linenumber2l
Used in error handling to resume execution after an error is
trapped and processed by your error handling routine.

[linenumber] RETURN
Completes subroutine processing and branches back to the
statement following the GOSUB which started the subroutine.

[linenumber] STOP
Terminates program execution and returns to comand level. 

[linenumber] SYS [jumpaddress]
Calls the assembly language subroutine at location "jump-
address" (which is a decimal, not hexadecimal, address) and
executes the machine language program starting at that ad-
NOTE: SYS will only jump into Segment 15 of the computer Random 
Access Memory (RAM) locations. This means that even if you were to 
select ony other Bank or memory segment the program will still ONLY 
jump into Segment 15.
NOTE: All machine language programs must end with an RTS (ReTurn from Subroutine) statement.

TRAP [linenumber] TRAP [linenumber2]
Stops from functioning BASIC's normal error handling and
lets your program peform its own error handling.

[linenumber] WAIT location,, maskl [,mask2] Continually tests the data at "location" and re-executes the
WAIT statement or proceeds to the next executable statement.
depending on the values of selected bits at location.

ABS (expression)
The absolute valne of "expression"

ASC (expression)
The numeric value that represents the ASCII code of the first
character of "expression".

ATN (expression)
The arctangent of the "expression" in radians.

CHR$ (expression)
A string containing a single character whose value is the
character with the ASCII code represented by "expression".

COS (expression)
The cosine of "expression" in radians.

ERR$ (expression)
A character string which contains the text of the error mes-
sage represented by "expression".

EXP (expression)
The value of e (approx. 2.71828183) raised to the power rep-
resented by "expression".

FRE (expression)
The number offree bytes in a memory segment or bank indi-
cated by "expression".

INSTR (expressionl ,expression2[,expression3]) "Expressionl" is searched, beginning at the optional char-
acter position represented by "expression3", for the occurrence
of the string represented by "expression2".

INT (expression)
The largest integer which is less than or equal to the value
specified in "expression".

LEFT$ (expressionl, expression2)
The leftmost "expression2" characters in the string repre-
sented by "expressionl".

LEN (expression)
The number of characters in "expression".

LOG (expression)
The natural logarithm of "expression".

MID$ (expression1,expression2[,expression3])
A string containing "expression3" characters of the string 
"expression1", beginning at the character position "expression2".

PEEK (expression)
The byte readfrom memory location "expression" in the bank
selected by a previously executed BANK instruction.

POS (expression)
The column where the next character will be written on the
line currently contain ing the cursor.
NOTE:"expression" is necessary, but ignored.

RIGHT$ (expression1, expression2)
A string consisting of the rightmost "expression2" characters
in the string "expression1".

RND (expression)
A random number between 0 and 1. "Expression" is used as the
seed value. See the Programmer's Reference Guide for details.

SGN (expression)
A value indicating whether the value of "expression" is posi-
tive (gives +1) negative (gives -1), or zero (gives 0).

SIN (expression)
The sine of "expression" in radians.

SPC (expression)
Prints the number of blank spaces on the screen indicated by
Ihe number in "expression".

SQR (expression)
The square root of "expression".

STR$ (expression)
A character string containing a string representation of the
value represented by "expression".

TAB (expression)
Positions the cursor in the column represented by "expression".

TAN (expression)
The tangent of "expression" in radians.

USR (expression)
Calls the user-written assembly language subroutine which
has starting address stored in locations 3 and 4 of bank 15.
The argument ("expression") is stored in the floating point ac-
cumulator prior to entering the subroutine. See the Program-
mer's Reference Guide for more details.

VAL (expression)
The numeric value of the string "expression".

AND Logical Operator.
DS$ Disk Status reserved word.
EL Line number last error occurred.
ER Error# of last error occurrence.
OR Logical operator.
NOT Logical operator.
STatus The system status for the last Input/Output operation
TI$me The character string representation of the current time-of-day registers.

© 1999-2024 Retro-CMS by M. Sachse http://www.cbmhardware.de