Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How determine if variable is an array
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00395400
Message ID:
00395565
Vues:
8
>Thanks for the suggestion, Nick. I'll do that.
>
>>Hi Rick,
>>
>>You may want to add this function to UT FAQ section.

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 <paArray> 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 <atest> 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 && '<sys(2018)>' is not an array.

*!*     function isempty
*!*     lparameter puvalue
*!*     return empty(puvalue) or isnull(puvalue)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform