import win.ui;
import console;
import key;
/*DSG{{*/
mainForm = win.form(text="计算器";right=757;bottom=467;max=false)
mainForm.add(
buttonCal={cls="button";text="计算结果";left=111;top=354;right=269;bottom=405;color=14120960;font=LOGFONT(h=-14);note=" ";z=2};
buttonClose={cls="button";text="退出";left=441;top=354;right=599;bottom=405;color=14120960;font=LOGFONT(h=-14);note=" ";z=6};
editFrom={cls="richedit";left=52;top=48;right=358;bottom=349;edge=1;multiline=1;wrap=1;z=1};
editTo={cls="edit";left=388;top=48;right=694;bottom=349;edge=1;multiline=1;z=3};
staticCal={cls="static";text="公式(可分行计算)";left=52;top=10;right=172;bottom=37;transparent=1;z=4};
staticNo={cls="static";text="1";left=29;top=51;right=46;bottom=349;transparent=1;z=7};
staticResult={cls="static";text="结果";left=405;top=10;right=525;bottom=37;transparent=1;z=5}
)
/*}}*/
mainForm.editFrom.text = "33+33";
mainForm.staticNo.text = '';
for(i=1;20;1){
mainForm.staticNo.text = mainForm.staticNo.text++i++'\n';
}
mainForm.editFrom.onOk = function(){ //onOk回车
if #mainForm.editFrom.lineText() {
try{
var res = math.round(eval(mainForm.editFrom.lineText()),2);
mainForm.editFrom.print("="++res++'\n\n'++res);
key.combine(0x8/*_VK_BACK*/)
//key.press(0x8/*_VK_BACK*/)
}
catch(e){
mainForm.msgbox("公式错误")
}
//var errString = assert(mainForm.editFrom.lineText(),"异常")
//console.log(errString);
}
return true;
}
mainForm.buttonCal.oncommand = function(id,event){
if #mainForm.editFrom.text {
mainForm.editTo.text = eval(mainForm.editFrom.text)
}
}
mainForm.buttonClose.oncommand = function(id,event){
win.quitMessage()
}
mainForm.show();
return win.loopMessage();