Re: Returning the var type based on content of object
- Posted by DerekParnell (admin) May 13, 2009
- 857 views
znorq2 said...
Hi,
I created the following function;
I suggest you actually benchmark this before deciding which is faster.
------------------------------------------------------------------------------------------------ global function fVarType(object oObject) -->> cGA08, uGA08 ------------------------------------------------------------------------------------------------ -->> Purpose: Return A, N, F or E depending on the oObject content; -->> 'A'tom -->> 'N'ested sequence (Array) -->> 'F'lat sequence (May be considered as a string) -->> 'E'mpty sequence -->> ========================================================================================= -->> GA08; Created. -->> ========================================================================================= -- atom xType -- -- if atom(oObject) then return 'A' end if if length(oObject) = 0 then return 'E' end if -- if sequence(oObject[1]) -- Most nested sequences nest on the 1st element. then return 'N' end if for cnt = 2 to length(oObject) do if sequence(oObject[cnt]) then return 'N' end if end for -- return 'F' -- end function