written by Sumbera, S.,  Dec. 2002

5. Hello World

Hllo worlD - your first MDL program...

 

 

Let’s create first program in MDL to get the first impression. The code is made as simple as possible just to provide introduction to programming in MDL. Compilation is made through compiler and linker programs. Later you will see that the build process can be handled by bmake utility and correspondent make file. Hello World program only prints a greeting text.
 

Step 1

In any text editor create following code and save it as HelloWorld.mc into the arbitrary folder, let’s say D:\mdl_src:
 

#include    <stdio.h>

void main(){

// print message  to the text window

printf(" Hello World from  MDL application");

}

Step 2

From Windows menu Start/Program/MicroStationv8 run Development Shell of MicroStation. A command window will be displayed.
Development Shell runs Windows command interpreter (former DOS prompt) with mstndevvar.bat batch file. The batch file resides in \MicroStation\jmdl\bin directory and sets all neccessary environment variables for building applications (like path to MicroStation executable, include and library directories).

Step 3

Compile your code with mcomp compiler, an object file HelloWorld.mo will be created. The flag –i tells to compiler where to search include files. variable MS has been set by previous step and contain path to MicroStation directory.


mcomp -i%MS%\mdl\include -i%MS%\mdl\include\stdlib d:\mdl_src\HelloWorld.mc
 

Step 4

 Link the code with mlink to final application HelloWorld.ma located in mdlapps directory of MicroStation . A flag –a sets the output path of the application.

mlink -a%MS%\mdlapps\HelloWorld.ma d:\mdl_src\HelloWorld.mo
 

Step 5

 Run MicroStation and type into Key-In area: mdl load HelloWorld. In a text window of MicroStation you will see the message written in the code above.
 

 

(TB-MB C) ..to be ..may be... continued

mail comments to stanislav@sumbera.com