DISPLAY

DISPLAY

Display records to the console

Syntax

      DISPLAY <exp list>
             [TO PRINTER] [TO FILE <xcFile>]
             [<scope>] [WHILE <lCondition>]
             [FOR <lCondition>] [OFF]

Arguments

<exp list> is the list of values to display for each record processed.

TO PRINTER echoes output to the printer.

TO FILE <xcFile> echoes output to the indicated file which can be specified either as a literal file name or as a character expression enclosed in parentheses. If an extension is not specified, .txt is added.

<scope> is the portion of the current database file to DISPLAY. The default is the current record, or NEXT 1. If a condition is specified, the scope becomes ALL.

WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails.

FOR <lCondition> specifies the conditional set of records to DISPLAY within the given scope.

OFF suppresses the display of the record number.

Description

DISPLAY is a database command that sequentially accesses records in the current work area, sending the results of the <exp list> to the console in a tabular format with each column separated by a space. The command does not display column headers or pause at predetermined intervals. DISPLAY is identical to LIST with the exception that its default scope is NEXT 1 rather than ALL.

When invoked, output is sent to the screen and optionally to the printer and/or a file. To suppress output to the screen while printing or echoing output to a file, SET CONSOLE OFF before the DISPLAY command line.

Notes

. Interrupting output: To let the user interrupt the processing of a DISPLAY command, using the INKEY() function, add a test for the interrupt key press to the FOR condition. See the example below. . Printer margin: Since DISPLAY is a console command, it honors the current SET MARGIN for output echoed to the printer.

Examples

      .  This example illustrates a simple DISPLAY, and a conditional
      DISPLAY to the printer:
      USE Sales NEW
      DISPLAY DATE(), TIME(), Branch
      DISPLAY Branch, Salesman FOR Amount > 500 TO PRINTER
      .  This example interrupts a DISPLAY using INKEY() to test
      whether the user pressed the Esc key:
      #define K_ESC  27
      USE Sales INDEX SalesMan NEW
      DISPLAY Branch, Salesman, Amount WHILE ;
         INKEY() != K_ESC

Seealso

DBEVAL(), INKEY(), LIST, SET MARGIN

DELETE TAG

DELETE TAG

Delete a tag

Syntax

      DELETE TAG <cOrderName> [IN <xcOrderBagName>]
             [, <cOrderName> [IN xcOrderBagName] list>]

Arguments

<cOrderName> is a character string that represents the order name.

<xcOrderBagName> is the name of a disk file containing one or more orders. You may specify <xcOrderBagName> as the file name with or without the path name or appropriate extension. If you do not include the extension as part of <xcOrderBagName>, Clipper uses the default extension of the current RDD.

<cOrderName …list> is an optional list of order and order bag name pairs, separated by commas. Any reference to <cOrderName> that results in either a null string (“”) or spaces is ignored. You can specify each order as a literal expression or as a character expression enclosed in parentheses. If you specify no extension for the order bag name, the current database driver supplies a default extension.

Description

This command removes an order from an order bag in the current or specified work area. If you do not specify an <xcOrderBagName>, all orders bags are searched in the current or specified work area. The first occurrence of <cOrderName> is deleted. A runtime recoverable error is raised if the order is not found.

If <cOrderName> is the active order, the database in the current or specified work area reverts to its identity order (natural or entry) and SET FILTER scoping.

A runtime error is raised if <xcOrderBagName> does not exist or if it exists but does not contain <cOrderName>.

The active RDD determines the order capacity of an order bag. The default DBFNTX and the DBFNDX drivers only support single-order bags, while other RDDs may support multiple-order bags (e.g., the DBFCDX and DBFMDX drivers).

Examples

      USE Customer VIA "DBFCDX" NEW
      SET INDEX TO Customer
      // Delete the Orders (Tags) Cust01 and Cust02 that
      // exist in the index file Customer
      DELETE TAG Cust01 IN Customer
      DELETE TAG Cust02 IN Customer
      // or
      // DELETE TAG Cust01 IN Customer, Cust02 IN Customer

Sealso

ORDDESTROY()

DELETE

DELETE

Mark records for deletion

Syntax

      DELETE [<scope>] [WHILE <lCondition>]
             [FOR <lCondition>]

Arguments

<scope> is the portion of the current database file to DELETE. If a scope is not specified, DELETE acts only on the current record. If a conditional clause is specified, the default becomes ALL records.

WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails.

FOR <lCondition> specifies the conditional set of records to DELETE within the given scope.

Description

DELETE is a database command that tags records so they can be filtered with SET DELETED ON, queried with DELETED(), or physically removed from the database file with PACK. In addition, display commands such as LIST and DISPLAY identify deleted records with an asterisk (*) character. Once records are deleted, you can reinstate them by using RECALL. If you want to remove all records from a database file, use ZAP instead of DELETE ALL and PACK.

Any deleted record can be recalled as long as the PACK or ZAP command has not been issued. Once the PACK or ZAP command has been issued, the deleted data cannot be retrieved.

In a network environment, DELETE requires the current record be locked with RLOCK() if you are deleting a single record. If you are deleting several records, the current database file must be locked with FLOCK() or USEed EXCLUSIVEly. Refer to the “Network Programming” chapter in the Programming and Utilities Guide for more information.

Notes

. DELETE with SET DELETED ON: If the current record is deleted with SET DELETED ON, it will be visible until the record pointer is moved.

Examples

      .  This example demonstrates use of the FOR clause to mark a set
         of records for deletion:
      USE Sales INDEX Salesman NEW
      DELETE ALL FOR Inactive

Seealso

DBEVAL(), DELETED(), FLOCK(), PACK, RECALL, RLOCK()

COUNT

COUNT

Tally records to a variable

Syntax

      COUNT TO <idVar>
             [<scope>] [WHILE <lCondition>] [FOR <lCondition>]

Arguments

TO <idVar> identifies the variable that holds the COUNT result. A variable that either does not exist or is invisible is created as a private variable whose scope is the current procedure.

<scope> is the portion of the current database file to COUNT. The default is ALL records.

WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails.

FOR <lCondition> specifies the conditional set of records to COUNT within the given scope.

Description

COUNT tallies the number of records from the current work area that match the specified record scope and conditions. The result is then placed in the specified variable. <idVar> can be a variable of any storage class including a field.

Examples

      .  This example demonstrates a COUNT of Branches in Sales.dbf:
      USE Sales NEW
      COUNT TO nBranchCnt FOR Branch = 100
      ? nBranchCnt                           // Result: 4
      .  This example tallies the number of records in Sales.dbf whose
      Branch has the value of 100 and assigns the result to the Count field
      in Branch.dbf for branch 100:
      USE Branch INDEX Branch NEW
      SEEK 100
      USE Sales INDEX SalesBranch NEW
      SEEK 100
      COUNT TO Branch->Count WHILE Branch = 100

Seealso

AVERAGE, DBEVAL(), SUM, TOTAL

COPY TO

COPY TO

Export records to a new database (.dbf) file or ASCII text file

Syntax

      COPY [FIELDS <idField list>] TO <xcFile>
             [<scope>] [WHILE <lCondition>] [FOR <lCondition>]
             [SDF | DELIMITED [WITH BLANK | <xcDelimiter>] |
             [VIA <xcDriver>]]

Arguments

FIELDS <idField list> specifies the list of fields to copy to the target file. The default is all fields.

TO <xcFile> specifies the name of the target file. The file name can be specified either as a literal file name or as a character expression enclosed in parentheses. If SDF or DELIMITED is specified, .txt is the default extension. Otherwise, .dbf is the default extension.

<scope> defines the portion of the current database file to COPY. The default is ALL records.

WHILE <lCondition> specifies the set of records meeting the condition from the current record until the condition fails.

FOR <lCondition> specifies the conditional set of records to copy within the given scope.

SDF specifies the output file type as a System Data Format ASCII text file. Records and fields are fixed length.

DELIMITED specifies the output file type as a delimited ASCII text file where character fields are enclosed in double quotation marks (the default delimiter). Records and fields are variable length.

DELIMITED WITH BLANK identifies an ASCII text file in which fields are separated by one space and character fields have no delimiters.

DELIMITED WITH <xcDelimiter> identifies a delimited ASCII text file where character fields are enclosed using the specified delimiter. <xcDelimiter> can be specified either as a literal character or as a character expression enclosed in parentheses.

See the tables below for more information regarding the format specifications for ASCII text files created using these arguments.

VIA <xcDriver> specifies the replaceable database driver (RDD) to use to create the resulting copy. <cDriver> is name of the RDD specified as a character expression. If <cDriver> is specified as a literal value, it must be enclosed in quotes.

If the VIA clause is omitted, COPY TO uses the driver in the current work area. If you specify the VIA clause, you must REQUEST the appropriate RDDs to be linked into the application.

Note: If the DELIMITED WITH clause is specified on a COPY or APPEND command, it must be the last clause specified.

Description

COPY TO is a database command that copies all or part of the current database file to a new file. Records contained in the active database file are copied unless limited by a <scope>, a FOR|WHILE clause, or a filter.

If DELETED is OFF, deleted records in the source file are copied to <xcFile> where they retain their deleted status. If DELETED is ON, however, no deleted records are copied. Similarly, if a FILTER has been SET, invisible records are not copied.

Records are copied in controlling index order if there is an index open in the current work area and SET ORDER is not zero. Otherwise, records are copied in natural order.

In a network environment, Clipper opens the target database file EXCLUSIVEly before the COPY TO operation begins. Refer to the “Network Programming” chapter.

          This table shows the format specifications for SDF text files:
          SDF Text File Format Specifications
          ------------------------------------------------------------------------
          File Element        Format
          ------------------------------------------------------------------------
          Character fields    Padded with trailing blanks
          Date fields         yyyymmdd
          Logical fields      T or F
          Memo fields         Ignored
          Numeric fields      Padded with leading blanks for zeros
          Field separator     None
          Record separator    Carriage return/linefeed
          End of file marker  1A hex or CHR(26)
          ------------------------------------------------------------------------
          This table shows the format specifications for DELIMITED and DELIMITED
          WITH <xcDelimiter> ASCII text files:
          DELIMITED Text File Format Specifications
          ------------------------------------------------------------------------
          File Element        Format
          ------------------------------------------------------------------------
          Character fields    Delimited, with trailing blanks truncated
          Date fields         yyyymmdd
          Logical fields      T or F
          Memo fields         Ignored
          Numeric fields      Leading zeros truncated
          Field separator     Comma
          Record separator    Carriage return/linefeed
          End of file marker  1A hex or CHR(26)
          ------------------------------------------------------------------------
          This table shows the format specifications for DELIMITED WITH BLANK
          ASCII text files:
          DELIMITED WITH BLANK Text File Format Specifications
          ------------------------------------------------------------------------
          File Element        Format
          ------------------------------------------------------------------------
          Character fields    Not delimited, trailing blanks truncated
          Date fields         yyyymmdd
          Logical fields      T or F
          Memo fields         Ignored
          Numeric fields      Leading zeros truncated
          Field separator     Single blank space
          Record separator    Carriage return/linefeed
          End of file marker  1A hex or CHR(26)
          ------------------------------------------------------------------------

Examples

      .  This example demonstrates copying to another database file:
      USE Sales NEW
      COPY TO Temp
      .  This example demonstrates the layout of a DELIMITED file:
      COPY NEXT 1 TO Temp DELIMITED
      TYPE Temp.txt
      Result:
      "Character",12.00,19890801,T
      .  This example demonstrates the layout of an SDF file with four
      fields, one for each data type:
      USE Testdata NEW
      COPY NEXT 1 TO Temp SDF
      TYPE Temp.txt
      Result:
      Character     12.0019890801T
      .  This example demonstrates the layout of a DELIMITED file WITH
      a different delimiter:
      COPY NEXT 1 TO Temp DELIMITED WITH '
      TYPE Temp.txt
      Result:
      'Character',12.00,19890801,T

Seealso

APPEND FROM, COPY FILE, COPY STRUCTURE, SET DELETED

CONTINUE

CONTINUE

Resume a pending LOCATE

Syntax

      CONTINUE

Description

CONTINUE is a database command that searches from the current record position for the next record meeting the most recent LOCATE condition executed in the current work area. It terminates when a match is found or end of file is encountered. If CONTINUE is successful, the matching record becomes the current record and FOUND() returns true (.T.); if unsuccessful, FOUND() returns false (.F.).

Each work area may have an active LOCATE condition. In Harbour, a LOCATE condition remains pending until a new LOCATE condition is specified. No other commands release the condition.

Notes

. Scope and WHILE condition: Note that the scope and WHILE condition of the initial LOCATE are ignored; only the FOR condition is used with CONTINUE. If you are using a LOCATE with a WHILE condition and want to continue the search for a matching record, use SKIP and then repeat the original LOCATE statement adding REST as the scope.

Examples

      .  This example scans records in Sales.dbf for a particular
         salesman and displays a running total sales amounts:
      LOCAL nRunTotal := 0
      USE Sales NEW
      LOCATE FOR Sales->Salesman = "1002"
      DO WHILE FOUND()
         ? Sales->Salesname, nRunTotal += Sales->Amount
         CONTINUE
      ENDDO
      .  This example demonstrates how to continue if the pending
      LOCATE scope contains a WHILE condition:
      LOCAL nRunTotal := 0
      USE Sales INDEX Salesman NEW
      SEEK "1002"
      LOCATE REST WHILE Sales->Salesman = "1002";
            FOR Sales->Amount > 5000
      DO WHILE FOUND()
         ? Sales->Salesname, nRunTotal += Sales->Amount
         SKIP
         LOCATE REST WHILE Sales->Salesman = "1002";
            FOR Sales->Amount > 5000
      ENDDO

Seealso

EOF(), FOUND(), LOCATE, SEEK

COMMIT

COMMIT

Perform a solid-disk write for all active work areas

Syntax

      COMMIT

Description

COMMIT is a database command that flushes Harbour buffers and performs a solid-disk write for all work areas with open database and index files. The solid-disk write capability is available under DOS version 3.3 and above. Under DOS 3.2 or less, COMMIT flushes Harbour buffers to DOS.

In a network environment, issuing a GO TO RECNO() or a SKIP0 will flush Clipper’s database and index buffers, but only a COMMIT will flush the buffers and perform a solid-disk write. Thus to insure updates are visible to other processes, you must issue a COMMIT after all database update commands (e.g., APPEND, REPLACE). To insure data integrity, COMMIT should be issued before an UNLOCK operation. Refer to the “Network Programming” chapter for more information on update visibility.

Examples

      .  In this example, COMMIT forces a write to disk after a series
        of memory variables are assigned to field variables:
      USE Sales EXCLUSIVE NEW
      MEMVAR->Name := Sales->Name
      MEMVAR->Amount := Sales->Amount
      //
      @ 10, 10 GET MEMVAR->Name
      @ 11, 10 GET MEMVAR->Amount
      READ
      //
      IF UPDATED()
         APPEND BLANK
         REPLACE Sales->Name WITH MEMVAR->Name
         REPLACE Sales->Amount WITH MEMVAR->Amount
         COMMIT
       ENDIF

Seealso

DBCOMMIT(), DBCOMMITALL(), GO, SKIP