Activate a format when READ is executed
SET FORMAT TO [<idProcedure>[.<ext>]]
TO <idProcedure> is a format (.fmt) file, a program (.prg) file, or a procedure.
<ext> is the extension of the format file. If not specified, the default extension is (.fmt).
SET FORMAT TO with no argument deactivates the current format.
SET FORMAT defines a procedure to execute when a READ is invoked. Unlike the interpreted environment, formats are not opened and executed at runtime. Instead, the Harbour compiler treats SET FORMAT the same as a DO command. The compiler first looks to see whether it has already compiled a procedure with the same name as <idProcedure>. If it has, it uses that procedure for the reference. If <idProcedure> is not found, the compiler looks to disk for a file with the same name. If this file is not found, an external reference is generated that must be resolved at link time.
SET FORMAT is a compatibility command and not recommended.
. Active format procedures: Unlike other dialects where each work area can have an active format, Harbour supports only one active format procedure for all work areas.
. Screen CLEARing: Harbour does not clear the screen when a format procedure is executed.
. Legal statements: Format procedures allow statements and commands in addition to @…SAY and @…GET.
. Multiple pages: Harbour does not support multiple-page format procedures.
. This example uses a format procedure to add records to a database file until the user presses Esc: USE Sales NEW SET FORMAT TO SalesScr DO WHILE LASTKEY() != 27 APPEND BLANK READ ENDDO RETURN PROCEDURE SalesScr @ 12, 12 SAY "Branch : " GET Branch @ 13, 12 SAY "Salesman : " GET Salesman RETURN
@…GET, @…SAY, PROCEDURE, READ