| **Navigation:**  [[introduction.htm|Language Reference]] > 13 - Built-in Functions >====== SETNULL (set file field null) ====== | [[setnonull set file field non null .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[setnulls set the null state of columns .htm|{{btn_next_n.gif|Next page}}]] | | || {{newc7.jpg|NewC7.jpg}} **SETNULL(**//field//**)** **SETNULL(**//file, field//**)** {{blk2blue.jpg|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 return null file field .htm|NULL]] [[setnonull set file field non null .htm|SETNONNULL]] [[getnulls get the null state of a table .htm|GETNULLS]] [[setnulls set the null state of columns .htm|SETNULLS]]