SET FILTER

SET FILTER

Hide records not meeting a condition

Syntax

      SET FILTER TO [<lCondition>]

Arguments

TO <lCondition> is a logical expression that defines a specific set of current work area records accessible for processing.

SET FILTER TO without an argument deactivates the filter condition.

Description

When a FILTER condition is SET, the current work area acts as if it contains only the records that match the specified condition. A filter condition is one of the properties of a work area. Once a FILTER has been SET, the condition can be returned as a character string using the DBFILTER() function.

Most commands and functions that move the record pointer honor the current filter with the exception of those commands that access records by record number. This includes GOTO, commands specified with the RECORD clause, and RELATIONs linked by numeric expression to a work area with no active index.

Once a FILTER is SET, it is not activated until the record pointer is moved from its current position. You can use GO TOP to activate it.

As with SET DELETED, a filter has no effect on INDEX and REINDEX.

Note

Although SET FILTER makes the current work area appear as if it contains a subset of records, it, in fact, sequentially processes all records in the work area. Because of this, the time required to process a filtered work area will be the same as an unfiltered work area.

Examples

      .  This example filters Employee.dbf to only those records where
         the age is greater than 50:

      USE Employee INDEX Name NEW
      SET FILTER TO Age > 50
      LIST Lastname, Firstname, Age, Phone
      SET FILTER TO

Seealso

DBFILTER(), DBSETFILTER(), SET DELETED

RECALL

Restore records marked for deletion

Syntax

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

Arguments

<scope> is the portion of the current database file to RECALL. The default scope is the current record, or NEXT 1. If a condition is specified, the default 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 RECALL within the given scope.

Description

RECALL is a database command that restores records marked for deletion in the current work area. This is the inverse of the DELETE command. If DELETED is ON, RECALL can restore the current record or a specific record, if you specify a RECORD scope. Note that once you PACK a database file, all marked records have been physically removed from the file and cannot be recovered.

In a network environment, RECALLing the current record requires an RLOCK(). RECALLing several records requires an FLOCK() or EXCLUSIVE USE of the current database file. Refer to the “Network Programming” chapter for more information.

Examples

      .  This examples show the results of RECALL:

      USE Sales NEW
      //
      DELETE RECORD 4
      ? DELETED()               // Result: .T.
      //
      RECALL
      ? DELETED()               // Result: .F.

Seealso

DELETE, DELETED, FLOCK(), PACK, RLOCK(), SET DELETED

GO

GO

Move the pointer to the specified identity

Syntax

      GO[TO] <xIdentity> | BOTTOM | TOP

Arguments

<xIdentity> is a unique value guaranteed by the structure of the data file to reference a specific item in a data source (database). In a .dbf, identity is the record number. In other data formats, identity is the unique primary key value.

BOTTOM specifies the last logical record in the current work area.

TOP specifies the first logical record in the current work area.

Description

GO[TO] is a database command that positions the record pointer in the current work area at the specified identity. In an Xbase data structure, this identity is the record number because every record, even an empty record, has a record number. In data structures of different design, identity may be defined as something other than record number.

Examples

      .  This example saves the current record number, searches for a
         key, and then restores the record pointer to the saved position:
      FUNCTION KeyExists( xKeyExpr )
         LOCAL nSavRecord := RECNO()      // Save the current record
                                          // pointer position
         LOCAL lFound
         SEEK xKeyExpr
         IF ( lFound := FOUND() )
            .
            .  < statements >
            .
         ENDIF
         GOTO nSavRecord      // Restore the record pointer position
         RETURN ( lFound )

Seealso

DBGOTO(), LASTREC(), RECNO(), SET DELETED, SET FILTER

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

SP_EDITDB

EDITDB()
  Short:
  ------
  EDITDB() Customized database browser with edit/add/search
  capabilities

  Returns:
  --------
  Nothing

  Syntax:
  -------
  EDITDB([lModify],[aFields,aFieldDesc],[lBypassAsk],[lBypassLeave],;
         [nLock])

  Description:
  ------------
  Customized browse interface allowing searching, goto,
  vertical view and (if <lModify> is True) add edit delete.

  Also allows limiting of fields viewed.

  [lModify] allows add-edit-delete or not.

  The two arrays [aFields, aFieldDesc] are of field
  names and field descriptions. Default is all fields, field names
  as descriptions.

  [lByPassAsk] allows bypass of the "BROWSE ALL/SELECT
  FIELDS" opening menu choice, and defaults to .f.

  [lByPassLeave] allows bypass of "Quit?" dialog. Just quits

  [nLock] number of columns to lock (default is 0)

  Examples:
  ---------
   USE CUSTOMER

   aFlds := {"FNAME","LNAME","MI"}
   aDesc := {"First","Last","Middle"}
   editdb(.t.,aFlds,aDesc)

  Notes:
  -------
  Allows record deletion, but does not pack. Does not
  'SET DELETED' one way or the other.

  Source:
  -------
  S_EDIT.PRG

 

C5_SET DELETED

SET DELETED
 Toggle filtering of deleted records
------------------------------------------------------------------------------
 Syntax

     SET DELETED on | OFF | <xlToggle>

 Arguments

     ON ignores deleted records.

     OFF processes deleted records.

     <xlToggle> is a logical expression that must be enclosed in
     parentheses.  A value of true (.T.) is the same as ON, and a value of
     false (.F.) is the same as OFF.

 Description

     SET DELETED toggles automatic filtering of records marked for deletion in
     all work areas.  When SET DELETED is ON, most commands ignore deleted
     records.  If, however, you refer to a record by record number (GOTO or any
     command that supports the RECORD scope), the record is not ignored even if
     marked for deletion.  Additionally, SET DELETED ON has no affect on INDEX
     or REINDEXing.

     RECALL ALL honors SET DELETED and does not recall any records.

 Notes

     .  Filtering deleted records in a single work area: To confine
        the filtering of deleted records to a particular work area, SELECT
        the work area, and then SET FILTER TO DELETED().

 Examples

     .  This example illustrates the effect of using SET DELETED:

        USE Sales NEW
        ? LASTREC()                  // Result: 84
        //
        DELETE RECORD 4
        COUNT TO nCount
        ? nCount                     // Result: 84
        //
        SET DELETED ON
        COUNT TO nCount
        ? nCount                     // Result: 83

 Files   Library is CLIPPER.LIB.

See Also: DELETE DELETED() RECALL SET FILTER



C5 Commands

 ?|??            Display one or more values to the console
 @...BOX         Draw a box on the screen
 @...CLEAR       Clear a rectangular region of the screen
 @...GET         Create a new Get object and display it
 @...PROMPT      Paint a menu item and define a message
 @...SAY         Display data at a specified screen or printer row and column
 @...TO          Draw a single- or double-line box
 ACCEPT*         Place keyboard input into a memory variable
 APPEND BLANK    Add a new record to the current database file
 APPEND FROM     Import records from a database (.dbf) file or ASCII text file
 AVERAGE         Average numeric expressions in the current work area
 CALL*           Execute a C or Assembler procedure
 CANCEL*         Terminate program processing
 CLEAR ALL*      Close files and release public and private variables
 CLEAR GETS      Release Get objects from the current GetList array
 CLEAR MEMORY    Release all public and private variables
 CLEAR SCREEN    Clear the screen and return the cursor home
 CLEAR TYPEAHEAD Empty the keyboard buffer
 CLOSE           Close a specific set of files
 COMMIT          Perform a solid-disk write for all active work areas
 CONTINUE        Resume a pending LOCATE
 COPY FILE       Copy a file to a new file or to a device
 COPY STRUCTURE  Copy the current .dbf structure to a new database (.dbf) file
 COPY STRU EXTE  Copy field definitions to a .dbf file
 COPY TO         Export records to a database (.dbf) file or ASCII text file
 COUNT           Tally records to a variable
 CREATE          Create an empty structure extended (.dbf) file
 CREATE FROM     Create a new .dbf file from a structure extended file
 DELETE          Mark records for deletion
 DELETE FILE     Remove a file from disk
 DELETE TAG      Delete a tag
 DIR*            Display a listing of files from a specified path
 DISPLAY         Display records to the console
 EJECT           Advance the printhead to top of form
 ERASE           Remove a file from disk
 FIND*           Search an index for a specified key value
 GO              Move the pointer to the specified identity
 INDEX           Create an index file
 INPUT*          Enter the result of an expression into a variable
 JOIN            Create a new database file by merging from two work areas
 KEYBOARD        Stuff a string into the keyboard buffer
 LABEL FORM      Display labels to the console
 LIST            List records to the console
 LOCATE          Search sequentially for a record matching a condition
 MENU TO         Execute a lightbar menu for defined PROMPTs
 NOTE*           Place a single-line comment in a program file
 PACK            Remove deleted records from a database file
 QUIT            Terminate program processing
 READ            Activate full-screen editing mode using Get objects
 RECALL          Restore records marked for deletion
 REINDEX         Rebuild open indexes in the current work area
 RELEASE         Delete public and private memory variables
 RENAME          Change the name of a file
 REPLACE         Assign new values to field variables
 REPORT FORM     Display a report to the console
 RESTORE         Retrieve memory variables from a memory (.mem) file
 RESTORE SCREEN* Display a saved screen
 RUN             Execute a DOS command or program
 SAVE            Save variables to a memory (.mem) file
 SAVE SCREEN*    Save the current screen to a buffer or variable
 SEEK            Search an order for a specified key value
 SELECT          Change the current work area
 SET ALTERNATE   Echo console output to a text file
 SET BELL        Toggle sounding of the bell during full-screen operations
 SET CENTURY     Modify the date format to include or omit century digits
 SET COLOR*      Define screen colors
 SET CONFIRM     Toggle required exit key to terminate GETs
 SET CONSOLE     Toggle console display to the screen
 SET CURSOR      Toggle the screen cursor on or off
 SET DATE        Set the date format for input and display
 SET DECIMALS    Set the number of decimal places to be displayed
 SET DEFAULT     Set the CA-Clipper default drive and directory
 SET DELETED     Toggle filtering of deleted records
 SET DELIMITERS  Toggle or define GET delimiters
 SET DESCENDING  Change the descending flag of the controlling order
 SET DEVICE      Direct @...SAYs to the screen or printer
 SET EPOCH       Control the interpretation of dates with no century digits
 SET ESCAPE      Toggle Esc as a READ exit key
 SET EXACT*      Toggle exact matches for character strings
 SET EXCLUSIVE*  Establish shared or exclusive USE of database files
 SET FILTER      Hide records not meeting a condition
 SET FIXED       Toggle fixing of the number of decimal digits displayed
 SET FORMAT*     Activate a format when READ is executed
 SET FUNCTION    Assign a character string to a function key
 SET INDEX       Open one or more order bags in the current work area
 SET INTENSITY   Toggle enhanced display of GETs and PROMPTs
 SET KEY         Assign a procedure invocation to a key
 SET MARGIN      Set the page offset for all printed output
 SET MEMOBLOCK   Change the block size for memo files
 SET MESSAGE     Set the @...PROMPT message line row
 SET OPTIMIZE    Change the setting that optimizes using open orders
 SET ORDER       Select the controlling order
 SET PATH        Specify the CA-Clipper search path for opening files
 SET PRINTER     Toggle echo of output to printer or set the print destination
 SET PROCEDURE*  Compile procedures and functions into the current object file
 SET RELATION    Relate two work areas by a key value or record number
 SET SCOPE       Change the boundaries for scoping keys in controlling order
 SET SCOPEBOTTOM Change bottom boundary for scoping keys in controlling order
 SET SCOPETOP    Change top boundary for scoping keys in controlling order
 SET SCOREBOARD  Toggle the message display from READ or MEMOEDIT()
 SET SOFTSEEK    Toggle relative seeking
 SET TYPEAHEAD   Set the size of the keyboard buffer
 SET UNIQUE*     Toggle inclusion of non-unique keys into an index
 SET WRAP*       Toggle wrapping of the highlight in menus
 SKIP            Move the record pointer to a new position
 SORT            Copy to a database (.dbf) file in sorted order
 STORE*          Assign a value to one or more variables
 SUM             Sum numeric expressions and assign results to variables
 TEXT*           Display a literal block of text
 TOTAL           Summarize records by key value to a database (.dbf) file
 TYPE            Display the contents of a text file
 UNLOCK          Release file/record locks set by the current user
 UPDATE          Update current database file from another database file
 USE             Open an existing database (.dbf) and its associated files
 WAIT*           Suspend program processing until a key is pressed
 ZAP             Remove all records from the current database file