Core Function GetVarType
From Sputnik Wiki
(Difference between revisions)
(→Example) |
m (1 revision) |
||
(4 intermediate revisions by one user not shown) | |||
Line 17: | Line 17: | ||
Returns the common type of a variable as a numeric value types are: | Returns the common type of a variable as a numeric value types are: | ||
<pre> | <pre> | ||
− | + | [TYPE] [@MACRO] | |
− | + | NULL @typeNULL | |
− | + | BOOL @typeBOOL | |
− | + | CHAR @typeCHAR | |
− | + | BYTE @typeBYTE | |
− | + | SBYTE @typeSBYTE | |
− | + | INT16 @typeINT16 | |
− | + | INT32 @typeINT32 | |
− | + | INT64 @typeINT64 | |
− | + | UINT16 @typeUINT16 | |
− | + | UINT32 @typeUINT32 | |
− | + | UINT64 @typeUINT64 | |
− | + | FLOAT @typeFLOAT | |
− | + | DOUBLE @typeDOUBLE | |
− | + | STRING @typeSTRING | |
− | + | BINARY @typeBINARY | |
− | + | INTPTR @typeINTPTR | |
− | + | UINTPTR @typeUINTPTR | |
− | + | REFERENCE @typeREFERENCE | |
+ | ARRAY @typeARRAY | ||
+ | OBJECT @typeOBJECT | ||
+ | ERROR @typeERROR | ||
</pre> | </pre> | ||
Line 45: | Line 48: | ||
Checking as numeric | Checking as numeric | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Checking using @ Macro of the numeric | Checking using @ Macro of the numeric |
Latest revision as of 12:37, 14 June 2015
GetVarType( $variable )
Contents |
Description
Get the common type of a variable
Parameters
variable
The variable to check.
Return Value
Returns the common type of a variable as a numeric value types are:
[TYPE] [@MACRO] NULL @typeNULL BOOL @typeBOOL CHAR @typeCHAR BYTE @typeBYTE SBYTE @typeSBYTE INT16 @typeINT16 INT32 @typeINT32 INT64 @typeINT64 UINT16 @typeUINT16 UINT32 @typeUINT32 UINT64 @typeUINT64 FLOAT @typeFLOAT DOUBLE @typeDOUBLE STRING @typeSTRING BINARY @typeBINARY INTPTR @typeINTPTR UINTPTR @typeUINTPTR REFERENCE @typeREFERENCE ARRAY @typeARRAY OBJECT @typeOBJECT ERROR @typeERROR
Remarks
None.
Example
Checking as numeric
Checking using @ Macro of the numeric
$a = "My value"; if( GetVarType($a) == @TypeDouble) // Double { } switch( GetVarType($a) ) { case @TypeUInt64: // UInt64 { } break; case @TypeDouble: // Double { } break; }
Some other ways to test a variables type
if( $a Is Double) // $a is a Double { } if( $a IsNot Double) // $a is NOT a Double { } if( $a ~~ Double) // $a is a Double { } if( $a !~ Double) // $a is NOT a Double { }