;w Menu * { - Enterprise Calculation:/dialog -md Math Math - } alias F6 { /dialog -md Math Math } Dialog Math { Title "Enterprise Calculation By Ano" size -1 -1 150 100 option dbu Menu "Options", 100 Item "Calculator", 101, 100 Item "Graph", 102, 100 Edit "Answer", 1, 2 2 98 10 Edit "Question", 2, 2 14 98 10, read Button "1", 3, 2 26 15 15 Button "2", 4, 17 26 15 15 Button "3", 5, 32 26 15 15 Button "4", 6, 2 41 15 15 Button "5", 7, 17 41 15 15 Button "6", 8, 32 41 15 15 Button "7", 9, 2 56 15 15 Button "8", 10, 17 56 15 15 Button "9", 11, 32 56 15 15 Button "0", 12, 2 71 15 15 Button ".", 13, 17 71 15 15 Button "-", 14, 32 71 15 15 Button ":", 15, 50 26 15 15 Button "X", 16, 50 41 15 15 Button "-", 17, 50 56 15 15 Button "+", 18, 50 71 15 15 Button "Ok", 19, 2 88 78 10 Button "²", 20, 65 26 15 15 Button "^", 21, 65 41 15 15 Button "xSqrt", 22, 65 71 15 15 Button "Sqrt", 23, 65 56 15 15 Button "[", 24, 83 71 15 15 Button "]", 25, 98 71 15 15 Button "Sin", 26, 83 26 15 15 Button "aSin", 27, 98 26 15 15 Button "Cos", 28, 83 41 15 15 Button "aCos", 29, 98 41 15 15 Button "Tan", 30, 83 56 15 15 Button "aTan", 31, 98 56 15 15 Button "(", 32, 83 88 15 10 Button ")", 33, 98 88 15 10 Button "+", 34, 100 2 10 10 Button "-", 35, 100 14 10 10 Edit "", 36, 112 2 30 10, center read Button "\Y1=", 37, 2 2 15 10 Button "\Y2=", 38, 2 14 15 10 Button "\Y3=", 39, 71 2 15 10 Button "\Y4=", 40, 71 14 15 10 Edit "", 41, 19 2 50 10, read Edit "", 42, 19 14 50 10, read Edit "", 43, 88 2 50 10, read Edit "", 44, 88 14 50 10, read Button "Draw", 45, 115 26 30 15 Text "Venster-", 46, 115 41 35 10 Text "instellingen:", 47, 115 47 35 8 Text "Xmin:", 48, 115 54 20 8 Text "Xmax:", 49, 129 54 20 8 Edit "", 50, 114 63 15 10, autohs Edit "", 51, 128 63 15 10, autohs Text "Ymin:", 52, 115 72 20 8 Text "Ymax:", 53, 129 72 20 8 Edit "", 54, 114 81 15 10, autohs Edit "", 55, 128 81 15 10, autohs } on *:dialog:math:sclick:45:{ window -cp @math draw } alias draw { unset %focus if ($window(@math,1)) { if (%xy2) drawline -ir @math 3289650 3 100 %xy2 500 %xy2 if (%xy1) drawline -ir @math 3289650 3 %xy1 100 %xy1 500 } window -p @math drawline -r @math 120 50 100 50 200 50 drawline -r @math 120 50 275 50 375 50 drawline -r @math 120 50 450 50 550 50 drawline -r @math 120 50 625 50 725 50 drawline -r @math 3289650 1 100 100 100 500 500 500 500 100 100 100 if ($did(math,54) < 0) drawline -r @math 3289650 3 100 $xy(y) 500 $xy(y) if ($did(math,50) < 0) drawline -r @math 3289650 3 $xy(x) 100 $xy(x) 500 set %xy1 $xy(x) set %xy2 $xy(y) textdraw if ($did(math,41)) drawtek 41 if ($did(math,42)) drawtek 42 if ($did(math,43)) drawtek 43 if ($did(math,44)) drawtek 44 } alias nothing { unset %focus drawline -r @math 120 50 100 50 200 50 drawline -r @math 120 50 275 50 375 50 drawline -r @math 120 50 450 50 550 50 drawline -r @math 120 50 625 50 725 50 drawreplace -r @math 328965 16777215 textdraw halt } menu @math { sclick: { if ($mouse.y isnum 28-78) { if ($mouse.x isnum 100-200) drawpict 1 if ($mouse.x isnum 275-375) drawpict 2 if ($mouse.x isnum 450-550) drawpict 3 if ($mouse.x isnum 625-725) drawpict 4 } } mouse: { if ($mouse.x isnum 100-500) && ($mouse.y isnum 100-500) && (%focus) trace } } alias trace { drawtext -r @math 0 525 110 TRACE: drawtext -r @math 0 525 125 Formula: drawtext -r @math 0 525 140 X: drawtext -r @math 0 525 155 Y: drawreplace -r @math 328965 16777215 drawtext -r @math 328965 595 125 $did(math,$iif(%focus == 1,41,$iif(%focus == 2,42,$iif(%focus == 3,43,$iif(%focus == 4,44))))) drawtext -r @math 328965 550 140 $xy($eval($mouse.x,0)) set %toes $did(math,$iif(%focus == 1,41,$iif(%focus == 2,42,$iif(%focus == 3,43,$iif(%focus == 4,44))))) set %toes2 $replacecs(%toes,X,%mouse5) set %toes3 $calccs(%toes2) drawtext -r @math 328965 550 155 %toes3 } alias drawpict { if ($1 === 1) && ($did(math,41)) { if (%focus == 1) nothing drawline -r @math 51200 50 100 50 200 50 drawline -r @math 120 50 275 50 375 50 drawline -r @math 120 50 450 50 550 50 drawline -r @math 120 50 625 50 725 50 set %focus 1 } if ($1 === 2) && ($did(math,42)) { if (%focus == 2) nothing drawline -r @math 120 50 100 50 200 50 drawline -r @math 51200 50 275 50 375 50 drawline -r @math 120 50 450 50 550 50 drawline -r @math 120 50 625 50 725 50 set %focus 2 } if ($1 === 3) && ($did(math,43)) { if (%focus == 3) nothing drawline -r @math 120 50 100 50 200 50 drawline -r @math 120 50 275 50 375 50 drawline -r @math 51200 50 450 50 550 50 drawline -r @math 120 50 625 50 725 50 set %focus 3 } if ($1 === 4) && ($did(math,44)) { if (%focus == 4) nothing drawline -r @math 120 50 100 50 200 50 drawline -r @math 120 50 275 50 375 50 drawline -r @math 120 50 450 50 550 50 drawline -r @math 51200 50 625 50 725 50 set %focus 4 } textdraw } alias textdraw { if ($did(math,41)) drawtext -r @math $rgb(230,240,50) 125 44 /Y1= if ($did(math,42)) drawtext -r @math $rgb(230,240,50) 300 44 /Y2= if ($did(math,43)) drawtext -r @math $rgb(230,240,50) 475 44 /Y3= if ($did(math,44)) drawtext -r @math $rgb(230,240,50) 650 44 /Y4= } alias drawtek { unset %linex unset %liney unset %y unset %ty set %toes $did(math,$1) var %y = $did(math,50) var %ty = 100 while (%y) { if (%ty == 299) && ($getdot(@math,300,300) == 3223601) { inc %ty 1 inc %y $calc($calc($remove($did(math,50),-) + $remove($did(math,51),-)) / 400) } if (%ty > 500) break set %toes2 $replacecs(%toes,X,%y) set %toes3 $calccs(%toes2) if (%toes3 >= $did(math,54)) && (%toes3 <= $did(math,55)) && ($getdot(@math,$xy(%y,x),$xy(%toes3,y)) != 3223601) && ($xy(%y,x) >= 100) && ($xy(%y,x) <= 500) && ($xy(%toes3,y) >= 10) && ($xy(%toes3,y) <= 500) { if (%linex) && (3 > $calc($xy(%y,x) - %linex)) drawline -r @math 3289650 1 $xy(%y,x) $xy(%toes3,y) %linex %liney set %linex $xy(%y,x) set %liney $xy(%toes3,y) } inc %ty 1 inc %y $calc($calc($remove($did(math,50),-) + $remove($did(math,51),-)) / 400) } } alias xy { if ($1 == $eval($mouse.x,0)) { set %mouse1 $calc($remove($did(math,50),-) + $remove($did(math,51),-)) set %mouse2 $calc($mouse.x - 100) set %mouse3 $calc(%mouse1 / 400) set %mouse4 $calc(%mouse3 * %mouse2) set %mouse5 $calc($did(math,50) + %mouse4) return %mouse5 } if ($1 isnum) && ($2 == x) { if (0 > $did(math,50)) { set %num 0 set %num2 $calc($remove($did(math,50),-) + $remove($did(math,51),-)) set %num4 $calc($1 + $calc(%num2 / 2)) } else { set %num $did(math,50) set %num2 $did(math,51) set %num4 $1 } set %num3 $calc($remove($did(math,50),-) + $remove($did(math,51),-)) set %num5 $calc($calc(400 / %num3) * %num4) return $calc($calc(100 + %num5) - $calc(300 - $calc(%ix6 + 100))) } if ($1 isnum) && ($2 == y) { if (0 > $did(math,54)) { set %num1 0 set %num21 $calc($remove($did(math,54),-) + $remove($did(math,55),-)) set %num41 $calc($1 + $calc(%num21 / 2)) } else { set %num1 $did(math,54) set %num21 $did(math,55) set %num41 $1 } set %num31 $calc($remove($did(math,54),-) + $remove($did(math,55),-)) set %num51 $calc($calc(400 / %num31) * %num41) return $calc(500 - $calc(%num51 - $calc(300 - $calc(%iy6 + 100)))) } ;$calc($calc(100 + %num5) - $calc(300 - $calc(%ix6 + 100))) if ($1 == x) { if ($imp(50) == $false) || ($imp(51) == $false) { //echo -a Wrong X Coördinates Detected. halt } if (0 > $did(math,50)) { set %ix 0 set %ix2 $calc($did(math,51) + $remove($did(math,50),-)) } else { set %ix $did(math,50) set %ix2 $did(math,51) } set %ix3 $calc(%ix - %ix2) set %ix4 $calc($remove(%ix,-) + $remove(%ix2,-)) set %ix5 $calc(400 / $remove(%ix2,-)) set %ix6 $calc($remove($did(math,50),-) * %ix5) return $calc(%ix6 + 100) } if ($1 == y) { if ($imp(54) == $false) || ($imp(55) == $false) { //echo -a Wrong Y Coördinates Detected. halt } if (0 > $did(math,54)) { set %iy 0 set %iy2 $calc($did(math,55) + $remove($did(math,54),-)) } else { set %iy $did(math,54) set %iy2 $did(math,55) } set %iy3 $calc(%iy - %iy2) set %iy4 $calc(%ix + %iy2) set %iy5 $calc(400 / %iy2) set %iy6 $calc($remove($did(math,54),-) * %iy5) return $calc(500 - %iy6) } } alias imp { set %ds2 $1 var %ds = 1 while ($mid($did(math,%ds2),%ds,1)) { if ($mid($did(math,%ds2),%ds,1) isletter) { return $false break } if (%ds == $len($did(math,%ds2))) { return $true break } inc %ds } } ON *:DIALOG:math:close:*:{ set %sub1 $did(math,50) set %sub2 $did(math,51) set %sub3 $did(math,54) set %sub4 $did(math,55) } on *:dialog:math:init:*:{ if (%sub1) did -ra math 50 %sub1 if (%sub2) did -ra math 51 %sub2 if (%sub3) did -ra math 54 %sub3 if (%sub4) did -ra math 55 %sub4 if (%mem == 1) hide -v -h else { unset %mem hide -h -v did -ra $dname 19 X } } on *:dialog:math:sclick:37: { hut 41 42 43 44 } on *:dialog:math:sclick:38:{ hut 42 41 43 44 } on *:dialog:math:sclick:39:{ hut 43 41 42 44 } on *:dialog:math:sclick:40:{ hut 44 41 42 43 } alias hut { set %mem $1 did -n math $1 did -m math $2 did -m math $3 did -m math $4 if ($5) did -m math $5 } on *:dialog:math:menu:101:{ hide -v -h set %mem 1 did -ra $dname 19 Ok } on *:dialog:math:menu:102:{ hide -h -v did -ra $dname 19 X unset %mem } alias hide { set %hide $2 did $1 math 1 did $1 math 2 did $1 math 34 did $1 math 35 did $1 math 36 var %u = 37 while (%u) { if (%u > 55) break did %hide math %u inc %u } unset %hide } on *:dialog:math:sclick:34: { if (%res == 5) halt inc %res set %ruf $eval($remove($addtok($eval(%rof,0),%res,1),$chr(1)),2) set %rufl $eval($remove($addtok($eval(%rofl,0),%res,1),$chr(1)),2) did -ra $dname 1 %ruf did -ra $dname 2 %rufl did -ra $dname 36 %res } on *:dialog:math:sclick:35: { if (%res == 1) halt dec %res set %ruf $eval($remove($addtok($eval(%rof,0),%res,1),$chr(1)),2) set %rufl $eval($remove($addtok($eval(%rofl,0),%res,1),$chr(1)),2) did -ra $dname 1 %ruf did -ra $dname 2 %rufl did -ra $dname 36 %res } on *:dialog:math:sclick:*: { if (%mem) { if (%thingie == on) { set %thingie off did -r $dname %mem } if ($did == 16) { did -a $dname %mem * halt } if ($did isnum 3-22 || $did isnum 24-25 || $did isnum 32-33)) && ($did != 19) { if ($did(math,%mem) == Question) did -r $dname %mem set %calc $did(math,%mem) $+ $did(math,$did) $+ $iif($did == 22,$chr(40)) did -ra $dname %mem %calc } if ($did isnum 26-31 || $did isnum 23) { if ($did(math,%mem) == Question) did -r $dname %mem set %calc $did(math,%mem) $+ $sr($did) $+ $did(math,$did) $+ ( did -ra $dname %mem $remove(%calc,]) } elseif ($did == 19) { if (%mem == 1) { set %res 1 unset %tocalc* unset %tolol unset %wortel* unset %tos unset %chr* unset %repi set %tocalc $did(math,1) did -ra $dname 2 $calccs(%tocalc) set %rofl5 %rofl4 set %rofl4 %rofl3 set %rofl3 %rofl2 set %rofl2 %rofl1 set %rofl1 %tocalc3 set %rof5 %rof4 set %rof4 %rof3 set %rof3 %rof2 set %rof2 %rof1 set %rof1 %tocalc set %thingie on } else did -a math %mem X } else { } } } alias sr { if ($1) return $calc $+ $chr(40) if ($did(math,%mem) == $null) return $chr(32) elseif ($right($did(math,1),1) isin $plus) return $chr(32) else return * $chr(32) } alias calccs { set %toc $1- set %tocalc1 $replacex(%toc,:,/,asin,$chr(36) $+ asin,atan,$chr(36) $+ atan,acos,$chr(36) $+ acos,sin,$chr(36) $+ sin,cos,$chr(36) $+ cos,tan,$chr(36) $+ tan,²,^2,sqrt,$chr(36) $+ sqrt) if ($chr(91) isin %tocalc1) || ($chr(93) isin %tocalc1) set %tocalc1 $replica(%tocalc1,true) if ($chr(40) isin %tocalc1) || ($chr(41) isin %tocalc1) set %tocalc1 $replica(%tocalc1) if (x$sqrt isin %tocalc1) set %tocalc1 $wortel(%tocalc1) set %tocalc2 $eval(%tocalc1,2) set %tocalc3 $calc(%tocalc2) return %tocalc3 } alias wortel { set %ixy $1 set %wortel $pos(%ixy,x$sqrt,1) if ($mid(%ixy,%wortel,1) islower) { var %x = 1 while ($right($left(%ixy,%x),1)) { if (%x > 30) break if ($right($left(%ixy,%x),1) == $chr(41)) { set %nwortel - $+ %wortel set %wortel2 $remove($right($right(%ixy,%x),%nwortel),$chr(40),$chr(41),$chr(36) $+ sqrt) wortelimp return $replace(%ixy,%wortel3 $+ x$Sqrt( $+ %wortel2 $+ ),$negen) break } inc %x } } else return %ixy } alias negen { if ($count($calc( %wortel2 ^ $calc(1 / %wortel3)),9) > 4) return $round($calc( %wortel2 ^ $calc(1 / %wortel3)),4) else return $calc( %wortel2 ^ $calc(1 / %wortel3)) } alias wortelimp { var %z = 1 while ($right($left(%ixy,$calc(%wortel -1)),%z)) { if (%z > %wortel) break if ($right($left(%ixy,$calc(%wortel -1)),%z) isnum) set %wortel3 $right($left(%ixy,$calc(%wortel -1)),%z) else { break } inc %z } } alias plus { return ()+-/*[] $chr(32) : } alias replica { set %xx $1 unset %xxx* if ($2) return $replace(%xx,$chr(91),$chr(32) $chr(36) $+ calc $+ $chr(40),$chr(93),$chr(41)) else { var %x = 1 while (%x) { if (%x > $len(%xx)) break if ($mid(%xx,%x,1) == $chr(40)) inc %xxx1 if ($mid(%xx,%x,1) == $chr(41)) inc %xxx2 inc %x } return %xx $+ $str($chr(41),$calc(%xxx1 - %xxx2)) } }