4D v13.4

Type

Home

 
4D v13.4
Type

Type 


 

Type ( fieldVar ) -> Function result 
Parameter Type   Description
fieldVar  Field, Variable in Field or Variable to be tested
Function result  Longint in Data type number

The Type command returns a numeric value that denotes the type of the field or variable you pass as fieldVar.

4D provides the following predefined constants:

Constant Type Value
Array 2D Longint 13
Boolean array Longint 22
Date array Longint 17
Integer array Longint 15
Is Alpha Field Longint 0
Is BLOB Longint 30
Is Boolean Longint 6
Is Date Longint 4
Is Float Longint 35
Is Integer Longint 8
Is Integer 64 bits Longint 25
Is LongInt Longint 9
Is Picture Longint 3
Is Pointer Longint 23
Is Real Longint 1
Is String Var Longint 24
Is Subtable Longint 7
Is Text Longint 2
Is Time Longint 11
Is Undefined Longint 5
LongInt array Longint 16
Picture array Longint 19
Pointer array Longint 20
Real array Longint 14
String array Longint 21
Text array Longint 18

Notes:

  • Type returns 9 (Is LongInt) when applied to a Graph variable.
  • Beginning with version 11 of 4D, Type returns the actual type of an array when it is applied to a "row" of a 2D array, rather than Array 2D as before (see example 4).
  • Beginning with version 11 of 4D, Type returns the type Is Text or Text array when it is applied, respectively, to an Alpha variable or an Alpha array (starting with this version, there is no difference between an Alpha variable and a Text variable).

You can apply Type to fields, interprocess variables, process variables, local variables, and dereferenced pointers referring to these types of objects.You can apply Type to parameters ($1,$2..., ${...}), or to project method or function results ($0).

See example for the APPEND DATA TO PASTEBOARD command.

See example for DRAG AND DROP PROPERTIES command.

The following project method empties some or all of the fields for the current record of the table whose a pointer is passed as parameter. It does this without deleting or changing the current record:

  ` EMPTY RECORD Project Method
  ` EMPTY RECORD ( Pointer {; Long } )
  ` EMPTY RECORD ( -> [Table] { ; Type Flags } )
 
 C_POINTER($1)
 C_LONGINT($2;$vlTypeFlags)
 
 If(Count parameters>=2)
    $vlTypeFlags:=$2
 Else
    $vlTypeFlags:=0xFFFFFFFF
 End if
 For($vlField;1;Get last field number($1))
    $vpField:=Field(Table($1);$vlField)
    $vlFieldType:=Type($vpField->)
    If($vlTypeFlags ??$vlFieldType )
       Case of
          :(($vlFieldType=Is Alpha Field)|($vlFieldType=Is Text))
             $vpField->:=""
          :(($vlFieldType=Is Real)|($vlFieldType=Is Integer)|($vlFieldType=Is LongInt))
             $vpField->:=0
          :($vlFieldType=Is Date)
             $vpField->:=!00/00/00!
          :($vlFieldType=Is Time)
             $vpField->:=?00:00:00?
          :($vlFieldType=Is Boolean)
             $vpField->:=False
          :($vlFieldType=Is Picture)
             C_PICTURE($vgEmptyPicture)
             $vpField->:=$vgEmptyPicture
          :($vlFieldType=Is Subtable)
             Repeat
                ALL SUBRECORDS($vpField->)
                DELETE SUBRECORD($vpField->)
             Until(Records in subselection($vpField->)=0)
          :($vlFieldType=Is BLOB)
             SET BLOB SIZE($vpField->;0)
       End case
    End if
 End for


After this project method is implemented in your database, you can write:

  ` Empty the whole current record of the table [Things To Do]
 EMPTY RECORD(->[Things To Do])
 
  ` Empty Text, BLOB and Picture fields for the current record of the table [Things To Do]
 EMPTY RECORD(->[Things To Do];0?+Is Text?+Is BLOB?+Is Picture)
 
  ` Empty the whole current record of the table [Things To Do] except Alphanumeric fields
 EMPTY RECORD(->[Things To Do];-1?-Is Alpha Field)

In certain cases, for example when writing generic code, you may need to find out whether an array is a standard independent array or the “row” of a 2D array. In this case, you can use the following code:

 ptrmyArr:=->myArr{6} ` Is myArr{6} the row of a 2D array?
 RESOLVE POINTER(ptrmyArr;varName;tableNum;fieldNum)
 If(varName#"")
    $ptr:=Get pointer(varName)
    $thetype:=Type($ptr->)
  ` If myArr{6} is the row of a 2D array, $thetype equals 13
 End if

 
PROPERTIES 

Product: 4D
Theme: Language
Number: 295

 
INDEX

Alphabetical list of commands

 
HISTORY 

Modified: 4D v11 SQL

 
SEE ALSO 

Is a variable
Undefined