The text of a manual · part 6 of 26
Videx BASIC for DuraTrax, LaserLite, LaserLite Pro, and LaserLite Mx Data Collectors, pages 51 to 60
Pages 51 to 60 of 252
The original document is the PDF (765 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Videx DuraTrax, Videx LaserLite, Videx LaserLite Mx and Videx LaserLite Pro
Page 51
I - Send Status Report to Memory Card Processor for Update The status string retrieved by the C, S command may be sent to the memory card processor with the C, I command. The LaserLite Mx operating system and BASIC language automatically update the state of the memory card in its sleep/wake routines. Normally, you will not be concerned with updating the status, except when developing applications that use multiple files. Example Program: Cardcmd C, I, file1$
'Re-open previously opened file and 'restore pointer to specific record Gosub process_cardcmd_error 'Process any errors Result% = Cardstatus(file1$) 'Get status in file1$ Gosub process_card_error 'Process any errors from return
Successful return values: File management report (for C, F); status report (for C, S); 00 (for C, I). Possible error codes that can be returned from this command: 01, 03, 04, 10, 31, 32, 51, 52, 63 (See pages 59–60 for a description of the error codes.)
Chapter 4 Statement & Function Reference
43
Page 52
CARDCMD Statement Commands – continued
D, [modulus] , {file type}, {filename} or
D, {file handle} or
D, {file handle}, {file type}, {new name} Deletes or renames a memory card file. To delete a file, list the file type (indexed (I or H), sequential (S), identification (D), or boot (B)) and filename of the file to delete. The filename can have up to 18 bytes; or you can use the file handle number (if known from a previous O command). To rename a file, you must refer to the file by the file handle number and file type and pass it the new filename. Example 1: Delete an indexed file with filename data.txt: Cardcmd D, I, "data.txt" Example 2: Rename an indexed file with filename data.txt and file handle 03 to olddata.txt: Cardcmd D, 03, I, "olddata.txt" Successful return values: 00
(File deleted or renamed)
Possible error codes that can be returned from this command: 01, 03, 04, 09, 10, 31, 33, 40, 63, 65 (See pages 59–60 for a description of the error codes.)
44
Chapter 4 Statement & Function Reference
Page 53
F, [hash value] , [key field] or
F Searches for a record with the given key field in the memory card’s open file and sends it to the host. This command only functions with file types I and H. When a key field is not provided, and the last command was an H or an F command with a key field, it tries to read the next record with the same key field as was used in the last H command. For example, to read multiple records with the same key field, the following commands can be used. Assuming there are three records with the key field ABCDEFG in an indexed file, then Cardcmd F, "ABCDEFG": reads the first record; Cardcmd F: reads the second record; Cardcmd H: deletes the third record. To read all of the records in an indexed file with the same hash value, the following commands can be used: Cardcmd F, [key field]: first record in the chain; Cardcmd F: second record in the chain. Example: Find a record in the open file: Cardcmd F, "abc" Return: Record found.
"abc" <field2>
<field3>
35
No records match the find request.
Successful return values: A record. Possible error codes that can be returned from this command: 01, 03, 04, 06, 08, 10, 32, 35, 53, 63 (See pages 59–60 for a description of the error codes.)
Chapter 4 Statement & Function Reference
45
Page 54
CARDCMD Statement Commands – continued
H, [hash value] , [key field] Deletes a record with the given key field from the memory card’s open file. This command only functions with file types I and H. For an indexed file, the program goes through the hash table, finds the record, and sets the record status bit to zero. It does not change the pointer or erase the record. When no key field is provided, and the last command is an F or an H command with a key field, it tries to delete the next record with the same key field as in the last H command. Example: Delete a record from the open file: Cardcmd H, "abc" Successful return values: 00
(Record deleted)
Possible error codes that can be returned from this command: 01, 03, 04, 06, 08, 10, 32, 35, 39, 40, 53, 63, 65 (See pages 59– 60 for a description of the error codes.)
46
Chapter 4 Statement & Function Reference
Page 55
K, &1092 Removes deleted files from the memory card. This command copies the file management report from the control blocks to other blocks, changes content, erases the control blocks, and copies the information back to the control blocks. Do not interrupt the processor during the operation (power down or reset) as it is possible that file management information can be lost. This command should only be used after important data is transferred from the memory card to the computer. The &1092 parameter is required and allows the command to remove the deleted files from the memory card. Example: Clean up the card: Cardcmd K, &1092 Successful return values: 00
(Deleted files removed from the memory card)
Possible error codes that can be returned from this command: 01, 03, 04, 10, 40, 61, 62, 63, 65, 67, 68 (See pages 59–60 for a description of the error codes.)
Chapter 4 Statement & Function Reference
47
Page 56
CARDCMD Statement Commands – continued
M, {number of records/bytes}, {F/R} or
M, H, {file handle} or
M Moves the pointer within the memory card’s open file (see the O command on pages 52–53 to open file). For indexed (I or H) files, this command moves the pointer forward (F) or backward (R) a certain number of records within the open file, and sends out the current record that the pointer is pointing to. When number of records = &FFFF, the pointer is moved to the end-of-file (F) or the beginning-of-file (R). For sequential (S) and identification (D) files, the number is in bytes, and the program sends out 256 bytes. When the number of bytes = 0 (or is omitted), the program sends out the current record or 256 bytes, but does not move the pointer. When a file is opened, the move pointer is set at the end-of-file. An F or an H command sets the move pointer at that record. Example 1: Move forward 128K records from current position in open file: Cardcmd M, &020000, F Returns: "abcdefg" <field 2> <field 3> <…> Record found; data reported. 36
48
End-of-file encountered.
Chapter 4 Statement & Function Reference
Page 57
Example 2: Move to beginning of the open file: Cardcmd M, &FFFF, R Returns: "abcdefg data"
Record found, data reported.
23
There is no data in the file.
Example 3: Delete the record at the move pointer: Cardcmd M, H Returns: Record deleted.
00 Successful return values:
A record or 256 bytes of binary data. Possible error codes that can be returned from this command: 01, 03, 04, 10, 23, 36, 37, 39, 40, 53, 63, 65 (See pages 59–60 for a description of the error codes.)
Chapter 4 Statement & Function Reference
49
Page 58
CARDCMD Statement Commands – continued
The Move Pointer The M card command moves a pointer within an open data file. The following table indicates the location of the move pointer under different circumstances. Condition
Location for file types I/H (indexed files)
Location for file types B/D/S (sequential files)
Open a file
Last record.
Last 256 bytes.
Append record
Last record.
Last 256 bytes.
Scrolling
Current record.
Current 256 bytes.
Closed file
Invalid.
Invalid.
Open file with no data
“No data condition” (error 23).
“No data condition” (error 23).
Not applicable. Delete record At the deleted record. Must issue with the H another M command before issuing command or an M, H command. The M command M, H command then moves to the next record in the data file. If there is not a valid next record, then the move pointer moves to the previous record. F command
At the found record or, if not found, at the bottom of the data file.
Not applicable.
S command
At the found record or, if not found, at the bottom of the data file.
Not applicable.
50
Chapter 4 Statement & Function Reference
Page 59
N, [param1] Formats the memory card. N, by itself, closes any open files and restarts the memory card program. It also locks some of the physical functions, so the IRAM, XRAM, and memory card contents cannot be accidentally changed using low-level routines. To return the ID of the memory card, issue the N command without a parameter. The parameter &0129 unlocks low-level physical functions permitting writing directly to the card module’s XRAM memory and formatting the memory card. The parameter &1092 erases the entire card and formats the card, if it is not formatted. Example 1: Format memory card: Cardcmd N, &1092 Returns: 00
Memory card formatted.
Example 2: Determine memory card ID: Cardcmd N Returns: "092612456" The card ID name, card module formatted. Successful return values: ID of the memory card. Possible error codes that can be returned from this command: 01, 03, 04, 07, 10, 22, 63, 65 (See pages 59–60 for a description of the error codes.) Chapter 4 Statement & Function Reference
51
Page 60
CARDCMD Statement Commands – continued
O, [modulus] , {file type}, {filename} or
O, {file handle} Opens an existing or a new file on the memory card. To open an existing file, only the file type (indexed (I or H), sequential (S), identification (D), or boot (B)) and the filename is needed; or you can use the file handle number, if known from a previous O command. The modulus (number of hash table entries) can be zero. The modulus can be omitted for sequential, identification, or boot files; for indexed or hashed files the modulus can be from 1–65535. (Note: See Appendix B for information on the modulus.) The filename can have up to 18 bytes. When a file is opened, any following operations are directed to the open file; any previously opened files are closed. When the module is powered up, the firmware boots the memory card and starts to run the DMS program from the XRAM. If successful, the O command returns the file handle number of the opened file. One memory card ID file can be opened per card. The filename is used as the card ID, and any contents can be written to the file as a sequential file. The ID can be found by writing an ID file to the memory card with any name. It can also be found by issuing an N command (see page 51) without a parameter. Example 1: Open an indexed file with table size 2203 and filename test1.txt: Cardcmd O, 2203, I, "test1.txt" or Cardcmd O, &089B, I, "test1.txt" or Cardcmd O, 03 Returns:
52
&03
File opened successfully and 03 hex is the file handle.
39
Memory full.
Chapter 4 Statement & Function Reference