Hi Robert,

You can call one sub and one function inside your MapBasic app directly from VB 
using OLE. Both take a text string as argument. In
OLE these are the Do method and the Eval function in the MBApplication object, 
which in your MB app corresponds to the
RemoteMsgHandler sub and RemoteQueryHandler function.

You can also from VB read and write all variables declared in the MB app as 
Global's. These are accessed thru the MBGlobals
collection in OLE.

-

In your code, you call  the DO method on the Application object, which is the 
same as running the provided command in the MB window.

And even if you'd used the MBApplication object, your example tries to call the 
missing RemoteMsgHandler sub with a text string
"Call action(1)" as argument.

-

If it's a single value you're transferring, I would just transfer it as a text 
from VB, i.e.

    set oMBObject = oMIObject.MBApplications(sMapBasicProgram)
    oMBObject.Do Str(iGPSFileID)

and have the mb app's RemoteMsgHandler issue this call

    Call Action(Val(CommandInfo(CMD_INFO_MSG)))

If you're transferring mutiple values, define them as Global in mb, poke the 
values from VB using the MBGlobals collection, and call
the RemoteMsgHandler with an empty argument, letting it pick up the values from 
the Global variables.

Best regards/Med venlig hilsen
Lars V. Nielsen
GisPro, Denmark
http://www.gispro.dk/

----- Original Message ----- 
From: "Robert Crossley" <[EMAIL PROTECTED]>
To: "MapInfo List" <[email protected]>
Sent: Tuesday, June 21, 2005 4:02 PM
Subject: MI-L setting a variable value in integrated mapping.


Hi all,

I know that this has been covered before - almost, and I have been reading
(and even answering this very question), but I can't seem to find an easy
answer for the question:

I want to run a sub routine in a mapbasic app that runs using values for
variables that I pass to it from vb.

An example fo the Mapbasic program:

Include "MapBasic.def"
Declare Sub Main
Declare Sub Action(ByVal iGPSFileID as Integer)
Sub Main

End Sub

Sub Action(ByVal iGPSFileID as Integer)
Note iGPSFileID
End Sub


And the vb code:

Set oMIObject = CreateObject("MapInfo.Application")
oMIObject.Do "Set Application WIndow " & iMainFormHwnd ' MainForm.hWnd
If Err > 0 Then
     Call AddTrace(lvlError, "Could not start MapInfo for:")
Else
     On Error Resume Next
     oMIObject.Do "Set Window Message Show Position (0,0) Width 10 Units
""cm"" Parent  " & iMainFormHwnd
     oMIObject.Do "Run Application " & gDquote(sMapBasicAppDir &
sMapBasicProgram)
     oMIObject.Do "Call action(1)"


There has been some discussion on this before, but I did not see an
elegant solution, except perhaps an external DDE which I haven't been able
to find again.  Google seems to have failed me on this one.

I have written to an ini file before and this works OK, but I thought i
should try something smarter if I could.

Can I use DDE poke to put it in?

Am going to bed now so won't reply for a while.

R
-- 
________________________________________________

Robert Crossley

Agtrix P/L
9 Short St
PO Box 63
New Brighton 2483
Far Southern Queensland
AUSTRALIA

153.549004 E 28.517344 S

P: 02 6680 1309
F: 02 6680 5214
M: 0419 718 642
E: [EMAIL PROTECTED]
W: www.agtrix.com
W: www.wotzhere.com
skype: robertcrossley

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 16860



---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 16878

Reply via email to