Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parameter passing
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00575264
Message ID:
00575278
Vues:
27
This message has been marked as the solution to the initial question of the thread.
Than you will have to define as many parameters as there can be but no more than 27 (VFP limit).

>I am avoiding this, since I have to create a long array before I can use it.
>In a way what i am looking to do is to make it easier to make an array <g>.
>
>>You can pass an array as parameter (by reference)
DIMENSION mar[3]
>>mar[1] = 1
>>mar[2] = 2
>>mar[3] = 3
>>
>>avg=calcAverage(@mar)
>>
>>function calcAverage(taMar)
>>EXTERNAL ARRAY taMar
>>local n,v,i
>>n=ALEN(taMar)
>>v = 0
>>for i=1 to n
>>  v=v + tamar(i)
>>next
>>return v/n
>>
>>
>>>Can anyone suggest a way to pass a variable number of parameters to a method or function where the maximum number is not known in advance?
>>>
>>>E.g. Foxpro pseudocode below:
>>>
>>>function calcAverage()
>>>local n,v,i
>>>n=pcount()
>>>for i=1 to n
>>> v=v+parameter(i)
>>>next
>>>return v/n
>>>
>>>avg=calcAverage(1,2,3,4,5,6,7)
>>>
>>>I know that you can declare a maximum number of parameters. But what if I dont know in advance? Should I declare 10 parameters and do the following
>>>
>>>function calcAverage(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
>>>local n,v,i,sp
>>>n=pcount()
>>>v=0
>>>for i=1 to n
>>> sp='p'+ltrim(str(i,2))
>>> v=v+&sp
>>>next
>>>return v/n
>>>
>>>
>>>Costas
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform