Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check the type of a parameter
Message
De
17/05/2001 19:11:02
Fausto Garcia
Independent Developer
Lima, Pérou
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00508539
Message ID:
00508547
Vues:
17
Hi Shane,

Here is some code that does what you need:
PROCEDURE cMyFunc
PARAMETERS uMyVar
LOCAL cReturnValue
IF TYPE("uMyVar")="C" THEN
   IF TYPE("&uMyVar")="U" THEN
      *Means that the parameter came with a string
      *which has an <b>U</b>ndefined "inner" value,
      *so we consider it a simple string ("C")
      cReturnValue="C"
   ELSE
      *Here there is inner value!
      cReturnValue = TYPE("&uMyVar")
   ENDIF
ELSE
   cReturnValue = TYPE("uMyVar")
ENDIF
RETURN cReturnValue
ENDPROC
Hope this helps to solve your problem!


>I need a procedure that will accept one parameter. This parameter may contain the value I want or it may contain the name of a variable that contains the value that I want. Here are some examples.
>
>PROCEDURE cMyFunc( uMyVar )
>... What code goes here?
>RETURN cReturnValue
>ENDPROC
>
>x = "test"
>cMyFunc( x ) should return 'C'
>
>x = 5
>cMyFunc( x ) should return 'N'
>
>x = "5"
>cMyFunc( x ) should return 'C'
>
>x = .T.
>y = "x"
>cMyFunc( y ) should return 'L'
>
>How do I figure out if a character parameter contains the name of another variable?
>
>Any ideas?
Solo se que nada se

Fausto J. Garcia Pino - MCSD.NET
.NET, Oracle, Tronador & Fondismo!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform