Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing a foxpro array from within a VB COM Server
Message
From
17/01/2001 08:07:14
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00464487
Message ID:
00464588
Views:
17
Hi!

If it is not an option, better forget it. You're really trying to hit an impossible! ;)

Think about reference to array as some pointer in the memory. When both objects are in the same memory space, this reference is valid. When objects in the different memory spaces, like COM objects, referense to array might quickly become invalid (usualy it is not true unless COM objects reside in different EXE files or on different computers).

More, VB cannot work with the variables list of VFP, these are completely different applications with different architecture, so you cannot pass variable name in the string from VFP into VB and than use that name to reference variable.

Better do all you want at the client side. For example, make a generic method 'Getarraybyname'. Pass to it array name. Than, in that method call method of COM object to fill temporary array, than copy information from it into the passed array.


>First let me take a moment to thank everyone who has been helping me thus far on my journey! (Randy, Christof, Ed, Mike, etc...) Now I have yet another interesting problem. :)
>
>I am writing a COM Server with VB and tying it to our favorite language, VFP. Inside of a method on my COM server I need to run an ACLASS command.
>Here is a snippet of my code to help illustrate...
>
>>>>> IN VFP <<<<
>PUBLIC ox
>PUBLIC myarray[1] && ALSO tried LOCAL myarray[1]
>
>ox = CREATEOBJECT('form')
>ox.ADDOBJECT('vbcomtest','myocx', 'vbcomtest.ctlvbcomtest')
>loTemp = CREATEOBJECT('Custom')
>?comarray(ox.vbcomtest.object,11)
>? ox.vbcomtest.DoAClass(loTemp, "loTemp", @myarray, "myarray")
>? ALEN(myarray)
>
>DEFINE CLASS myocx AS OLECONTROL
>ENDDEFINE
>
>>>>>> IN VB COM Server <<<<<<
>Public Sub DoAClass(toObject As Variant, tcObject As String, tcaAClass() As Variant, tcArrayName As String, toVFP As Variant)
> Dim lcCommand As String
>>>>> 'Do stuff
>>>>> 'Do stuff
>>>>> 'Do stuff
>
> lcCommand = "? ACLASS(" & tcArrayName & ", " & tcObject & ")"
> Call MsgBox(lcCommand)
> Call CallByName(toVFP, "DoCmd", VbMethod, lcCommand)
>
>>>>> 'Do stuff
>>>>> 'Do stuff
>>>>> 'Do stuff
>End Sub
>
>
>When the CallByName function runs within VB it displays the correct result from the AClass command onto the VFP desktop. (I checked it by running the same string from with VFP). So it appears that AClass is running correctly but it is not sending the results into "myarray"
>
>What I wanted to do was send in a reference to the "myarray" array and its name as a string. In this way I could build a vfp string to execute through the _VFP object reference, and have the array reference I've sent in correctly point to the results.
>
>How can I run AClass within a VB COM Server and get access to the resulting array?
>
>Any help would be greatly appreciated!
>
>-- Chris
>
>PS: Running AClass and sending in the results array to the VB COM Server's method is NOT AN OPTION. :)
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform