File_Append()

Parent Previous Next

File_Append(pFileName), Byte


pFileName: The name of the file to open for appending (maximum length 12 characters, including dot and extension).


Return Status:

cErrOK: Success.

cErrNotFound: File not found.

cErrDiskFull: Disk is full.

cErrInUse: File is already open and in use.

cErrRWError: Read/write error.


Open a File for Appending Data


This procedure opens an existing file for writing, specifically appending data to the end of the file. The maximum name length is 12 characters, including the file extension.


Example:

File_Append("MyFile.txt")


Notes:

• This command opens the file and automatically moves to the end of the file to allow appending data.

• If you wish to add more data to the file, use File_Append() and the new data will be written at the end of the file without overwriting existing content.

• After finishing the write operation, close the file using File_Close() to ensure the data is saved.

• The Modified property of the file is updated when using File_Append(). If new values aren't set with File_TimeModified(), the current values will be used.


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

File_TimeModified(5,11,24, 12,39,45)                                                        'Set modified property

While File_Append("append.log") <> cErrOK : Wend                                            'Open file append.log to edit data

TftPrintSndString("Append append.log OK",1,0,2,1,GREEN,BLACK,0)                             'Confirm append.log is open 

sString = " world!"                                                                         'Load string with data to be written

For bCounter = 0 To 12    

    If sString[bCounter] = 0 Then Break                                                     'break if end of string

    File_WriteByte(sString[bCounter])                                                       'write data to append.Log

Next

If File_Flush() = 1 Then 

    TftPrintSndString("Flush append.Log OK",1,0,3,1,GREEN,BLACK,0)                          'confirm flush ok and good to remove card

Else

    TftPrintSndString("Flush append.Log NO",1,0,3,1,GREEN,BLACK,0)                          'flush not ok and not good to remove card

EndIf 






Created with the Personal Edition of HelpNDoc: Revolutionize Your CHM Help File Output with HelpNDoc