System Specification for C65 | Fred Bowen | March 1, 1991 |
Before arrays of variables can be used, the program must first execute a DIM statement to establish DIMensions of that array (unless there are 11 or fewer elements in the array). The statement DIM is followed by the name of the array, which may be any legal variable name. Then, enclosed in parentheses, put the number (or numeric variable) of elements in each dimension. An array with more than one dimension is called a matrix. Any number of dimensions may be used, but keep-in mind that the whole list of variables being created takes up space in memory, and it is easy to run out of memory if too many are used. To figure the number of variables created with each DIM, multiply the total number of elements in each dimension of the array. Note: each array starts with element 0, and integer arrays take up 2/5ths of the space of floating point arrays.
More than one array can be dimensioned in a DIM statement by separating the arrays by commas. If the program executes a DIM statement for any array more than once, the message 'REDIM'D ARRAY' is reported. It is good programming practice to place DIM statements near the beginning of the program.
10 DIM A$(40),B7(15),CC%(4,4,4) | | | 41 elements 16 elements 125 elements
DIRECTORY ["filespec"] [,R] [,Ddrive] [<ON|,>Udevice]
A directory is a list of-the names of the files that are on a diskette. The directory listing consists of the name of the diskette, the names, sizes, and filetypes of all the files on a diskette, and the remaining free space on the diskette. The filespec is used to specify a pattern whitch string to view selected files. Not all disk drives support tne same options or filespecs; refer to your DOS manual for details. The C64DX allows you to print DIR listings without having to 'load' the directory; see example below.
The commands DIR, DIRECTORY, and CATALOG have the exact same function. They can be used in direct or program mode.
DIRECTORY List all files on the diskette in the default system drive. DIR "*.src", U9 Lists the all the files,ending with ".src" on unit 9. DIR "*,=P",R List all the deleted but recoverable PRG-type files on the system drive. OPEN4,4:CMD4:DIR:CLOSE4 Print DIR listing to printer unit 4.
The following program can be used to load the directory into variables for use within a program. In this case, the filename is simply printed to the screen:
10 OPEN 1,8,0,"$0:*,P,R" open dir as a file 20 : IF DS THEN PRINT DS$: GOTO100 abort if error 30 GET#1,X$,X$ trash load address 40 DO read each line 50 : GET#1,X$,X$: IF ST THEN EXIT trash links, check eof 60 : GET#1,BL$,BH$ get file size 70 : LINE INPUT#l, F$ get filename & type 80 : PRINT LEFT$(F$,18) print filename 90 : LOOP loop until eof 100 CLOSE 1 close dir
This page has been created by Sami Rautiainen. | |
Read the small print. | Last updated April 07, 2006. |