At 08:12 PM 5/8/2008 +0100, Alan Bourke wrote:
>On Thu, 8 May 2008 14:42:51 -0400, "David Crooks" <[EMAIL PROTECTED]>
>said:
> > Could I pass a
> > >structure or record with all my parameters in it?
>
>Nearest you'll get is an array or a collection. We don't got structs,
>and tables, records and the like aren't objects.
If you have the info in a table, SCATTER MEMO NAME .... will give you an
object with all the properties.
But if the parms are not in a table where that is possible, you could
'construct' an object with a property for each variable that needs passed.
Something like this:
*--------------------------------------
oParmObj = CreateMeSpecObject("parm1, myname2, another_variable_name3.....
parm30")
oParmObj.parm1 = 75
oParmObj.myname2 = gcPassedName
oParmObj.another_variable_name3 = oWeb.forms[1].account
...
oParmObj.parm30 = DATE()
*-- Make the call to the function that needs all the parms
=Servicecall(oParmObj)
.....
*-- Put this in some general utility PRG, or make it a method of an
application class, etc
FUNCTION CreateMeSpecObject
Parameters cStringofVariableNames
LOCAL nI, nItems, oTemp
nItems = ALINES(_aprop, cStringofVariableNames, .T., ',')
oTemp = NEWOBJECT('CUSTOM')
FOR nI = 1 TO nItems
oTemp.AddProperty(_aProp[nI])
ENDFOR
RETURN oTemp
*--------------------------------------
The above assumes you have control over the parameters received by the
function "Servicecall()". In that function you would have to modify the
parameter list to accecpt the single parameter - oParmObj - and then access
the various properties to get the values. For example, the first few lines
of "ServiceCall()" might look like:
*-- Function/Method: ServiceCall
PARAMETERS oParms
LOCAL nVal1, nSpecX, cNameOf, cTired, dAgain.....
nVal1 = oParms.parm1
nSpecX = oParms.another_variable_name3
cNameOf = oParms.myname2
dAgain = oParms.parm30
..... (and so on)
Of course, you do not have to reassign the values from oParms to local
variables. You could just use them directly. But if the code
(ServiceCall()) has hundreds or thousands of lines of code, it may be
easier to let the code keep using those variables and just set them up at
the top of the function/method.
If you didn't write ServiceCall(), then I don't think you can use this
approach (because ServiceCall has to be able to be changed to just receive
1 parameter and then work with the properties of that object from there).
HTH,
-Charlie
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.