MapBasic window

644 views
Skip to first unread message

Don Guerra

unread,
Oct 17, 2008, 4:30:23 PM10/17/08
to mapi...@googlegroups.com

Hello,

 

Issuing function commands such as WindowID(), MapperInfo(), and others from the Mapbasic window is generating “unrecognized command” errors.

I assume that the Mapbasic.def file loads with MapInfo Professional.  I’m using MI9.5

 

Thanks,

 

Don Guerra

Eric_Bl...@mapinfo.com

unread,
Oct 17, 2008, 6:02:12 PM10/17/08
to mapi...@googlegroups.com

Don,

The ids from MapBasic.def cannot be used in the MapBasic window. Only the MapBasic compiler knows about them when you include them and does the substitution of the actual numbers. The MapBasic.def listing is part of the help if you wish to find out what numbers to enter.

Eric Blasenheim
Chief Product Architect
Pitney Bowes Business Insight [MapInfo]



Mail List:grbounce-yvy1equaaaajbprysysrydkk7vpghp_9=mail_list=mapin...@googlegroups.com
From: "Don Guerra" <dagu...@mawc.org> on 10/17/2008 04:30 PM AST
To: <mapi...@googlegroups.com>
cc:
Subject: [MI-L] MapBasic window

Don Guerra

unread,
Oct 21, 2008, 4:03:48 PM10/21/08
to mapi...@googlegroups.com

Thanks Eric,

 

I had been typing “mapperinfo(1,22)” and getting the “unrecognized command” error……….adding “note” at the beginning of the line, to generate a window for the results, solved the problem.  I had assumed that the mapperinfo function command would be recognized and automatically generate it’s own result window. 

 

Still learning lots about mapbasic, thanks again

 

 

Don Guerra






<br

Eric_Bl...@mapinfo.com

unread,
Oct 23, 2008, 11:12:01 PM10/23/08
to mapi...@googlegroups.com

MapBasic functionality can be logically broken into two very different types: functions and commands/statements. A function just returns a value. Functions are supplied by us as part of the product (such as MapperInfo), or can be written by users in their MapBasic program. As functions just return values, they can only be executed as part of what is commonly called an expression.  Here are some expressions, some of which use functions:
5  - this is a constant expression. It's value is always 5.
5+4 this uses the addition operator and returns the result of the two constants
5+ somevariable - add the value of the "somevariable" and 5.
Str$(...) this function returns the string value of some expression
Mapperinfo(......) returns the values based on the various flags
5+ SomeFunctionIWrote(....) / SomeOtherFunction() * MapperInfo(.....) +6  - I think you get the idea.

Operators and functions often are very similar even though their syntax is different.  A function called Add(2, 7) does the same thing as 2+7
However, functions don't do things like visibly displaying a value. They can just return it. (This does not mean one can't write a function that runs commands inside it. That is done all the time).

Commands do not return values but execute the instructions and do whatever they are designed to do.

Open Table .....  is a command that opens the table. One has to use a CommandInfo() function afterward to find out if it was successful
Create Map...  
Select ...
Objects Combine ....
Print
Note

These are all commands. If you look up the help for Print (which displays to the message window) or Note(which puts up a dialog with the value) , the only parameter is a string expression.

If you type Print 5 in the MapBasic Window, Professional will coerce the number 5 into a string and send it to Print.
If you type Print "hello" you will see that string.
If you type Print abc123 you will get an error "variable or field abc123 not defined  Print command failed. Unable to evaluate expression"
This verbose error says that Professional, seeing abc and realizing that is not a number and there being no quotes knows it is not a string, tried to find a variable of that name or a table name. If there was one it would have printed the value. But there was none so it raised the first error. The print command received nothing to print so it failed and so forth.

Thus, when you enter just the MapperInfo() function in the MapBasic window, the command processor (which is what the MapBasic window is) finds no command to execute and errors. If you instead typed

dim abc as integer
abc=Mapperinfo(...)

then the command processor would have realized that it was doing an assignment command, evaluated MapperInfo( ...) and put the value in the variable. You would not have seen a thing because you did not ask to display anything. But the function would have worked just fine.

So, to see values from the MapBasic window, one should use Print or Note. Most people prefer Print because you don't have to dismiss the dialog AND you can run multiple commands at once. Just select the commands in the MapBasic window and hit Enter and you will execute them all in sequence. And now that one can copy values out of the message window, it is even more valuable.

I hope this helps.  

Eric Blasenheim
Chief Product Architect
Pitney Bowes Business Insight [MapInfo]



Mail List:grbounce-yvy1equaaaajbprysysrydkk7vpghp_9=mail_list=mapin...@googlegroups.com
From: "Don Guerra" <dagu...@mawc.org> on 10/21/2008 04:03 PM AST
To: <mapi...@googlegroups.com>
cc:
Subject: [MI-L] Re: MapBasic window

Don Guerra

unread,
Oct 27, 2008, 11:01:01 AM10/27/08
to mapi...@googlegroups.com

Eric,

 

Thanks, this helped a lot.

 Although I’ve been reading the user guide and reference I wasn’t picking up the distinction between functions and commands.

 

Don






<br

Reply all
Reply to author
Forward
0 new messages