xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

APPEND BLANK

Creates a new record in the current work area.

Syntax

APPEND BLANK

Description

The APPEND BLANK command creates a new record for the database file open in the current work area and moves the record pointer to the new record. All fields of the record are filled with empty data of the corresponding field data types. That is: Character fields are filled with blank spaces, Date fields contain CtoD(""), logical fields contain .F. (false), Memo fields contain nothing and Numeric fields contain 0.

Shared file access:  When the database is opened in SHARED mode, the APPEND BLANK command attempts to lock the ghost record before appending a new record to the file (the ghost record is the one located at LastRec()+1). If this record lock fails, function NetErr() is set to .T. (true) and no record is appended. When the record lock succeeds, it remains active until a new APPEND BLANK command is issued or the lock is explicitely released with the UNLOCK command. A file lock obtained with the FLock() function is not released by the APPEND BLANK command.

Note:  APPEND BLANK works only in the current work area. Its functional equivalent is the DbAppend() function which can create a new record in other work areas when used in an aliased expression.

Info

See also:APPEND FROM, DbAppend(), FLock(), Neterr(), RLock(), USE
Category: Database commands
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The examples demonstrates a basic technique for creating a new record
// in a shared database:

   PROCEDURE Main
      LOCAL cFirstName := Space(40)
      LOCAL cLastName  := Space(50)

      USE Address ALIAS Addr SHARED NEW
      IF .NOT. NetErr()
         SET INDEX TO AddressA, AddressB
      ENDIF

      CLS
      @ 10,5 SAY "Enter first name:" GET cFirstName
      @ 11,5 SAY "Enter last name :" GET cLastName
      READ

      IF .NOT. Empty( cFirstName + cLastName )
         APPEND BLANK
         IF NetErr()
            ? "Unable to create new record"
         ELSE
            REPLACE addr->FirstName WITH cFirstName  , ;
                    addr->LastName  WITH cLastName
         ENDIF
      ENDIF

      USE
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe