Core Function GetVarType

From Sputnik Wiki
Revision as of 12:37, 14 June 2015 by UberFoX (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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
{
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox