;;Text Correct - OQL Widget Script ;;Used for drilling and practicing OQL commands, or can be used for whatever you want EXCEPT duplicating without my permission. ;;Made by Jamie menu channel { Text Correct: tc } dialog textcorrect { title "Text Correct Counter" size -1 -1 250 70 button "Set Text", 1, 100 10 70 20 button "On", 2, 10 10 40 20 button "Off", 3, 55 10 40 20 button "Reset", 4, 175 10 40 20 text "# Correct:", 5, 30 37 80 20 text "# Wrong:", 6, 130 37 80 20 text "", 7, 90 37 40 20 text "", 8, 186 37 40 20 button "%", 9, 220 10 20 20 text "Text - ", 10, 10 55 40 15 text "", 11, 45 55 220 15 } dialog settext { title "Set Text" size -1 -1 250 50 text "Input text here:", 1, 10 2 90 15 edit "", 2, 5 17 240 18 button "OK", 3, 210 35 30 15, default, cancel } alias tc { if (!$dialog(active)) { dialog -vm textcorrect textcorrect } } on *:DIALOG:*:*:*: { if ($dname == textcorrect) { if ($devent == init) { did -ra textcorrect 11 %tc.text if (%tc.right != $null || %tc.wrong != $null) { did -ra textcorrect 7 %tc.zeros $+ %tc.right did -ra textcorrect 8 %tc.zeros $+ %tc.wrong } else { did -ra textcorrect 7,8 0000 } if (%tct == on) { did -b textcorrect 2 | did -e textcorrect 3 } else { did -b textcorrect 3 | did -e textcorrect 2 } } if ($devent == sclick) { if ($did == 1) { dialog -vm settext settext } else if ($did == 2) { if (%tct != on) { echo -a 2Text Correct is now on. set %tct on did -b textcorrect 2 | did -e textcorrect 3 } } else if ($did == 3) { if (%tct != off) { echo -a 2Text Correct is now off. if (%tc.right != $null || %tc.wrong != $null) { echo -a 2You got 4 $+ %tc.right 2right and 4 $+ %tc.wrong 2wrong. Your correct percentage is: 4 $+ $round($calc(100-((%tc.wrong / %tc.right)*100)),2) $+ % } set %tct off did -b textcorrect 3 | did -e textcorrect 2 } } else if ($did == 4) { echo -a 2Your scores have been reset. if (%tc.right != $null || %tc.wrong != $null) { echo -a 2You got 4 $+ %tc.right 2right and 4 $+ %tc.wrong 2wrong. Your correct percentage is: 4 $+ $round($calc(100-((%tc.wrong / %tc.right)*100)),2) $+ % } unset %tc.right 0 unset %tc.wrong 0 unset %tc.zeros did -ra textcorrect 7,8 0000 } else if ($did == 9) { echo -a 2Your correct percentage is: 4 $+ $round($calc(100-((%tc.wrong / %tc.right)*100)),2) $+ % } } } else if ($dname == settext) { if ($devent == sclick) { if ($did == 3) && ($did(settext,2,edited)) { set %tc.text $didtok(settext,2,32) set %tc.letters $remove(%tc.text,$chr(32)) echo -a 2Text is now set to  $+ %tc.text did -ra textcorrect 11 %tc.text unset %tc.right unset %tc.wrong dialog -x settext settext } } } } on *:INPUT:*: { if ($mid($1,1,1) != /) { if (%tct == on) { if ($mid($1,1,2) == ::) { if ($1- == %tc.text) { inc %tc.right | updater right } else { inc %tc.wrong | updater wrong } } else if ($compare($1-) == true) { inc %tc.right | updater right } else { inc %tc.wrong | updater wrong } } } } alias compare { var %b = $strip($1-) var %c = $remove(%b,$chr(32)) set %tc.boolean false if (%tc.text != $null) { var %g = 1 while (%g <= $numtok(%b,32)) { if ($len($gettok(%b,%g,32)) == $len($gettok(%tc.text,%g,32))) { set %tc.boolean true } else { set %tc.boolean false | break } inc %g } if (%tc.boolean == true) { var %a = 1 while (%a <= $len(%c)) { if ($count(%c,$mid(%tc.letters,%a,1)) != $count(%tc.letters,$mid(%tc.letters,%a,1))) { set %tc.boolean false | break } else { set %tc.boolean true } inc %a } } } return %tc.boolean } alias updater { if ($1 == right) { set %tc.zeros 0 while ($len(%tc.zeros) != $calc(4-$len(%tc.right))) { %tc.zeros = %tc.zeros $+ 0 } did -ra textcorrect 7 %tc.zeros $+ %tc.right } else { set %tc.zeros 0 while ($len(%tc.zeros) != $calc(4-$len(%tc.wrong))) { %tc.zeros = %tc.zeros $+ 0 } did -ra textcorrect 8 %tc.zeros $+ %tc.wrong } }