This is a dialog that allows you to edit your variables without having to open them. And it even sorts them for you. :D
dialog vareditor {
title "Variable Editor"
size -1 -1 180 140
option dbu
edit "", 1, 10 5 162 10, autohs
button "Set", 2, 20 20 32 12, disable
button "Unset", 3, 75 20 32 12, disable
button "Clear", 4, 130 20 32 12
list 5, 10 45 160 90
text "Current Variables:", 6, 12 35 45 8
}
on 1:dialog:vareditor:*:*:{
if ($devent == init) {
var %x 1
var %y 1
while ($var(%*,%y)) {
var %vars $addtok(%vars,$var(%*,%y),32)
inc %y
}
while ($gettok(%vars,%x,32)) {
did -a $dname 5 $gettok(%vars,%x,32) = $eval($gettok(%vars,%x,32),2)
inc %x
}
did -d $dname 5 1
did -d $dname 5 1
did -d $dname 5 1
}
if ($devent == edit) {
if ($did == 1) { did -e $dname 2,3 }
}
if ($devent == sclick) {
if ($did == 2) {
set $did(1) $$?"What does $did(1) stand for?"
did -a $dname 5 $did(1) = $eval($did(1),2)
did -r $dname 1
did -b $dname 2,3
}
if ($did == 3) {
unset $did(1)
did -d $dname 5 $did(5).sel
did -r $dname 1
did -b $dname 2,3
}
if ($did == 4) {
did -r $dname 5
did -r $dname 1
did -b $dname 2,3
unsetall
}
if ($did == 5) {
did -r $dname 1
did -a $dname 1 $did(5).seltext
did -e $dname 2,3
}
}
}
menu * {
Variable Editor:dialog $iif($dialog(vareditor),-v,-m) vareditor vareditor
}
I could see this working in conjunction with a junk variable remover... but since I'm in my ScriptEd most of the time anyway, it's just a click away to get the variables. Plus, the top-right button in the variables tab sorts variables, too.
However, the idea of bringing it to a dialog gives newer people an easier interface for creation and removal of variables.
If you could find a place to add a refresh button, that would also be pretty neat, so people who are testing their scripts could watch what their variables are doing.
Also, why EXACTLY does clicking on the list anywhere CLEAR ALL OF YOUR VARIABLES!? I think that would be meant for the "Clear" button, but you put it under 5.
dialog vareditor {
title "Variable Editor"
size -1 -1 180 140
option dbu
edit "", 1, 10 5 162 10, autohs
button "Set", 2, 20 20 32 12, disable
button "Unset", 3, 75 20 32 12, disable
button "Refresh", 4, 130 20 32 12
list 5, 10 45 160 90
text "Current Variables:", 6, 12 35 45 8
}
on 1:dialog:vareditor:*:*:{
if ($devent == init) vareditor_populate
if ($devent == edit) && ($did == 1) did -e $dname 2,3
if ($devent == sclick) {
if ($did == 2) {
set $did(1) $$?"What does $did(1) stand for?"
did -a $dname 5 $did(1) = $eval($did(1),2)
did -r $dname 1
did -b $dname 2,3
}
if ($did == 3) {
unset $did(1)
did -d $dname 5 $did(5).sel
did -r $dname 1
did -b $dname 2,3
}
if ($did == 4) {
did -r $dname 5
vareditor_populate
}
if ($did == 5) {
did -r $dname 1
did -a $dname 1 $did(5).seltext
did -e $dname 2,3
}
}
}
alias vareditor_populate {
var %x 1
var %y 1
while ($var(%*,%y)) {
var %vars $addtok(%vars,$var(%*,%y),32)
inc %y
}
while ($gettok(%vars,%x,32)) {
did -a $dname 5 $gettok(%vars,%x,32) = $eval($gettok(%vars,%x,32),2)
inc %x
}
}
menu * {
Variable Editor:dialog $iif($dialog(vareditor),-v,-m) vareditor vareditor
}
Here is a version where I removed the unset %*, and replaced the clear command (since you could just /unset all at any time) with a Refresh Command.