Before read:
First of all,forgive my poor English.I will try to make this manual as readable as possible.And any advice or bug submit are welcomed here.Although the project have been planned for 5 years,but we just start it a few month ago. I did know dozens of bugs there,and something maybe changed later. So if your want to find a language to write your software at once,you should ignore this at the moment.
About the model language:
The model language are basically designed for repack use.It's try to offer a better way to reuse current stuff. The application which write in model language should be suitable for maintenance, redesign, and even migrate bettween diffent systems. Neither like Object-oriented in C++, nor like Process-based in C.there are no certain design methed in model language.To design a app in Model Language,the best way is try to make the framework clearly first,or try to solve the current problems first,then sum up experience and improve the quality.
Using model language:
In this paragraph,we write a window based app as an example.The app has a main window,and a button control on it to close the app.The details of syntax should be discussed later.We just get a glance here.
1) Setup entironment.In this example we use mingw as the complier.Copy mdl.exe into bin directory,and create a folder called mdltmp under it.Create a folder called "mdlc" in mingw's root directory,which contain the header file and library file.
2) Setup project.Write a project file as follows,and save it as helloword.prj:
[mdl\]
"main.mdl"
Write a batch file as follows to build the project:
set path= "(your mingw path)\bin\"
cd "(your mingw path)\bin\"
mdl win32 -prj [your prj file's full path filename)] -gcc -out [our output file's full path filename]
3)Create a txt file and write mdl code as follows:
//The entrance.
adv WinMsgFramework Main( nArcNum )
{
update Start( )
{
mdlwmf:Start( "MainWindow" );
}
}
//The main window. As an example,we write it manually instead of inherit from perdefined proc.
proc MainWindow()
{
step OnInit()
{
nStyle = mWS_SYSMENU | mWS_BORDER;
mdlwmf:PushStyle( nStyle );
mdlwmf:SetWinRect( 100, 100, 693, 501 );
mdlwmf:SetType( "Window" );
mdlwmf:SetWinText( "hello world!" );
}
step AddSubControls()
{
mdlwmf:Start( "CloseButton" );
}
}
//The Button.
proc CloseButton()
{
step OnInit()
{
mdlwmf:SetWinRect( 20, 20, 100, 60 );
mdlwmf:SetWinText( "Close" );
ButtonFramework:OnInit();
}
step OnClick()
{
Halt( "No Error" );
}
}
4)Save the text file as "main.mdl",and exec the batch file to build the project then.
Majority features of model language:
Here are the majority features of model language:
1)Independent of compiler:
Unlike C or C++,model language are not designed for direct build binary.It's designed for transform mdl codes into the other language.For example, we can transform mdl codes into standard C codes and build them.The result file are certain number, certain format,so we can detach the language from compilers,and have a better chance to port cods between different platform.
2)Half script:
An very important feature of mdl is it support "call by name",which let us can make a proc or step call by strings.With this feature,we can repack our codes very shortly.
e.g:Call a step belong to Foo proc by the string sStepname.
simu Foo % sStepname( nX, nY )
{
//Codes for deal with failed.
}
In this example, we can simply assign different sStepname values to change the target step.
3)Prefix define method:
Not like C,C++ or Jave etc,model language use it's own method to declare values.All values has a prefix name and defined automatically.For example:If we needs a integer value A,in C language,we should navigate to the head of the function,and write "int A" to declare it.But in the model language,we just use nA instead.
4)Process inherited:
In model language,we can not only inherited members of proc,but also can inherit the process.For example,the FooA proc have 4 steps: A,B,C,D.They are design to execute one by one.Now we want to got a new proc: FooB,which just needs to change the C.We can simply inherited FooB from FooA, and update the step C.The FooB still keeps the same process as FooA,we can call it directly.