Skip to content

Commit ac54814

Browse files
committed
fix type issue in calculator
1 parent 84392af commit ac54814

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

OSL Programs/apps/System/.Install_system.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
"path": "Origin/(A) System/User Applications",
243243
"name": "Calculator.osl",
244244
"icon": "c #777 w 10 square 0 0 5 5 c #111 w 8 square 0 0 5 5 dot 0 0 c #888 w 2.5 square 0 3.7 3.7 1 dot -3.5 -1 dot 0 -1 dot -3.5 -4.6 dot 0 -4.5 c #f79204 dot 3.5 -4.5 dot 3.5 -1",
245-
"version":"4.9"
245+
"version":"5.0"
246246
},
247247
{
248248
"url": "https://origin.mistium.com/OSL%20Programs/apps/System/Activity.osl",

OSL Programs/apps/System/Calculator.osl

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,23 @@ def "draw" "x, y, x2, y2, character" (
2525
)
2626
)
2727
if clicked or "enter".onKeyDown() and character == "=" (
28-
current.toNum()
29-
secondary.toNum()
30-
if operation == "+" "current += secondary"
31-
if operation == "-" "current -= secondary"
32-
if operation == "x" "current *= secondary"
33-
if operation == "÷" "current /= secondary"
34-
current.toStr()
35-
secondary = 0
28+
number out = current.toNum()
29+
switch operation (
30+
case "+"
31+
out += secondary.toNum()
32+
break
33+
case "-"
34+
out -= secondary.toNum()
35+
break
36+
case "x"
37+
out *= secondary.toNum()
38+
break
39+
case "÷"
40+
out /= secondary.toNum()
41+
break
42+
)
43+
current = out.toStr()
44+
secondary = ""
3645
operation = ""
3746
)
3847
change -10 -5
@@ -62,7 +71,7 @@ loc 999 2 0 -22.5
6271
square 265 30 10 1 : c#ctb
6372

6473
loc 999 2 0 -72.5
65-
square 265 40 10 : c#cca
74+
square 265 40 10 : c#ctb
6675

6776
loc 2 2 20 -22.5
6877
text "Calculator" 9 : c#ct

0 commit comments

Comments
 (0)