KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method to determine if variable is an array
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac & Win
Published On: December 2, 2016

Below is an utility method that takes a pointer to a variable and returns True if the variable is an array, else False.

// Method: UTIL_IS_ARR
// Parameters:
// $1 - Pointer to variable
// Return:
// $0 - True if array, else False

C_POINTER($1;$var)
C_BOOLEAN($0;$isArr)
C_LONGINT($type)

$var:=$1

$type:=Type($var->)
$isArr:=False
If ($type=LongInt array) | ($type=Object array) | ($type=Picture array) \
   | ($type=Pointer array) | ($type=Real array) | ($type=String array) \
   | ($type=Text array) | ($type=Time array) | ($type=Blob array) \
   | ($type=Boolean array) | ($type=Date array) | ($type=Integer array)\
   | ($type=Array 2D)
   $isArr:=True
End if
$0:=$isArr

Below are a examples of using the utility method:

ARRAY TEXT($arrText;0)
$isArr:=UTIL_IS_ARR(->$arrText)
// $isArr returns True

C_TEXT($text)
$isArr:=UTIL_IS_ARR(->$text)
// $isArr returns False