Code: Select all
Declare cHeader Type Character
Declare cNote Type Character
Declare cFile Type Character
Declare nCount Type Number
nCount := 0
cFile := PathCompany() + "NOTESDATA.TXT"
OpenTable("CUSTREC")
CUSTREC->(GotoTop())
If .NOT. CreateFile(cFile)
Echo("Sorry, file " + cFile + " could not be created. It may open in another application. " + IOError())
Return
Endif
:Loop
cNote := ReadRTFNote(2, CUSTREC->Cuscode,, TRUE)
If .Not. Empty(cNote)
cHeader := CUSTREC->CUSCODE + "|"
WriteFile(cFile, IF(nCount > 0, CHR(13) + CHR(10), "") + cHeader + cNote)
nCount := nCount + 1
Endif
If CUSTREC->(Skip())
Goto Loop
Endif
If .Not. CloseFile(cFile)
Echo("Error attempting to close export notes data.")
Return
Endif
If nCount = 0
Echo("No notes found.")
Else
Echo("Export completed.")
Endif