File_ReadByte(), Byte
Result Byte: The byte read from the open file.
Read a Single Byte from an Open File
This procedure reads a single byte from an open file. To read the n-th byte from the file, you need to call this function in a loop n-1 times before reaching the desired byte.
How it Works:
• File_Open: Before you can use File_ReadByte(), the file must be opened with the File_Open() or File_OpenAt() function.
• End of File (EOF): You can monitor the File_tEOF variable to determine if you've reached the end of the file. When File_tEOF = 1, you've reached the end of the file.
• File Open Check: You can also check if a file is currently open by monitoring the File_tIsOpen variable. When File_tIsOpen = 1, it means a file is currently open and available for reading.
Example:
File_ReadByte()
Notes:
• If you're trying to read the n-th byte, you can use a loop to call File_ReadByte() repeatedly. For example, to read the second byte, you would call File_ReadByte() once and then read the byte returned in the second call.
• Be sure to check File_tEOF to prevent reading past the end of the file, which would result in an error.
TftSetUp(0) 'Set screen TftResetScreen(BLACK) 'Reset screen TftSetSndFont(0,0) 'Set Font0 While File_Init() <> cErrOK : Wend 'Initialize SD Card TftPrintSndString("Sd Initialization OK",1,0,0,1,GREEN,BLACK,0) 'Confirm Initialize SD Card While File_Open("Open.txt") <> cErrOK : Wend 'Open file Open.txt to edit data TftPrintSndString("Open Open.txt OK",1,0,2,1,GREEN,BLACK,0) 'Confirm Open.txt is open bCounter = 0 'Print position counter Do TftPrintSndChar(File_ReadByte(),1,bCounter,3,1,GREEN,BLACK,0) 'Print data as text If File_EOF() = 1 Then Break 'Loop till end of file Inc bCounter Loop File_Close() 'close file TftPrintSndString("Close Open.txt OK",1,0,4,1,GREEN,BLACK,0) 'Confirm close file |
|
Created with the Personal Edition of HelpNDoc: Add an Extra Layer of Security to Your PDFs with Encryption