dialog lcalc {
title "calc"
size -1 -1 123 130
option dbu
edit "", 1, 0 2 120 28, multi return
button "7", 2, 7 31 18 20
button "8", 3, 28 31 18 20
button "9", 4, 49 31 18 20
button "/", 5, 70 31 18 20
button "=", 6, 91 103 18 20
button "4", 7, 7 55 18 20
button "5", 8, 28 55 18 20
button "6", 9, 49 55 18 20
button "*", 10, 70 55 18 20
button "-", 11, 70 79 18 20
button "3", 12, 49 79 18 20
button "2", 13, 28 79 18 20
button "1", 14, 7 79 18 20
button "+", 15, 70 103 18 20
button ".", 16, 49 103 18 20
button "-/+", 17, 28 103 18 20
button "0", 18, 7 103 18 20
button "Mod", 19, 91 79 18 20
button "^", 20, 91 55 18 20
button "Clear", 21, 91 31 18 20
}
on 1:dialog:lcalc:sclick:*:{
if ($did == 10) { did -a lcalc 1 * | set %cs %cs $+ * }
elseif ($did == 11) { did -a lcalc 1 - | set %cs %cs $+ - }
elseif ($did == 15) { did -a lcalc 1 + | set %cs %cs $+ + }
elseif ($did == 5) { did -a lcalc 1 / | set %cs %cs $+ / }
elseif ($did == 6) { did -i lcalc 1 2 $calc($did(lcalc,1,1)) }
elseif ($did == 21) { unset %cs | did -r lcalc 1 }
}