Harbour have many features for text file processing, manipulation.
Global Processing : taking text files as a single string.
|MemoRead||Return the text file’s contents as a character string|
|MemoWrit||Write a memo field or character string to a text file on disk|
|HB_MemoRead||Return the text file’s contents as a character string|
|HB_MemoWrit||Write a memo field or character string to a text file on disk|
A Class to read a text file
|TFileRead||Read a file one line at a time|
In Harbour it’s possible also manipulate text files same as table ( .dbf ) files.
This group of function may be used for this purpose.
The basic structure is :
HB_FUse( <cTextFile> ) <-- open text file as a table WHILE .NOT. HB_FEof() <-- continue process for all lines in the file
c1Line := HB_FReadLN() <-- read a record (line) from file .... <-- process line HB_FSkip() <-- advance record ( line ) pointer ENDDO HB_FUse() <-- close file
Special Text File Processing Functions
|HB_FAtEOF()||Chech EOF status of given work area|
|HB_FEof()||Check end of text file status|
|HB_FGoBottom()||Go to the last record in a text file|
|HB_FGoto()||Move record pointer to specific record in the selected text file|
|HB_FGoTop()||Move the record pointer to the first record in selected text file|
|HB_FInfo()||Retrieves status information about the currently selected text file|
|HB_FLastRec()||Get the number of records in the currently selected text file|
|HB_FReadAndSkip()||Reads the current line and moves the record pointer to the next line|
|HB_FreadLN()||Read a line from the selected text file without moving the record pointer|
|HB_FRecno()||Return the current line / record number of a text file|
|HB_FSelect()||Select a text file work area|
|HB_FSkip()||Move the record pointer to a new position in a text file|
|HB_FUse()||Open or close a text file for use by the HB_F* functions|
A ‘global’ sample for HB_F* text file processing functions : download.