justamistere
Programmer
In VFP 6, I haven't found any inherent IsArray() function like VB has. I am sending a @param1 to either a Procedure/Method, where I want to test to see if it is array or just a single memory variable.
I have something that may work, hopefully in all situations. I was wondering how others have achieved this common test.
I have something that may work, hopefully in all situations. I was wondering how others have achieved this common test.
Code:
*20*********************************************************
* Name: IsArray()
* Author: JXE 2004/10/25
* Description: Determine if a variable is an array.
* Syntax: llIsArray = IsArray(@txValue).
************************************************************
FUNCTION IsArray
LPARAMETERS txMemVar
LOCAL lcOLD_ErrorHandler, ;
lnErrorNumber, ;
llReturnValue
STORE "" TO lcOLD_ErrorHandler
STORE 0 TO lnErrorNumber
STORE .T. TO llReturnValue
lcOLD_ErrorHandler = ON("ERROR")
ON ERROR lnErrorNumber = GetErrorNumber(ERROR())
= ALEN(txMemVar, 1)
***---| "name" is not an array (Error 232)
IF lnErrorNumber = 232
llReturnValue = .F.
ENDIF
ON ERROR &lcOLD_ErrorHandler
RETURN llReturnValue
************************************************************
*21*********************************************************
* Name: GetErrorNumber()
* Author: JXE 2004/10/25
* Description: Returns the VFP error number returned by
* the ERROR() function.
************************************************************
FUNCTION GetErrorNumber
LPARAMETER tnErrorNumber
LOCAL lnErrorNumber
lnErrorNumber = tnErrorNumber
RETURN lnErrorNumber
************************************************************