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.