aardio的简单计算器实例

 

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();

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值