Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
From VB to VFP
Message
 
 
À
14/12/2001 22:13:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00594726
Message ID:
00595122
Vues:
27
In this sample you have to use VBScript (VB code) to pass a variable by reference.
Either way I'm also very wondered why you do not get a result.

BTW, I just made a very simple test and was wondered WHERE is a problem. I just made a very simple VB COM object DLL with following code:
Option Explicit

Sub ttt(ByRef ttt As String)
  ttt = "He-He"
End Sub

Sub ttt2(ByRef ttt As Variant)
  ttt = "He-He"
End Sub
Then I tested it under VFP in command window - it works when you pass a string to VB object by reference. THe test was following:

oo = createobject("tttt.ttt")
rr = "aa"
oo.ttt(@rr)
? rr && DISPLAYS "He-he" on the screen

I tested both methods ttt and ttt2 - both return correct result. I also registered that component under MTS and tested again - it works through DCOM too.

VB and VFP COM objects could be very well combined, as far as I know.

Accordingly to all above, your code should look like following:
LOCAL loEClient
LOCAL lcResponseCode
<b>lcResponseCode = "EMPTY"</b>
loEClient=CREATEOBJECT('MyObject')
loEClient.GetResponseCode(<b>@</b>lcResponseCode)
? 'Response Code: ' + lcResponseCode
>>>>Any difference if you pass the parameter BY REFERENCE?
>>>
>>>I also tried that. It didn't help.
>>
>>Try
LOCAL loEClient
>>LOCAL lcResponseCode
>><b>lcResponseCode = REPLICATE(CHR(0), 255)</b>
>>loEClient=CREATEOBJECT('MyObject')
>><b>loEClient.GetResponseCode(@lcResponseCode)</b>
>>? 'Response Code: ' + lcResponseCode
>>
>
>I finally found some documentation about that point. Basically, JScript has the same problem. Those methods will return an empty string as JScript doesn't support in and out (i.e., by reference) arguments with COM objects. So, this is probably the situation we are facing here with Visual FoxPro.
>
>There documentation gives a workaround. However, I'm not sure how I can translate that in Visual FoxPro.
>
>
>The sample code shows how most of the work can be done with JScript but
>when it comes time to retrieve the Get method results from the COM object,
>the JScript code must pass the object to a VBScript function
>that does the GETs and then returns the results back to the JScript via a
>VBArray which is supported by JScript. For example,
>
>//Start JScript
>....
>oEClient = new ActiveXObject("My object");
>....
>//Do Sets...
>....
>VBarray = new VBArray(VBdoTransaction(oEClient));
>Jarray = VBarray.toArray();
>
>....
>
>//End JScript
>
>< SCRIPT LANGUAGE="VBScript" RUNAT=SERVER>
>option explicit
>
>Function VBdoTransaction(oEClient)
>Dim vbArray(10)
>Dim vbrc
>.
>.
>.
>
>VBdoTransaction = vbArray
>
>End Function
>< /SCRIPT>
>
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform