Variable Viewer and Editor Dialog

By Scakk on Oct 05, 2007

With this dialog you can edit to current variables , delete variables ( one or more than one at a time ) and also create new variables with information for them.

Image

menu status,channel { 
  [Variable Updater]: dialog $iif(!$dialog(variables), -m,va) variables variables
}

dialog Variables {
  title "Variable Updater"
  size -1 -1 285 255
  list 2, 5 5 275 170, hsbar vsbar sort
  text "Variable", 3, 5 175 40 20, center
  text "Info", 5, 5 200 40 20, center
  edit "", 4, 50 172 230 20, center read
  edit "", 6, 50 197 230 20, center read
  button "New Variable", 7, 3 225 90 25
  button "Edit Variable", 8, 98 225 90 25
  button "Delete Variable", 9, 193 225 90 25
  text "Variable", 10, 5 260 40 20, center
  text "Info", 11, 5 285 40 20, center
  edit "", 12, 50 257 230 20, left autohs
  edit "", 13, 50 283 190 20, left autohs
  button "Done", 14, 245 283 35 20
  list 15, 5 257 275 150, hsbar vsbar sort check
  button "Delete Variable(s)", 16, 95 410 100 25
} 

on *:dialog:variables:*:*: {
  if ($devent == close) { unset %vubutton %vmvars }
  if ($devent == init) { 
    did -b $dname 8,16
    var %i 1
    while (%i <= $var(%*,0)) {
      did -i $dname 2,15 %i $var(%*,%i)
      inc %i
    }
    did -z $dname 2,15 125 500
    dialog -t $dname Variable Manager $+($chr(91),$did(2).lines,$chr(32),Variables,$chr(93)) 
  }
  if ($devent == sclick) {
    if ($did == 2) {
      if ($did(2).seltext) {  
        did -e $dname 8
        dialog -s $dname -1 -1 285 255
        did -ra $dname 4 $did(2).seltext
        did -ra $dname 6 $var($did(2).seltext,1).value
      }
    }
    if ($did == 7) { 
      set %vubutton 1 
      dialog -s $dname -1 -1 285 310 
      did -e $dname 12 
      did -r $dname 4,6,12,13
      did -u $dname 2,15
      did -b $dname 8
      did -h $dname 15
      did -v $dname 10-14
      var %t 1
      while (%t <= $did(15).csel) {
        did -l $dname 15 %t
        inc %t
      }
      dialog -t $dname Variable Manager $+($chr(91),$did(2).lines,$chr(32),Variables,$chr(93))
    }
    if ($did == 8) { 
      set %vubutton 2 
      dialog -s $dname -1 -1 285 310 
      did -r $dname 4,6
      did -bra $dname 12 Editing: $did(2).seltext
      did -ra $dname 13 $var($did(2).seltext,1).value
      did -u $dname 2,15
      did -b $dname 8
      did -h $dname 15
      did -v $dname 10-14
      var %t 1
      while (%t <= $did(15).csel) {
        did -l $dname 15 %t
        inc %t
      }
      dialog -t $dname Variable Manager $+($chr(91),$did(2).lines,$chr(32),Variables,$chr(93))
    }
    if ($did == 9) { 
      dialog -s $dname -1 -1 285 440
      did -u $dname 2,15
      did -b $dname 8
      did -v $dname 15
      did -h $dname 10-14
      did -r $dname 4,6,12,13
    }
    if ($did == 14) { 
      if (%vubutton == 1) { 
        if ($did(12).text && $did(13).text) {
          if ($count($did(12).text,$chr(32)) < 1 && $left($did(13).text,1) != $chr(32)) {
            set $iif($left($did(12).text,1) != $chr(37), $+($chr(37),$did(12).text), $did(12).text) $did(13).text 
            did -a $dname 2 $iif($left($did(12).text,1) != $chr(37), $+($chr(37),$did(12).text), $did(12).text)
            dialog -s $dname -1 -1 285 255
            did -r $dname 2,15
            unset %vubutton
            var %i 1
            while (%i <= $var(%*,0)) {
              did -i $dname 2,15 %i $var(%*,%i)
              inc %i
            }
            dialog -t $dname Variable Manager $+($chr(91),$did(2).lines,$chr(32),Variables,$chr(93))
          }
        }
        else { dialog -s $dname -1 -1 285 255 }
      }
      if (%vubutton == 2) { 
        if ($len($did(13).text) >= 1) { 
          if ($did(13).text != $var($did(13).text,1)) { 
            set $gettok($did(12).text,2,32) $did(13).text 
            unset %vubutton
            dialog -s $dname -1 -1 285 255 
            dialog -t $dname Variable Manager $+($chr(91),$did(2).lines,$chr(32),Variables,$chr(93))
          }
        }
        else { dialog -s $dname -1 -1 285 255 }
      }
    }
    if ($did == 15) {
      if ($did(15).csel >= 1) { 
        did -e $dname 16 
        if ($did(15,$did(15).sel).cstate == 1) { set %vmvars $addtok(%vmvars,$did(15).seltext,32) } 
        if ($did(15,$did(15).sel).cstate == 0) { set %vmvars $remove(%vmvars,$did(15).seltext)  }
      }
      if ($did(15).csel == 0) { 
        unset %vmvars
        did -b $dname 16
        did -u $dname 15
      }
    }  
    if ($did == 16) { 
      if ($input(Delete Variable(s),cy,Delete Variable(s)?)) { 
        tokenize 32 %vmvars
        unset $1-
        unset %vmvars
        dialog -s $dname -1 -1 285 255 
        did -r $dname 2,15
        did -b $dname 16
        var %i 1
        while (%i <= $var(%*,0)) {
          did -i $dname 2,15 %i $var(%*,%i)
          inc %i
        }
        dialog -t $dname Variable Manager $+($chr(91),$did(2).lines,$chr(32),Variables,$chr(93))
      }
      else {
        unset %vmvars
        did -r $dname 2,15
        var %t 1
        while (%t <= $did(15).csel) {
          did -l $dname 2,15 %t
          inc %t
        }
        did -u $dname 15
        did -b $dname 16
        dialog -s $dname -1 -1 285 255 
      }
    }
  }    
}

Comments

Sign in to comment.
Scakk   -  Sep 22, 2008

Completely redid this one.

 Respond  
Scakk   -  Oct 05, 2007

Deleted the wrong two post of mountaindew\'s

New I forgot something >_<

Added it in the other two places.

 Respond  
guest598594   -  Oct 05, 2007

ugh sorry for double post

 Respond  
Scakk   -  Oct 05, 2007

Changed that pert.

 Respond  
guest598594   -  Oct 05, 2007
      if ($$?\"Continue with edit? Yes or No.\" == Yes) {

u can just do

  if ($$?!=\"Continue with edit?\" == $true) {

that shows an input box with a yes button and a no button

 Respond  
Scakk   -  Oct 05, 2007

1) Buttons updated.
2) Ability to delete one or all variables added.
3) Added some checks to parts.

 Respond  
Scakk   -  Oct 05, 2007

Will update the buttons , add the delete variable or variables and make a few other changes.

 Respond  
guest598594   -  Oct 05, 2007

4) Are you saying change the name of the buttons \"Add\" and \"Delete\"?

yea, me and rubixcube both thought of it as adding and deleting the variable entirely

 Respond  
Scakk   -  Oct 05, 2007

u shuold disable add/remove until u specify a variable
u should add a button to entirely delete the variable
ask for input on addtok and remtok for a delimeter
i thought add/remove would add or remove the whole variable, i think u shuold make it \"add token\" and \"remove token\"

1) The \"Add\" and \"Delete\" buttons will not work unless you specify a variable to change.
2) I will add one shortly.
3) The Info box and Input Popups show what delimeter is already present in the variable so you know what to use. The only one it chnages is $chr(32) to $chr(44).
4) Are you saying change the name of the buttons \"Add\" and \"Delete\"?

Why not have it edit the variable manually and then have a button to completely set the new input. I also had the same idea of the add/remove as mountaindew. You should probably make those include a new or remove an old variable and just have an editor.

Editing the variable manually is done using the \"Add\" and \"Delete\" buttons. I have the \"New %\" for adding new variables. I will add a button to it to make it where you can delete entire variables.

 Respond  
guest598594   -  Oct 05, 2007

i like the editor idea, then you wouldnt have to worry about delimeters and tokens, just like write in an edit box \"echo $did($dname,).seltext\"

 Respond  
RubixCube   -  Oct 05, 2007

Why not have it edit the variable manually and then have a button to completely set the new input. I also had the same idea of the add/remove as mountaindew. You should probably make those include a new or remove an old variable and just have an editor.

 Respond  
guest598594   -  Oct 05, 2007

this is a great idea, but it needs some work

u shuold disable add/remove until u specify a variable
u should add a button to entirely delete the variable
ask for input on addtok and remtok for a delimeter
i thought add/remove would add or remove the whole variable, i think u shuold make it \"add token\" and \"remove token\"

otherwise, its pretty good so far

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.