manual:chapter4:card

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:chapter4:card [2017/06/03 13:27]
smartin [File operations]
manual:chapter4:card [2017/06/05 19:28] (current)
smartin [SD card operations]
Line 3: Line 3:
 Over 30 commands dedicated to working with secure digital (SD) offline storage are available.  Both SD and SDHC cards are supported.  The SD card can have up to 4 partitions, denoted C:, E:, F:, G: on a PC; and '':3:'', '':4:'', '':5:'', and '':6:'' on the 50g.  Paths and filenames (case-sensitive) are specified in the following ways on the 50g (for the first partition, '':3:''): Over 30 commands dedicated to working with secure digital (SD) offline storage are available.  Both SD and SDHC cards are supported.  The SD card can have up to 4 partitions, denoted C:, E:, F:, G: on a PC; and '':3:'', '':4:'', '':5:'', and '':6:'' on the 50g.  Paths and filenames (case-sensitive) are specified in the following ways on the 50g (for the first partition, '':3:''):
  
-As a string: ''":3:/Path/to/Filename"''+As a string (including the partition number): ''":3:Path/to/Filename"'' 
 + 
 +As a string (default partition): ''"Path/to/Filename"''
  
 As a list: ''{'Path' 'to' 'Filename'}'' As a list: ''{'Path' 'to' 'Filename'}''
Line 19: Line 21:
 ''42.5'' ''42.5''
  
-''":3:/Test/Spnum"''+''"Test/Spnum"''
  
 ''SDSTO'' ''SDSTO''
Line 25: Line 27:
 and to recall this same file contents to the stack, and to recall this same file contents to the stack,
  
-''":3:/Test/Spnum"''+''"Test/Spnum"''
  
 ''SDRCL'' ''SDRCL''
Line 31: Line 33:
 (Note that the forward slash symbol, /, has the shortcut **AL-RS-DIV** or **AL-RS-Z**). (Note that the forward slash symbol, /, has the shortcut **AL-RS-DIV** or **AL-RS-Z**).
  
-Alternatively, if a sub directory is already set (see Directory operations below using ''SDCHDIR''), then the above example of storing 42.5 to the file Spnum can be done like this: ''42.5 'Spnum' SDSTO'' (and similarly for ''SDRCL'').+Alternatively, if a sub directory is already set (see Directory operations below using ''SDCHDIR''), then the above example of storing 42.5 to the file Spnum can be done like this: ''42.5 'Spnum' SDSTO'' (and similarly for ''SDRCL'').  Note that single quotes or double quotes may be used, the latter giving more flexibility to filenames than the former which would just be a variable name.  To specify a partition (the first one, or current partition, is used by default), preface the object name with the partition number, e.g., ''":4:Test/Spnum"''.
  
 ===Handling of RPL code=== ===Handling of RPL code===
Line 40: Line 42:
  
   - Copy the program file (as a text file, delimited only by the program chevrons «») to the SD card,   - Copy the program file (as a text file, delimited only by the program chevrons «») to the SD card,
-  - With the SD card back in the 50g, open the file: ''":3:filename" SDOPENRD'', returned to the stack is the file handle (#xh), ''EN'' (to duplicate the file handle),+  - With the SD card back in the 50g, open the file: ''"filename" SDOPENRD'', returned to the stack is the file handle (#xh), ''EN'' (to duplicate the file handle),
   - Determine the characters (or bytes) to read: ''SDFILESIZE''   - Determine the characters (or bytes) to read: ''SDFILESIZE''
   - ''SWAP''   - ''SWAP''
Line 50: Line 52:
  
   - Put program on stack as string (''→STR''),   - Put program on stack as string (''→STR''),
-  - Open an empty text file on the SD card for writing (at this time, there isn't a command to create an empty text file): ''":3:newfile:" SDOPENWR'', a file handle is returned to the stack,+  - Open an empty text file on the SD card for writing: ''"newfile" SDOPENWR'', a file handle is returned to the stack,
   - ''SDWRITETEXT''   - ''SDWRITETEXT''
   - ''#xh SDCLOSE'', where #xh is the file handle from step 2.   - ''#xh SDCLOSE'', where #xh is the file handle from step 2.
Line 60: Line 62:
  
 ^ Command ^ Purpose ^ Example ^ ^ Command ^ Purpose ^ Example ^
-| ''SDCRDIR'' | Create a new directory | ''":3:/Newdir1" SDCRDIR''+| ''SDCRDIR'' | Create a new directory | ''"Newdir1" SDCRDIR''
-| ''SDCHDIR'' | Change to directory | ''":3:/Newdir1" SDCHDIR'' |+| ''SDCHDIR'' | Change to directory | ''"Newdir1" SDCHDIR'' |
 | ''SDPATH'' | Current directory path | ''SDPATH'' | | ''SDPATH'' | Current directory path | ''SDPATH'' |
 | ''SDUPDIR'' | Back up one directory level | ''SDUPDIR'' | | ''SDUPDIR'' | Back up one directory level | ''SDUPDIR'' |
-| ''SDPGDIR'' | Delete a directory (must be empty) | ''":3:/Newdir1" SDPGDIR'' |+| ''SDPGDIR'' | Delete a directory (must be empty) | ''"Newdir1" SDPGDIR'' |
 | ''SDSETPART'' | Set the active partition (0-3) | ''3 SDSETPART'' | | ''SDSETPART'' | Set the active partition (0-3) | ''3 SDSETPART'' |
  
Line 74: Line 76:
 | ''SDRCL'' | Recall an object (file) | '''Spnum' SDRCL'' | | ''SDRCL'' | Recall an object (file) | '''Spnum' SDRCL'' |
 | ''SDPURGE'' | Delete a file | '''Spnum' SDPURGE'' | | ''SDPURGE'' | Delete a file | '''Spnum' SDPURGE'' |
-| ''SDCOPY'' | Copy a file | ''":3:/Test/sourcefile" ":3:/Test/destfile" SDCOPY''+| ''SDCOPY'' | Copy a file | ''"Test/sourcefile" "Test/destfile" SDCOPY''
-| ''SDMOVE'' | Move a file | ''":3:/Test/sourcefile" ":3:/Test/destfile" SDMOVE''+| ''SDMOVE'' | Move a file | ''"Test/sourcefile" "Test/destfile" SDMOVE''
-| ''SDOPENRD'' | Open a file for read | ''":3:/Test/file" SDOPENRD'', returns file handle (#xh) | +| ''SDOPENRD'' | Open a file for read | ''"Test/file" SDOPENRD'', returns file handle (#xh) | 
-| ''SDOPENWR'' | Open a file for write | ''":3:/Test/file" SDOPENWR'', returns file handle (#xh) |+| ''SDOPENWR'' | Open a file for write (create new file if it doesn't exist) | ''"Test/file" SDOPENWR'', returns file handle (#xh) |
 | ''SDOPENMOD'' | Open a file for byte modification |  | | ''SDOPENMOD'' | Open a file for byte modification |  |
 | ''SDOPENAPP'' | Open a file for append |  | | ''SDOPENAPP'' | Open a file for append |  |
Line 84: Line 86:
 | ''SDREADTEXT'' | Read characters (nchars) from a file (given file handle) | ''nchars #xh SDREADTEXT'' | | ''SDREADTEXT'' | Read characters (nchars) from a file (given file handle) | ''nchars #xh SDREADTEXT'' |
 | ''SDWRITETEXT'' | Write string to a file (given file handle) | ''"string" #xh SDWRITETEXT'' | | ''SDWRITETEXT'' | Write string to a file (given file handle) | ''"string" #xh SDWRITETEXT'' |
 +| ''SDREADLINE'' | Read a line of text (including newline) from file | ''#xh SDREADLINE''
 +| ''SDSEEKSTA'' | Move pointer in file (measured relative to file start) | ''offset #xh SDSEEKSTA''
 +| ''SDSEEKEND'' | Move pointer in file (measured relative to file end) | ''offset #xh SDSEEKEND''
 +| ''SDSEEKCUR'' | Move pointer in file (measured relative to current position) | ''offset #xh SDSEEKCUR''
 +| ''SDTELL'' | Return pointer position in file (relative to file start) | ''#xh SDTELL''
 +| ''SDEOF'' | Returns true (1) if last operation hit end of file | ''#xh SDEOF'' |
  
 ---- ----
 ====Maintenance and status==== ====Maintenance and status====
  
-^ Command ^ Purpose ^ +^ Command ^ Purpose ^ Example 
-| ''SDFREE'' | Report free space on SD card (in bytes) | +| ''SDFREE'' | Report free space on SD card (in bytes) | ''SDFREE'' 
-| ''SDRESET'' | Mount card (safe to remove) |+| ''SDRESET'' | Mount card (safe to remove) | ''SDRESET''
 +| ''SDOPENDIR'' | Open a directory for gathering file or sub directory information | ''"Test" SDOPENDIR''
 +| ''SDNEXTFILE'' | Display file statistics in directory ((Returns 5 objects to stack: filename, underscore string, size (bytes), last modification date (DD.MMYYYY), last modification time (HH.MMSS); set 6 digits to display.)) (file handle from ''SDOPENDIR'') | ''#xh SDNEXTFILE''
 +| ''SDNEXTDIR'' | Display sub directory statistics within current directory | ''#xh SDNEXTDIR''
 +| ''SDNEXTENTRY'' | Step through every entry in the current directory (files or directories) | ''#xh SDNEXTENTRY'' |
  
 ---- ----
  • manual/chapter4/card.1496521641.txt.gz
  • Last modified: 2017/06/03 13:27
  • by smartin