使用MyGeneration创建模板

概观

这是一个使用 MyGeneration 开发模板的基本的介绍。如果你安装了 MyGeneration ,并且对 MyGeneration 感到迷惑的话,这里是一个很好的教你使用 MyGeneration 的教程。这个教程将教会你使用 MyGeneration 创建基本的 JScript. 或 VBScript. 的模板。


创建模板

  • 打开 MyGeneration
  • 从菜单中选择File->New->JScript. Template或者File->New->VBScript. Template
    填充模板属性
  • 你可以通过点击 Property 按钮查看或编辑模板的属性
    按照如下的显示填充属性窗体

templateproperties.png


保存模板

  • 选择File->Save As...保存模板

输入UI接口代码


通过切换到Interface Code的Tab页面,可以编辑接口代码。这里的接口代码在运行时,将会生成一个窗体,提示用户输入一个名称,而用户输入的名称将会替换掉“Hello World”中的World。

JScript

 

None.gif // In the interface code segment, the setup function 
None.gif
  // is the initial function call.
None.gif
  function  setup()
None.gif {
None.gif        
// Set the form title bar to say "Hello World!!"
None.gif
        ui.Title  =   " Hello World!! " ;
None.gif
None.gif
None.gif        
// Set the height and width of the form in pixels
None.gif
        ui.Height  =   150 ;
None.gif        ui.Width 
=   340 ;
None.gif
None.gif
None.gif        
// Add a label and a textbox to the form.
None.gif
        ui.AddLabel( " lblName " " Enter a Name: " " Enter a name belowdot.gif " );
None.gif        ui.AddTextBox(
" txtName " " World " " Enter a name in heredot.gif " );
None.gif
None.gif
None.gif        
// The number of times to repeat "Hellow World!!"
None.gif
        input.item( " timesToRepeat " =   10 ;
None.gif
None.gif
None.gif        
// Tells MyGeneration to display the form. If this is 
None.gif
         // set to false. MyGeneration skips displaying the
None.gif
         // form, but retains any changes made in the interface
None.gif
         // code segment.
None.gif
        ui.ShowGUI  =   true ;
None.gif }
None.gif
None.gif

VBScript

 

None.gif ' In the interface code segment, the setup function 
None.gif
  ' is the initial function call.
None.gif
  Sub  setup()
None.gif        
' Set the form title bar to say "Hello World!!"
None.gif
        ui.Title  =   " Hello World!!"
None.gif
None.gif

None.gif
         ' Set the height and width of the form in pixels
None.gif
        ui.Height  =   150
None.gif        ui.Width 
=   340
None.gif
None.gif
None.gif        
' Add a label and a textbox to the form.
None.gif
        ui.AddLabel  " lblName " " Enter a Name: " " Enter a name belowdot.gif"
None.gif
        ui.AddTextBox  " txtName " " World " " Enter a name in heredot.gif"
None.gif
None.gif

None.gif
         ' The number of times to repeat "Hellow World!!"
None.gif
        input.item( " timesToRepeat " =   10
None.gif        
' Tells MyGeneration to display the form. If this is 
None.gif
         ' set to false. MyGeneration skips displaying the
None.gif
         ' form, but retains any changes made in the interface
None.gif
         ' code segment.
None.gif
        ui.ShowGUI  =   true
None.gif 
End Sub
None.gif
None.gif

测试UI接口

如果你想测试一下前面输入的内容的结果,你就需要执行模板。点击工具栏的Execute按钮(绿色的播放按钮),你将看到如下的结果


execute_gui.png

输入模板代码


通过切换到Template Code Tab页,可以查看和编辑模板代码。如下的代码将生成一个显示10各Hello Name!!!的HTML页面。


JScript

 

None.gif < html >
None.gif        
< body >
None.gif 
 for (var i = 0; i < input.item("timesToRepeat"); i++) { %>
None.gif                        
<br>Hello  input.item("txtName"%>!!
None.gif 
 } %>
None.gif        
body>
None.gif 
html>
None.gif

 

VBScript

 

None.gif < html >
None.gif        
< body >
None.gif 
< For  i  =   0   to  input.item( " timesToRepeat " ) % >
None.gif                        
< br > Hello  < % =  input.item( " txtName " ) % > !!
None.gif 
< Next  % >
None.gif        
body >
None.gif 
html >

执行完成的模板

  • 执行模板之前,保存模板
  • 点击执行按钮,执行后的结果如下: 

None.gif   < html >
None.gif        
< body >
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif                        
< br > Hello World!!
None.gif        
body >
None.gif 
html >
None.gif
None.gif

结束语


希望通过这个教程,你看到了 MyGeneration 通过你的指尖在键盘上的敲打而显现的强大的力量。当你开始熟悉 MyGeneration 之后,我建议你做如下的事情:

  1. 查看安装 MyGeneration 时附带的模板,我从哪儿学到了很多;
  2. 研究 Zeus 的API文档以及 MyMeta. ;
  3. 思考一下,在你的工作中哪些需要使用 MyGeneration ,发现这些,你将会吃惊的发现,以前很多耗时的工作, MyGeneration 会使它们变得轻而易举。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12639172/viewspace-364713/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/12639172/viewspace-364713/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值