Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pass Vfp Object to a DCOM server ?
Message
From
11/08/2000 20:18:58
Eric Barnett
Barnett Solutions Group, Inc
Sonoma, California, United States
 
 
To
01/08/2000 15:59:03
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00399459
Message ID:
00404249
Views:
17
You can't use AddProperty with COM. The reason I believe is because the type library and interface are defined when you build the DLL (see VTABLE, early & late binding, don't want to get into that unless I have to). Conversely, in your scenario, the properties that you added don't seem to be included in the COM representation of your object when you pass it over DCOM as properties added with AddProperty do not seem to be recognized as part of the object's interface.

I am sure that if you do the following:

DEFINE CLASS myParameterClass AS Custom
Param1=.NULL.
Param2=.NULL.
ENDDEFINE

oParam = CreateObject("myParameterClass")
oParam.Addproperty("Param1",0)
oParam.Addproperty("Param2","Allo")

x = CreateObjectEx("MyDcom.Main")
x.MyFunction(oParam)

It will work as intended. If you need to be able to create variables named & set dynamically, I would suggest using an array to store named value pairs, with getparam() and setparam() methods, i.e.

DEFINE CLASS myParameterClass AS Custom
DIMENSION aParameters(1,2)
FUNCTION setparam
LPARAMETERS cName,uValue
LOCAL nCounter,lExists
IF VARTYPE(aParameters(1,1))="L"
lExists=.F.
ELSE
lExists=.F.
FOR nCounter=1 TO ALEN(aParameters,1)
IF UPPER(cName)==aParameters(nCounter,1)
lExists=.T.
EXIT
ENDIF
ENDFOR
ENDIF
IF !lExists
IF VARTYPE(aParameters(1,1))="L"
aParameters(1,1)=UPPER(cName)
aParameters(1,2)=uValue
ELSE
DIMENSION aParameters(ALEN(aParameters,1)+1,2)
aParameters(ALEN(aParameters,1),1)=UPPER(cName)
aParameters(ALEN(aParameters,1),2)=uValue
ENDIF
ELSE
aParameters(nCounter,1)=UPPER(cName)
aParameters(nCounter,2)=uValue
ENDIF
ENDFUNC
FUNCTION getparam
LPARAMETERS cName
LOCAL nCounter,uRetVal
uRetVal=.NULL.
FOR nCounter=1 TO ALEN(aParameters,1)
IF UPPER(cName)==aParameters(nCounter,1)
uRetVal=aParameters(nCounter,2)
EXIT
ENDIF
ENDFOR
RETURN uRetVal
ENDFUNC
ENDDEFINE

(I just wrote this as an example in a hurry, I don't have time to test it right now so there might be an error, but hopefully you'll get the jist).

Then you could say,

oParam = CreateObject("myParameterClass")
oParam.setparam("Param1",0)
oParam.setparam("Param2","Allo")

x = CreateObjectEx("MyDcom.Main")
x.MyFunction(oParam)

And the class Main in projet MyDcom would just have to know how to call

oParam.getparam("Param1")

for example.

Hope this is helpful.








>>Hi All,
>>
>>I'm Trying to Pass a Vfp Object to a Dcom application as a parameter.
>>It receives the object well but i can't get values from it's property ?
>>
>>Ex:
>>
>>oParam = CreateObject("Custom")
>>oParam.Addproperty("Param1",0)
>>oParam.Addproperty("Param2","Allo")
>>
>>x = CreateObjectEx("MyDcom.Main")
>>? x.MyFunction(oParam)
>>
>>
>>*******************************
>>MyFunction
>>*******************************
>>Lparameters toParam
>>Local llRet
>>llRet = .F.
>>IF VARTYPE("toParam") = "O"
>> IF toParam.Param1 = 0 and !Empty(toParam.Param2)
>> llRet = .T.
>> ENDIF
>>ENDIF
>>RETURN llRet
>Hate to ask that but is MyFunction a method of main class? Also what if you change "main" to other name?
>Mark
Eric Shaneson
Cutting Edge Consulting
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform