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

保存模板
输入UI接口代码
通过切换到Interface Code的Tab页面,可以编辑接口代码。这里的接口代码在运行时,将会生成一个窗体,提示用户输入一个名称,而用户输入的名称将会替换掉“Hello World”中的World。
JScript
//In the interface code segment, the setup function
//is the initial function call.
function setup()
{
//Set the form title bar to say "Hello World!!"
ui.Title = "Hello World!!";

//Set the height and width of the form in pixels
ui.Height = 150;
ui.Width = 340;

//Add a label and a textbox to the form.
ui.AddLabel("lblName", "Enter a Name:", "Enter a name below
");
ui.AddTextBox("txtName", "World", "Enter a name in here
");

//The number of times to repeat "Hellow World!!"
input.item("timesToRepeat") = 10;

//Tells MyGeneration to display the form. If this is
//set to false. MyGeneration skips displaying the
//form, but retains any changes made in the interface
//code segment.
ui.ShowGUI = true;
}

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

'Set the height and width of the form in pixels
ui.Height = 150
ui.Width = 340

'Add a label and a textbox to the form.
ui.AddLabel "lblName", "Enter a Name:", "Enter a name below
"
ui.AddTextBox "txtName", "World", "Enter a name in here
"

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

测试UI接口
如果你想测试一下前面输入的内容的结果,你就需要执行模板。点击工具栏的Execute按钮(绿色的播放按钮),你将看到如下的结果
输入模板代码
通过切换到Template Code Tab页,可以查看和编辑模板代码。如下的代码将生成一个显示10各Hello Name!!!的HTML页面。
JScript
<html>
<body>
<% for (var i = 0; i < input.item("timesToRepeat"); i++) { %>
<br>Hello <%= input.item("txtName") %>!!
<% } %>
body>
html>
VBScript
<html>
<body>
<% For i = 0 to input.item("timesToRepeat") %>
<br>Hello <%= input.item("txtName") %>!!
<% Next %>
body>
html>执行完成的模板
<html>
<body>
<br>Hello World!!
<br>Hello World!!
<br>Hello World!!
<br>Hello World!!
<br>Hello World!!
<br>Hello World!!
<br>Hello World!!
<br>Hello World!!
<br>Hello World!!
<br>Hello World!!
body>
html>

结束语
希望通过这个教程,你看到了 MyGeneration 通过你的指尖在键盘上的敲打而显现的强大的力量。当你开始熟悉 MyGeneration 之后,我建议你做如下的事情:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-364713/ ,如需转载,请注明出处,否则将追究法律责任。