|
楼主 |
发表于 2013-7-11 07:28:01
|
显示全部楼层
本帖最后由 DAS 于 2013-7-11 07:44 编辑
adriweb 发表于 2013-7-11 01:51
Have you guys seen FormulaPro ... ?
oh...imba.
That·s cool,and i cant believe it is a Lua Open-Source Program.
But...i cant fill munber in formula on the program and have to calc on scratchpad?
By the way,I have a problem on my program.this prgm cannot use a Negative number as arg.i means if i enter a Negative number in textbox as a argument,it report error.you can press"1","c"in the program,you will find a page about Uniformly accelerated linear motion.and if you set v1=-1,v0=12,a="N/A",t=0.01,it reported a error.i want to know how can i fix it.- -----------这是一份人人都可以查看的源代码,但它不能被未授权的查看者编辑(Readonly)---------------
- platform.apiLevel = '2.0'
- disp = 0
- calc = 0
- ---------------------------------------菜单--------------------------------------------
- menu = {
- {"物理 - 力学",
- {"胡克定律",function () f001() end},
- {"重力",function () f002() end},
- {"f1与f2合力",function () f003() end},
- {"滑动摩擦力",function () f004() end},
- {"浮力",function () f005() end},
- {"万有引力定律",function () f006() end},
- {"库仑力",function () f007() end},
- {"电场力",function () f008() end},
- {"磁场力 - 洛仑兹力",function () f009() end},
- {"磁场力 - 安培力",function () f010() end},
- {"牛顿第二定律",function () f011() end},
- {"匀变速直线运动",function () f012() end},
- {"匀速圆周运动",function () f013() end},
- {"直线运动公式",function () f014() end},
- {"动量,动量定理和冲量",function () f015() end},
- {"动量守恒定律",function () f016() end},
- {"功,动能和重力势能",function () f017() end},
- {"动能定理",function () f018() end},
- {"功率",function () f019() end},
- {"简谐振动",function () f020() end},
- {"波长,波速和频率",function () f021() end},
- },
- {"物理 - 热学",
- {"热力学第一定律",function () f101() end},
- {"克拉白龙方程",function () f102() end},
- {"理想气体状态方程",function () f103() end},
- {"理想气体玻马定律",function () f104() end},
- {"理想气体查理定律",function () f105() end},
- {"理想气体盖吕萨克定律",function () f106() end},
- },
- {"物理 - 电磁学",
- {"直流电路 - 电流强度的定义",function () f201() end},
- {"直流电路 - 电阻的串并联",function () f202() end},
- {"直流电路 - 欧姆定律1",function () f203() end},
- {"直流电路 - 欧姆定律2",function () f204() end},
- {"直流电路 - 电功和电功率",function () f205() end},
- {"电场和磁场 - 库仑定律",function () f206() end},
- {"电场和磁场 - 电场强度",function () f207() end},
- {"电场和磁场 - 电势差",function () f208() end},
- {"电场和磁场 - 电场力的功",function () f209() end},
- {"电场和磁场 - 电势和电容",function () f210() end},
- {"电场和磁场 - 磁感应强度",function () f211() end},
- {"电场和磁场 - 带电粒子在匀强...",function () f212() end},
- {"电磁感应 - 磁通量",function () f213() end},
- {"电磁感应 - 法拉第电磁感应定...",function () f214() end},
- {"电磁感应 - 电磁震荡",function () f215() end},
- {"交变电流 - 正弦交流电(从中性...",function () f216() end},
- {"交变电流 - 理想变压器",function () f217() end},
- },
- {"物理 - 光学",
- {"折射率",function () f301() end},
- {"全反射临界角",function () f302() end},
- {"波长,频率与波速的关系",function () f303() end},
- {"光子能量",function () f304() end},
- {"爱因斯坦光电方程",function () f305() end},
- },
- {"物理 - 原子物理学",
- {"波尔的原子理论",function () f401() end},
- {"氢原子能级公式",function () f402() end},
- {"氢原子轨道半径公式",function () f403() end},
- {"核反应方程",function () f404() end},
- {"爱因斯坦质能方程",function () f405() end},
- },
- }
- toolpalette.register(menu)
- toolpalette.enable("物理 - 原子物理学","核反应方程",false)
- -------------------------------------------菜单结束--------------------------------------------------
- -------------------------------------------功能跳转--------------------------------------------------
- function f001()
- falseall()
- disp = 1
- Text001:setVisible(true)
- Text002:setVisible(true)
- Text003:setVisible(true)
- Text001:setFocus(true)
- Text001:setText("N/A",90,0)
- refresh()
- end
- function f012()
- falseall()
- disp = 12
- Text001:setVisible(true)
- Text002:setVisible(true)
- Text003:setVisible(true)
- Text004:setVisible(true)
- Text001:setFocus(true)
- Text001:setText("N/A",90,0)
- refresh()
- end
- -------------------------------------------功能跳转结束-----------------------------------------
- function falseall()
- Text001:setVisible(false)
- Text002:setVisible(false)
- Text003:setVisible(false)
- Text004:setVisible(false)
- Text005:setVisible(false)
- Text006:setVisible(false)
- Text007:setVisible(false)
- end
- --------------------------------------------GC------------------------------------------------
- function on.paint(gc)
- if disp == 0 then
- gc:drawString("Power Formula V1.0.0 Alpha",50,70)
- gc:drawString("请按 menu 开始",90,90)
- gc:setFont("sansserif","r",9)
- gc:drawString("By DAS Copyright 2013 All right reserved.",45,185)
- gc:drawString("Protect by CC BY-SA 3.0 Agreement",60,200)
- end
- -------------------------------------------------------
- if disp == 1 then
- gc:drawString("物理 - 力学 - 胡克定律",20,20)
- gc:drawString("F=Kx",20,40)
- gc:drawString("K=",12,82)
- gc:drawString("x=",160,82)
- gc:drawString("F=",12,114)
- if calc == 0 then
- gc:drawString("输入3个参数中的2个并按esc键计算",20,200)
- end
- if calc == 1 then
- gc:drawString("按⇧shift+tab开始一个新的计算",40,200)
- end
- end
- ------------------------------------------------------
- if disp == 12 then
- gc:drawString("物理 - 力学 - 匀变速直线运动",20,20)
- gc:drawString("V₁=V₀+at",20,40)
- gc:drawString("V₁=",12,82)
- gc:drawString("V₀=",160,82)
- gc:drawString("a=",12,114)
- gc:drawString("t=",160,114)
- if calc == 0 then
- gc:drawString("输入4个参数中的3个并按esc键计算",20,200)
- end
- if calc == 1 then
- gc:drawString("按⇧shift+tab开始一个新的计算",40,200)
- end
- end
- ------------------------------------------------------
- end
- --------------------------------------------------GC结束-----------------------------------------------------------
- --------------------------------------------------计算区-----------------------------------------------------------
- function on.escapeKey()
- if disp == 1 then
- if Text003:getText() == "N/A" then
- varsf = tonumber(Text001:getText()) * tonumber(Text002:getText())
- Text003:setText(tostring(varsf))
- calc = 1
- refresh()
- end
- if Text001:getText() == "N/A" then
- varsk = tonumber(Text003:getText()) / tonumber(Text002:getText())
- Text001:setText(tostring(varsk))
- calc = 1
- refresh()
- end
- if Text002:getText() == "N/A" then
- varsx = tonumber(Text003:getText()) / tonumber(Text001:getText())
- Text002:setText(tostring(varsx))
- calc = 1
- refresh()
- end
- end
- ----------------------------------------------
- if disp == 12 then
- if Text001:getText() == "N/A" then
- varsv1 = tonumber(Text002:getText()) + tonumber(Text003:getText()) * tonumber(Text004:getText())
- Text001:setText(tostring(varsv1))
- calc = 1
- refresh()
- elseif Text002:getText() == "N/A" then
- varsv0 = tonumber(Text001:getText()) - tonumber(Text003:getText()) * tonumber(Text004:getText())
- Text002:setText(tostring(varsv0))
- calc = 1
- refresh()
- elseif Text003:getText() == "N/A" then
- varsa = (tonumber(Text001:getText()) - tonumber(Text002:getText())) / tonumber(Text004:getText())
- Text003:setText(varsa)
- calc = 1
- refresh()
- elseif Text004:getText() == "N/A" then
- varst = (tonumber(Text001:getText()) - tonumber(Text002:getText())) / tonumber(Text004:getText())
- Text004:setText(tostring(varst))
- calc = 1
- refresh()
- end
- end
- ----------------------------------------------
- end
- ---------------------------------------------计算区结束-----------------------------------------------------
- ------------------------------------------绘制富文本框什么的------------------------------------------------
- function on.resize()
- Text001 = D2Editor.newRichText();
- Text001:move(40,60)
- Text001:resize(100,30)
- Text001:setText("N/A",90,0)
- Text001:setBorder(1)
- Text001:setVisible(false)
- Text002 = D2Editor.newRichText();
- Text002:move(190,60)
- Text002:resize(100,30)
- Text002:setText("N/A",90,0)
- Text002:setBorder(1)
- Text002:setVisible(false)
- Text003 = D2Editor.newRichText();
- Text003:move(40,92)
- Text003:resize(100,30)
- Text003:setText("N/A",90,0)
- Text003:setBorder(1)
- Text003:setVisible(false)
- Text004 = D2Editor.newRichText();
- Text004:move(190,92)
- Text004:resize(100,30)
- Text004:setText("N/A",90,0)
- Text004:setBorder(1)
- Text004:setVisible(false)
- Text005 = D2Editor.newRichText();
- Text005:move(40,124)
- Text005:resize(100,30)
- Text005:setText("N/A",90,0)
- Text005:setBorder(1)
- Text005:setVisible(false)
- Text006 = D2Editor.newRichText();
- Text006:move(190,124)
- Text006:resize(100,30)
- Text006:setText("N/A",90,0)
- Text006:setBorder(1)
- Text006:setVisible(false)
- Text007 = D2Editor.newRichText();
- Text007:move(40,156)
- Text007:resize(100,30)
- Text007:setText("N/A",90,0)
- Text007:setBorder(1)
- Text007:setVisible(false)
- end
- ------------------------------------------绘制富文本框结束-------------------------------------------------------
- function on.contextMenu()
- if Text001:hasFocus() == true then
- if Text002:isVisible() == true then
- Text002:setFocus(true)
- end
- elseif Text002:hasFocus() == true then
- if Text003:isVisible() == true then
- Text003:setFocus(true)
- end
- elseif Text003:hasFocus() == true then
- if Text004:isVisible() == true then
- Text004:setFocus(true)
- end
- elseif Text004:hasFocus() == true then
- if Text005:isVisible() == true then
- Text005:setFocus(true)
- end
- elseif Text005:hasFocus() == true then
- if Text006:isVisible() == true then
- Text006:setFocus(true)
- end
- elseif Text006:hasFocus() == true then
- if Text007:isVisible() == true then
- Text007:setFocus(true)
- end
- end
- end
- function on.backtabKey()
- Text001:setText("N/A",90,0)
- Text002:setText("N/A",90,0)
- Text003:setText("N/A",90,0)
- Text004:setText("N/A",90,0)
- Text005:setText("N/A",90,0)
- Text006:setText("N/A",90,0)
- Text007:setText("N/A",90,0)
- Text001:setFocus(true)
- calc = 0
复制代码 |
评分
-
查看全部评分
|