User Tools

Site Tools


setnull_set_file_field_null_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== SETNULL (set file field null) ====== Previous pageReturn to chapter overviewNext page

NewC7.jpg

SETNULL(field)

SETNULL(file, field)

blk2blue.jpg

SETNULL Assigns null “value” to a field.
field The label (including prefix) of a field in a FILE structure. This may be a GROUP or RECORD structure.
file The label of a FILE.

The SETNULL statement assigns a null “value” to a field in a FILE structure. If the field is a GROUP or RECORD structure, all component fields are set to null. Support for null “values” in a FILE is entirely dependent upon the file driver. The file must be opened before this statement is applied.

You can now pass a file as the first parameter to SETNULL. This allows you to pass references to fields (see the example below).

Example:

Customer FILE,DRIVER('Clarion'),PRE(Cus) !Declare customer file layout

AcctKey   KEY(Cus:AcctNumber)

Record    RECORD

AcctNumber  LONG

OrderNumber LONG

Name        STRING(20)

Addr        STRING(20)

CSZ         STRING(35)

**          END**

**         END**

Header  FILE,DRIVER('Clarion'),PRE(Hea)  !Declare header file layout

AcctKey  KEY(Hea:AcctNumber)

OrderKey KEY(Hea:OrderNumber)

Record   RECORD

AcctNumber  LONG

OrderNumber LONG

ShipToName  STRING(20)

ShipToAddr  STRING(20)

ShipToCSZ   STRING(35)

**         END**

**        END**

** CODE**

** OPEN(Header)**

** OPEN(Customer)**

** SET(Hea:AcctKey)**

** LOOP**

**  NEXT(Header)**

**   IF ERRORCODE()**

**    BREAK**

**   END**

**   Cus:AcctNumber = Hea:AcctNumber**

**   GET(Customer,Cus:AcctKey)                                  !Get Customer record**

**   IF ERRORCODE()**

**    CLEAR(Cus:Record)**

**   END**

**   IF NOT NULL(Hea:ShipToName) AND Hea:ShipToName = Cus:Name  !Check ship-to address**

**   **SETNULL(Hea:ShipToName)                                    !and assign null “values”

**   **SETNULL(Hea:ShipToAddr)                                    ! to ship-to address

**   **SETNULL(Hea:ShipToCSZ)

**  END**

**  PUT(Header)                                                 !Put Header record back**

** END**

!Example Two ' Use of file parameter

SwapNullState PROCEDURE(File F, ANY var)

**  CODE**

**    IF **NULL(f, var)

**      SETNONULL(f, var)**

**    ELSE**

**     **SETNULL(f, var)

**    END**

See Also:

NULL

SETNONNULL

GETNULLS

SETNULLS

setnull_set_file_field_null_.htm.txt · Last modified: by 127.0.0.1