File_ReadLine()

Parent Previous Next

Syntax

File_ReadLine(ByRef StringBuffer As Dword, wBufferLen As Word, LinePosition As Word), Word

Parameters

StringBuffer — destination string buffer array — a string variable is required here, since ByRef passes its address automatically

wBufferLen — string buffer size in bytes

LinePosition — characters already consumed for this line so far (0 on the first call for a line)

               

Return value — 0 - if the line completed (LF found, or EOF reached) within this call;

               otherwise - LinePosition + however many characters this call added - pass that back in as LinePosition to continue reading the same line from where stopped    


Reads from the currently open file up to the next line into srting array


Reads from the currently open file up to the next line with File_Open() or File_OpenAt() ending (or EOF) into StringBuffer, always starting at StringBuffer's own position 0. 


LinePosition is the cumulative count of characters already read for this line by previous calls (0 for a fresh line); It's only used to compute the return position in file.


CR bytes are discarded (not stored, don't end the line by themselves); LF ends the line. Doesn't handle a lone CR with no following LF as a line ending.

Example

    'Create string array variable

    Dim sTemp As String * 12  

    'Create scratch variable                                  

    Dim bTemp As Byte   

    'Open file "temp.txt"                                         

    File_Open("temp.txt")                                       

    'Read the first line from the begining into sTemp, 

    'if the line is longer than 12, bTemp will hold the 

    'current position i.e. 12, otherwise 0 

    bTemp = File_ReadLine(sTemp,12,0)  

    'Print the read text                       

    TftPrintSndString(sTemp, 1, 0,0,1, RED,BLACK,0)         

    'Read the first Line from position held in bTemp i.e. 12 

    'into sTemp, If the Line is longer than 12, the Result 

    'will hold the current position i.e. 24, otherwise 0 

    File_ReadLine(sTemp,12,bTemp)  

    'Print the read text starting at TFT position bTemp + 1, thus completing the line                         

    TftPrintSndString(sTemp, 1, bTemp+1,0,1, RED,BLACK,0)

Created with the Personal Edition of HelpNDoc: Free Web Help generator