Before you can use procedures such as Main within your MapBasic program you must first declare them. As show in the code below:-
The Main procedure controls all the other sub procedures to ensure the program runs according to the programmer’s intention. For any procedure to work in must first be declared. The Declare function defines the name and parameter list of a function. Search for the Declare function in MapBasic Help and scroll down to the example section. Here you will find a program for calculating cubes which may help improve your understanding of some basic MapBasic programming concepts
This example below is a more simplified version which covers a number of features worthy of further discussion.
At this point you will also have to learn a little about variables. In this program we have also declared two variables x and Cube both are of type SmallInt. SmallInt variable types are whole numbers from -32768 to 32767 (inclusive); stored in 2 bytes. Any variable information must be declared before being used in the program. This enables MapBasic, in this example, to allocate memory to accommodate SmallInt integers associated with the two variables. For more information about variables search for the Dim statement in MapBasic Help.
The result of the equation x ^ 3 is saved in the variable Cube. The caret “^” signifies that x is raised by the power of 3 in this case.
When the program is compiled and run the output is displayed in MapInfo Professional in a Note statement dialogue box. When the OK button is clicked the box is removed and the program finishes.
Whilst this program only contains a few lines of code there is still a lot to understand if you are completely new to programming. Like with learning any language there are some basic concepts you have to understand before you can successfully create more meaningful programs.