SET FORMAT

SET FORMAT*

Activate a format when READ is executed

Syntax

      SET FORMAT TO [<idProcedure>[.<ext>]]

Arguments

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.

Description

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.

Notes

. 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.

Examples

      .  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

Seealso

@…GET, @…SAY, PROCEDURE, READ

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.