Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing optional array
Message
De
15/08/2019 05:02:38
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01670069
Message ID:
01670094
Vues:
98
IMHO it is better to pass an object. An object doesn't need to be declared as external (sometimes doesn't work for whatever reason I don't understand), it can carry any number of parameters as properties which could be other object, array etc types. You can, say, pass a table as an object if you like to. You can pass null as you wish, just keep in mind object parameters are always passed by reference (proc can change its values). ie:
CLEAR
Select * From (_samples+'data\Customer') Into Cursor crsMyData nofilter

Local loData, ix
loData = Createobject('Empty')
AddProperty(m.loData, 'Data['+Ltrim(Str(Reccount('crsMyData')))+']')
AddProperty(m.loData, 'Rows', Reccount('crsMyData'))

Select crsMyData
Scan
	Scatter Name m.loData.Data[RECNO()]
Endscan
CLOSE DATABASES all
? m.loData.Data[1].Company
CheckData(m.loData)
? m.loData.Data[1].Company
Checkdata(null)

Procedure CheckData(toData)
	If !Isnull(m.toData)
		If (m.toData.Rows > 0)
			m.toData.Data[1].Company = "Replaced in proc"
		Endif
	Else
		? 'Null value passed'
	Endif
Endproc
>Hi,
>
>I want to add an array parameter to a method. I know that I have to include, on the following line, the expression:
>
>External Array aMyArray
>
>
>Since it is optional, can I set the value of this parameter to NULL if nothing is passed? For example, to include the following code:
>
>if pcount() < 3 && or whatever number
>   aMyArray = NULL
>endif
>
>
>Or there is a preferred (better practice) method? The only other way I see is to set a variable within the method that would have the value True or False, depending if the parameter was passed.
>
>TIA
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform