Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How determine if variable is an array
Message
From
21/07/2000 13:38:02
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00395400
Message ID:
00395574
Views:
9
Hi Nadya,

I'm glad you found it useful, thanks for the quotation and for posting your code. I can see where it could be helpful to have the function return the number of elements in the array, as your does.

Rick

>Hi Rick,
>
>I found the function IsArray in our library, but I've just changed it to use your idea instead on on error route.
>
>*  Author............: Paul D. Wilcox
>*  Project...........: WIS Common Utility
>*  Created...........: Warren Information Services, Inc. - 01/01/98
>*  Copyright.........: (c) 1998 The Warren Group
>*  Description.......: ISARRAY.PRG
>*                    :    Function evaluates whether  is an array.
>*                    :    If so, returns the number of elements unless it is 
>*                    :    the identity array (a single empty element array) 
>*                    :    when it returns 0.  Returns - 1 if it is not an array.
>*  Called by.........: 
>*  Calling Samples...: lbarray = isarray(@atest) >= 0 && Be sure to pass  by reference!
>*  Parameter List....: paArray
>*  Procs & Fncts.....: 
>*    External........: 
>*    Internal........: 
>*  Data..............: 
>*  Major change list.:  - //
>*  New idea..........: Rick Borup rborup@prairienet.or
>*  Changed by        : Nadya Nosonovsky 07/21/2000 01:12:19 PM
>***************************************************************
>lparameter paArray
>local lnReturn, lnElements
>external array paArray
>if type("paArray[1]")="U" && paArray is not array
>    lnReturn=-1
>else
>    lnElements=alen(paArray)
>    if lnElements = 1 and empty(paArray[1])
>         lnReturn=0
>     else
>         lnReturn=lnElements
>     endif
>endif
>return lnReturn
>*!*     lcerror = "on error "+ on("error")
>
>*!*     on error lberr232 = atest(error())
>
>*!*     lnelements = alen(paArray)
>
>*!*     &lcerror
>
>*!*     if lberr232
>*!*       return - 1
>*!*     endif
>
>*!*     return iif(lnelements = 1 and isempty(paArray[1]), 0, lnelements)
>
>*!*     function atest
>*!*     lparameter pnerror
>*!*     return pnerror = 232 && '' is not an array.
>
>*!*     function isempty
>*!*     lparameter puvalue
>*!*     return empty(puvalue) or isnull(puvalue)
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Previous
Reply
Map
View

Click here to load this message in the networking platform