TFileGTF

Source: source/classes/tfilegtf.prg

Standalone class

TFileGTF is a file writer for the GTF (Generic Text Format) file format. It provides structured text output with configurable alignment, font selection, and color applied per write operation. The class manages font and format tables internally and writes the GTF header and body segments to disk.

Key DATA Members

DATATypeDescription
cNameCharacterTarget GTF file name
hFileNumericWindows file handle
nAlignNumericCurrent text alignment (ES_LEFT, ES_CENTER, ES_RIGHT)
nFontNumericCurrent font index in the font table
nColorNumericCurrent text color (RGB)

Methods

MethodDescription
New( cFileName )Create a new GTF file; writes header and font table
End()Finalize and close the GTF file
Write( uVal, nFormat, nAlign, nFont, nColor, lReturn )Write a value with optional format, alignment, font, and color; lReturn appends CRLF
_Return()Write a blank line (CRLF)

Utility Functions

FunctionDescription
GTFFont( cName, nHeight, nWidth, lBold, lItalic, lUnderline, lStrikeout )Define or retrieve a font; returns font index
GTFFormat( nAlign, nFont, nColor )Define or retrieve a format triplet; returns format index
SetGTFFormat( nFormat )Set current format by index
SetGTFAlign( nAlign )Set default alignment
SetGTFFont( nFont )Set default font index
SetGTFColor( nColor )Set default text color

Example: Writing a GTF File

#include "FiveWin.ch"

function Main()

   local oGtf := TFileGTF():New( "output.gtf" )

   GTFFont( "Arial", 14, 6, .T., .F., .F., .F. )
   GTFFont( "Courier New", 12, 5, .F., .F., .F., .F. )
   GTFFormat( ES_CENTER, 1, CLR_RED )
   GTFFormat( ES_LEFT, 2, CLR_BLUE )

   oGtf:Write( "Section Heading", 1 )
   oGtf:_Return()
   oGtf:Write( "Body text line", 2 )
   oGtf:End()

return nil

Notes

See Also