Type

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.0 (Modified)


Type (fieldVar) Number

ParameterTypeDescription
fieldVarField | VariableField or Variable to be tested
Function resultNumberData type number

Description

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

4th Dimension provides the following predefined constants:

ConstantTypeValue
Is Alpha FieldLong Integer 0
Is String VarLong Integer 24
Is TextLong Integer 2
Is RealLong Integer 1
Is IntegerLong Integer 8
Is LongIntLong Integer 9
Is DateLong Integer 4
Is TimeLong Integer 11
Is BooleanLong Integer 6
Is PictureLong Integer 3
Is SubtableLong Integer 7
Is BLOBLong Integer 30
Is UndefinedLong Integer 5
Is PointerLong Integer 23
String arrayLong Integer 21
Text arrayLong Integer 18
Real arrayLong Integer 14
Integer arrayLong Integer 15
LongInt arrayLong Integer 16
Date arrayLong Integer 17
Boolean arrayLong Integer 22
Picture arrayLong Integer 19
Pointer arrayLong Integer 20
Array 2DLong Integer 13

Compatibility Note: In previous versions of 4D, Type returned 3 (Is Picture) when applied to a Graph variable declared using the command C_GRAPH. Starting with version 6, Type returns 9 (Is LongInt) when applied to a Graph variable.

You can apply Type to fields, interprocess variables, process variables, local variables, and dereferenced pointers referring to these types of objects.

Version 6 Note: Starting with version 6, you can apply Type to parameters ($1,$2..., ${...}), or to project method or function results ($0).

Examples

1. See example for the APPEND TO CLIPBOARD command.

2. See example for DRAG AND DROP PROPERTIES command.

3. 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;Count fields($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 )

See Also

Is a variable, Undefined.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next