Component: File Access (File ): Difference between revisions
No edit summary |
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead"" |
||
| (6 intermediate revisions by 3 users not shown) | |||
| Line 17: | Line 17: | ||
==Component Source Code== | ==Component Source Code== | ||
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/ | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_File.fcsx FC_Comp_Source_File.fcsx] | ||
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/ | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_File.fcsx FC_Comp_Source_File.fcsx] | ||
==Detailed description== | ==Detailed description== | ||
| Line 47: | Line 47: | ||
''No detailed description exists yet for this component'' | ''No detailed description exists yet for this component'' | ||
Simple example App Developer file used with [[Component:_CSV_Read/Write_(File)|CVS Read/Write]] component to generate a two column CSV file that can be loaded into Microsoft Excel or LibreOffice Math. | |||
For an embedded CSV read write see the [[Component:_Embed_File_(File)|File component]] | |||
CSV Component used with App Developer -> File component: {{Fcfile|CSVTestAD.fcsx|CSV Test AD}} | |||
==Macro reference== | ==Macro reference== | ||
===AppendByteToFile=== | ===AppendByteToFile=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''AppendByteToFile''' | ||
|- | |- | ||
| colspan="2" | Adds a single byte to the end of the currently open file, useful for inserting the value 0 into binary file types. Returns 0 for success. | | colspan="2" | Adds a single byte to the end of the currently open file, useful for inserting the value 0 into binary file types. Returns 0 for success. | ||
| Line 103: | Line 75: | ||
===AppendStringToFile=== | ===AppendStringToFile=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''AppendStringToFile''' | ||
|- | |- | ||
| colspan="2" | Adds the contents of the data string parameter to the end of the currently open file. Returns 0 for success. | | colspan="2" | Adds the contents of the data string parameter to the end of the currently open file. Returns 0 for success. | ||
| Line 122: | Line 94: | ||
===CloseFile=== | ===CloseFile=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''CloseFile''' | ||
|- | |- | ||
| colspan="2" | Closes the currently opened file, releasing the file handle and allowing other applications to edit the file. | | colspan="2" | Closes the currently opened file, releasing the file handle and allowing other applications to edit the file. | ||
| Line 136: | Line 108: | ||
===CreateFile=== | ===CreateFile=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''CreateFile''' | ||
|- | |- | ||
| colspan="2" | Creates a file in the current folder location on the card. Default = Root Returns 0 for success File must be opened using "Open_File" after creation before writing any data. | | colspan="2" | Creates a file in the current folder location on the card. Default = Root Returns 0 for success File must be opened using "Open_File" after creation before writing any data. | ||
| Line 155: | Line 127: | ||
===DeleteFile=== | ===DeleteFile=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''DeleteFile''' | ||
|- | |- | ||
| colspan="2" | Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success. | | colspan="2" | Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success. | ||
| Line 174: | Line 146: | ||
===Initialise=== | ===Initialise=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Initialise''' | ||
|- | |- | ||
| colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 for success. | | colspan="2" | Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 for success. | ||
| Line 188: | Line 160: | ||
===MoveToNextFileSector=== | ===MoveToNextFileSector=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''MoveToNextFileSector''' | ||
|- | |- | ||
| colspan="2" | Attempts to move to the next sector in the file. When reading a file you would leave force next sector set to 0. When writing a file you would leave force next sector set to 1 to allow new sectors to be created as the file grows. Returns 0 for success | | colspan="2" | Attempts to move to the next sector in the file. When reading a file you would leave force next sector set to 0. When writing a file you would leave force next sector set to 1 to allow new sectors to be created as the file grows. Returns 0 for success | ||
| Line 207: | Line 179: | ||
===OpenFile=== | ===OpenFile=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OpenFile''' | ||
|- | |- | ||
| colspan="2" | Searches for and opens a file for reading or writing from within the current directory on the disk. Returns 0 for success. | | colspan="2" | Searches for and opens a file for reading or writing from within the current directory on the disk. Returns 0 for success. | ||
| Line 226: | Line 198: | ||
===OpenFolder=== | ===OpenFolder=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OpenFolder''' | ||
|- | |- | ||
| colspan="2" | ".." - Jumps up a directory, if at root then remains in root "root" - Jumps directly back to the root directory "foldername" - Opens folder named foldername | | colspan="2" | ".." - Jumps up a directory, if at root then remains in root "root" - Jumps directly back to the root directory "foldername" - Opens folder named foldername | ||
| Line 245: | Line 217: | ||
===ReadByteFromBuffer=== | ===ReadByteFromBuffer=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadByteFromBuffer''' | ||
|- | |- | ||
| colspan="2" | Reads a byte of data from the local sector buffer. Return = Data byte read from the local sector buffer. | | colspan="2" | Reads a byte of data from the local sector buffer. Return = Data byte read from the local sector buffer. | ||
| Line 264: | Line 236: | ||
===ReadByteFromFile=== | ===ReadByteFromFile=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadByteFromFile''' | ||
|- | |- | ||
| colspan="2" | Reads a byte from the currently open file. Auto increments the position in the file. A return value of 0 may signify the end of the file has been reached (depending on the contents of the file). | | colspan="2" | Reads a byte from the currently open file. Auto increments the position in the file. A return value of 0 may signify the end of the file has been reached (depending on the contents of the file). | ||
| Line 278: | Line 250: | ||
===ReadByteFromIndex=== | ===ReadByteFromIndex=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadByteFromIndex''' | ||
|- | |- | ||
| colspan="2" | Reads an arbitrary byte of data from the current open file. Return = Data byte read from the local sector buffer. Experimental and potentially slow if navigating backwards through the file. | | colspan="2" | Reads an arbitrary byte of data from the current open file. Return = Data byte read from the local sector buffer. Experimental and potentially slow if navigating backwards through the file. | ||
| Line 297: | Line 269: | ||
===ReadByteFromScan=== | ===ReadByteFromScan=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadByteFromScan''' | ||
|- | |- | ||
| colspan="2" | Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function. Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory | | colspan="2" | Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function. Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory | ||
| Line 316: | Line 288: | ||
===ReadFileLength=== | ===ReadFileLength=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadFileLength''' | ||
|- | |- | ||
| colspan="2" | Returns the number of bytes in the current sector that are used by the current open file. Return = 512 - Sector is filled with file data Return < 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector | | colspan="2" | Returns the number of bytes in the current sector that are used by the current open file. Return = 512 - Sector is filled with file data Return < 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector | ||
| Line 330: | Line 302: | ||
===ReadFileSector=== | ===ReadFileSector=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadFileSector''' | ||
|- | |- | ||
| colspan="2" | Overwrites local buffer with the current file sector from the disk. Used to restore the local sector buffer with the actual sector stored on the card. Return = 0 : Local buffer refreshed with current card sector Return > 0 : Error | | colspan="2" | Overwrites local buffer with the current file sector from the disk. Used to restore the local sector buffer with the actual sector stored on the card. Return = 0 : Local buffer refreshed with current card sector Return > 0 : Error | ||
| Line 344: | Line 316: | ||
===ReadFileSize=== | ===ReadFileSize=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadFileSize''' | ||
|- | |- | ||
| colspan="2" | Reads the entire size of the current file in bytes. | | colspan="2" | Reads the entire size of the current file in bytes. | ||
| Line 358: | Line 330: | ||
===ReadStringFromFile=== | ===ReadStringFromFile=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ReadStringFromFile''' | ||
|- | |- | ||
| colspan="2" | Reads a string from the currently open file. Auto increments the position in the file. An empty string signifies the end of the file has been reached. | | colspan="2" | Reads a string from the currently open file. Auto increments the position in the file. An empty string signifies the end of the file has been reached. | ||
| Line 382: | Line 354: | ||
===ScanCurrentFolder=== | ===ScanCurrentFolder=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ScanCurrentFolder''' | ||
|- | |- | ||
| colspan="2" | Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate. 0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty | | colspan="2" | Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate. 0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty | ||
| Line 406: | Line 378: | ||
===SetFileIndex=== | ===SetFileIndex=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''SetFileIndex''' | ||
|- | |- | ||
| colspan="2" | Sets the current file index and used to switch between several open file streams. Default = 0. | | colspan="2" | Sets the current file index and used to switch between several open file streams. Default = 0. | ||
| Line 425: | Line 397: | ||
===SetTimeAndDate=== | ===SetTimeAndDate=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''SetTimeAndDate''' | ||
|- | |- | ||
| colspan="2" | Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat | | colspan="2" | Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat | ||
| Line 449: | Line 421: | ||
===WriteByteToBuffer=== | ===WriteByteToBuffer=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''WriteByteToBuffer''' | ||
|- | |- | ||
| colspan="2" | Writes a single byte to the current 512 byte local sector buffer. | | colspan="2" | Writes a single byte to the current 512 byte local sector buffer. | ||
| Line 473: | Line 445: | ||
===WriteFileSector=== | ===WriteFileSector=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''WriteFileSector''' | ||
|- | |- | ||
| colspan="2" | Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function. Return = 0 - File sector written successfully. Return > 0 - File sector write error | | colspan="2" | Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function. Return = 0 - File sector written successfully. Return > 0 - File sector write error | ||
| Line 484: | Line 456: | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
==Property reference== | ==Property reference== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Properties''' | ||
|- | |- | ||
|- | |- | ||
Latest revision as of 14:22, 13 July 2026
| Author | Matrix TSL |
| Version | 1.0 |
| Category | File |
File Access component
File component allowing access to read and write files on the local Windows file system. Only available in simulation runtime mode, cannot be downloaded to hardware. Compatible with File (SD Card) embedded component.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_File.fcsx
Please click here to view the component source code (Beta): FC_Comp_Source_File.fcsx
Detailed description
No detailed description exists yet for this component
Simple example App Developer file used with CVS Read/Write component to generate a two column CSV file that can be loaded into Microsoft Excel or LibreOffice Math.
For an embedded CSV read write see the File component
CSV Component used with App Developer -> File component:
CSV Test AD
Macro reference
AppendByteToFile
AppendStringToFile
CloseFile
| CloseFile | |
| Closes the currently opened file, releasing the file handle and allowing other applications to edit the file. | |
| Return | |
CreateFile
DeleteFile
| DeleteFile | |
| Searches for and deletes a file in the current folder location on the card. Default = Root Returns 0 for success. | |
| Filename | |
| 8.3 format filename e.g."file.txt" | |
| Return | |
Initialise
| Initialise | |
| Attempts to communicate with the SD card and if successful sets up the file system. Returns 0 for success. | |
| Return | |
MoveToNextFileSector
OpenFile
OpenFolder
ReadByteFromBuffer
ReadByteFromFile
ReadByteFromIndex
ReadByteFromScan
ReadFileLength
ReadFileSector
ReadFileSize
| ReadFileSize | |
| Reads the entire size of the current file in bytes. | |
| Return | |
ReadStringFromFile
ScanCurrentFolder
SetFileIndex
| SetFileIndex | |
| Sets the current file index and used to switch between several open file streams. Default = 0. | |
| File_Index | |
| File index ranges from 0 to (Max Concurrent Files - 1) | |
| Return | |
SetTimeAndDate
| SetTimeAndDate | |
| Sets the current time and date. Time = (Hour << 11) + (Min << 5) + (Sec >> 1) Date = (YearFrom1980 << 9) + (Month << 5) + (Day) Additional details can be found here: http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#TimeFormat | |
| Time | |
| Sets the current Time in FAT Time format hhhhhmmmmmmsssss - S=Secs/2 | |
| Date | |
| Sets the current Date in FAT Date format yyyyyyymmmmddddd - Y=Years since 1980 | |
| Return | |
WriteByteToBuffer
| WriteByteToBuffer | |
| Writes a single byte to the current 512 byte local sector buffer. | |
| Address | |
| Address Range 0 - 511 | |
| Data | |
| Data Byte to write to the buffer | |
| Return | |
WriteFileSector