Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Pass Parameters to Init with CreateObject
Message
From
07/12/2006 01:51:22
 
 
To
07/12/2006 01:05:08
Donald Lowrey
Data Technology Corporation
Las Vegas, Nevada, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01175496
Message ID:
01175502
Views:
6
COM does not support passing parameters to the Init method. You'll have to instantiate the object, then pass the parameters to another method. Many people call it Initialize or something similar.

>Passing params to an object created from a prg file works fine, but when passing to an exe, I get a "data type mismatch" error.
>
>I know that params with CreateObject will automatically be passed to the Init() event of that class. In example #2, a COM exe, the data type mismatch error occurs when the Init Event fires. I thought at first that this is a value by reference vs. value type issue, but I seem to be stuck. Your thoughts are appreciated.
>
># 1 Object created from prg where test is a class defined as Custom (or Session, if you prefer) OlePublic.
>
>SET PROCEDURE TO oMyObj ADDITIVE
>oMyObj = CREATEOBJECT("test", 1, .t. , "Hello World")
>
>
># 2 Now, with the prg file compiled as an exe, named "testexe"
>
>oMyObj = CREATEOBJECT("testexe.test", 1, .t. , "Hello World")
>
>
>The Init() method in class "test" is the same in both examples.
>
>FUNCTION INIT
>LPARAMETERS nVal, lBool, cStr
>..do something
>ENDFUNC
>
>
>Thanks for taking a look.
>
>Don Lowrey
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform