Variables explorer

By LiQuiDFLamE on Nov 22, 2007

A simple dialog to search for variables. Like my hash table explorer, you have the option to search for wildmatches. (e.g If I searched e It would list any variables containing the letter e in them.) Once the list of matches appears, you can click on one to view the content of the variable. You can also double-click on the variable to edit the content.


To open the dialog type: /varexp


If you have any comments, don't hesitate to post them.


Regards.

dialog varexp {
  title "Variable explorer"
  size -1 -1 204 184
  option pixels
  edit "", 1, 5 9 124 20
  button "&Search", 2, 133 6 65 25
  list 3, 4 33 194 100, size
  check "Search for wildmatches", 4, 6 136 133 14
  edit "", 5, 5 160 196 20, disable autohs
}

on *:dialog:varexp:*:*:{ 
  if ( $devent = sclick ) { 
    if ( $did($dname,5).enabled = $true && $did != 5 ) did -b $dname 5
    if ( $did = 2 ) { 
      if ( $did($dname,1).text ) {  
        did -r $dname 3
        if ( $did($dname,4).state = 1 ) { 
          var %x = 1
          while ( $var(%*,%x) ) { 
            if ( $wildtok($v1,$+(*,$did($dname,1).text,*),1,32) ) did -a $dname 3 $ifmatch
            inc %x
          }
        }
        elseif ( $var($+(%,$did($dname,1).text),1) ) did -a $dname 3 $ifmatch
        did -ra $dname 5 $iif($did($dname,3).lines == 0,No matches!,Matched $did($dname,3).lines $iif($did($dname,3).lines == 1,result,results) $+ !)
      }
    }
    if ( $did = 3 ) did -ra $dname 5 $($did($dname,3).seltext,2)
  }
  if ( $devent = dclick && $did = 3 ) did -e $dname 5
  if ( $devent = edit && $did = 5 && $did($dname,3).seltext ) { set $did($dname,3).seltext $did($dname,5).text } 
}

alias varexp { 
  if ( !$dialog(varexp) ) dialog -m varexp varexp
  else dialog -v varexp varexp
}

Comments

Sign in to comment.
Hayate   -  Nov 24, 2007

Agreed. A list would be excellent. Just by looking at the code, you obviously supplement a % to the input, thus if a user types %etc it would return %%etc. Probably the reason mountaindew received no feedback without selecting the wildmatch option. Because it would search %etc out of %%etc when selecting wildmatch. A misfit in the documentation of this script.

Overall, to users of this script, you should not include a % when typing in the variable. And to the author, please back that up with some error checking ($iif($left($did($dname,1).text != %,$+(%,$did($dname,1).text),$did($dname,1).text)) or include it in the documentation. kthx.

 Respond  
guest598594   -  Nov 24, 2007

i wish u listed out the variables :/

and i search %8ball, nothing came up, i had to check the wild match box, then searched %8ball, then it came up

 Respond  
LiQuiDFLamE   -  Nov 22, 2007

The main purpose of this was to really be a quick search and edit script. I didn\'t want to get to thorough, just something quick and simple.

 Respond  
brinxy   -  Nov 22, 2007

Not bad. Could add the option to unset and set variables.

 Respond  
LiQuiDFLamE   -  Nov 22, 2007

Thanks Korvin.

 Respond  
Korvin   -  Nov 22, 2007
        did -ra $dname 5 $did($dname,3).lines matched result(s)!

can be

        did -ra $dname 5 $iif($did($dname,3).lines == 0,no results.,$did($dname,3).lines matched  $iif($did($dname,3).lines == 1,result,results) $+ !)
 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.