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
> 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