User Tools

Site Tools


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

NewC7.jpg

SETNONULL(field)

SETNONULL(file, field)

blk2blue.jpg

SETNONULL Assigns non-null value (blank or zero) 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 SETNONULL statement assigns a non-null value (blank or zero) to a field in a FILE structure. If the field is a GROUP or RECORD structure, all component fields are set non-null. Support for null “values” in a FILE is entirely dependent upon the file driver.

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

Return Data Type:     LONG

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)

           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)

          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 NULL(Hea:ShipToName) OR Hea:ShipToName = Cus:Name  !Check same ship-to address

  Hea:ShipToName = 'Same as Customer Address'          !flag the record

  SETNONULL(Hea:ShipToAddr)                            !and blank out ship-to address

  SETNONULL(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

SETNULL

SETNULLS

GETNULLS

setnonull_set_file_field_non_null_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1