You have asked almost the same question before:
http://groups.google.com/group/mapinfo-l/browse_frm/thread/216390bfeab56881
I also think you need this kind of code instead just doing x1=CMD_INFO_X
x1 = mapinfo.eval "CommandInfo(CMD_INFO_X)"
As an alternative you can also run everything through "mapinfo.do "
commands.
Regards
Uffe Kousgaard
Dim x1, y1, msg As String
x1 = "mapinfo.Eval CommandInfo(CMD_INFO_X)"
y1 = "mapinfo.Eval CommandInfo(CMD_INFO_Y)"
msg = "Insert into gps_temp (Latitude, Longitude, obj) values (x1, y1, CreatePoint(x1,y1))"
mapinfo.do "Set Style Symbol MakeSymbol (35, 255, 18)"
mapinfo.RunMenuCommand 1711
mapinfo.do (msg)
And I still get the same error. Sorry - bit confused by this one!
Steven,
x1 = mapinfo.eval "CommandInfo(CMD_INFO_X)"
Regards
Uffe Kousgaard
Visit Parkes on the web at http://www.parkes.nsw.gov.au.
-----------------------------------------------------------------------
ATTENTION: This e-mail is privileged and confidential. If you are not
the intended recipient please delete the message and notify the sender.
Any views or opinions presented are solely those of the author.
-----------------------------------------------------------------------
Putting DIMs into MapInfo results in code that can not be debugged easy
Set up a Global VB file with the MapBasic.DEF file reformatted
Now all MB commands and values are available to the VB code
[ I work in Delphi/Pascal so I'm making this short and *wrong* but you
should get the idea]
DIM Msg as String
DIM X1, Y1 as String
X1 = MI.Eval( " format$( commandinfo(cmd_info_x), "##0.000000" ) " )
Y1 = MI.Eval( " format$( commandinfo(cmd_info_y), "##0.000000" ) " )
'' now you have debugging
'' also you are forcing decimals because just commandinfo can return
'' truncated decimal values just like the browser with float fields
Msg = "Insert Into gps_temp ("
Msg = msg + Longitude
Msg = msg + ", "
Msg = msg + Latitude
Msg = msg + ") VALUES ("
Msg = msg + X1
Msg = msg + ", "
Msg = msg + Y1
Msg = msg + ")" '.............more stuff
MI.DO Msg
Now you you can set break points and debug MSG before it gets sent to MI
and figure out that """""" is really """ instead of """" [VB nonsense]
Once it works then you can combine the lines in to one long one
I couldn't get any of these methods to work. Treys answer allowed me to work out that the variable is defined OK in VB but not in Mapbasic.
If I drop my "Insert..." statement into a mapbasic window and run it, I get exactly the same error, which suggests to me the error is returned from Mapbasic, not VB.
I think the hint came from Trey.... "Set up a Global VB file with the MapBasic.DEF file reformatted Now all MB commands and values are available to the VB code" .
I have already had the Mapbasic.def setup as Mapbasic.bas so VB6 can read it.
The problem is (I think) related to the manner in which I am using the mapbasic code in VB.
Because I am using normal mapbasic statements within VB and I have a mapbasic.bas, I don't have ... Include "Mapbasic.def"... for when the mapbasic code runs (as you would normally have if you used plain old Mapbasic).
So.. I am stumped as to what would be the correct syntax for VB to recognise ... Include "Mapbasic.def"... I've tried it as a string, but I'm not sure if this is how it should be
Incidentally, in all the VB samples I have found, none of them actually show how to insert data into a table.
Cheers
> ************* This e-mail (including all attachments) contains
Visit Parkes on the web at http://www.parkes.nsw.gov.au.