$varwm() & /varwm

By Rebellious on Dec 18, 2007

Simple snippet to return all matched variables from your parameters. Can match different types of variables because of iswm. (e.g $varwm(eg) would return all variables matching eg.

$varwm() or /varwm

; --------------------------------------------------
; $varwm & /varwm
; Returns all matched variables based on your parameters.

; Due to using iswm, you can use wildcards. (e.g *ex*par would match all variables equivalent to the *ex*par)

; /varwm <string> simply echoes the matched variables
; $varwm(<string>) returns the matched variables

; Just saw some of those variable explorer snippets and decided to make an alternative.

; Important note: using % @ the beginning of a variable will either return No match or insufficient parameters. So please don't use %. In some cases, $ won't work either. (e.g when using //echo -a)

; --------------------------------------------------

alias varwm { 
  if ($1) { 
    var %x = 1, %n, %t = $iif($1 !iswm %* && $left($1,1) != $chr(47),$+(%,$1),$1)
    while ($var(%*,%x)) { 
      if (%t iswm $v1) %n = %n $var(%*,%x) 
      inc %x
    $iif($isid,return,echo -a) $iif(%n,%n,No match)
  else $err($+($iif($isid,$,/),varwm:) insufficient parameters)

alias -l err { 
  echo $+(-ac,$iif($prop,t)) info * $1-


Sign in to comment.
Rebellious   -  Dec 20, 2007

Tyvm, appreciate the feedback.

MoNoXiDe   -  Dec 20, 2007

I like it, does what it\'s supposed to do well. The code is clean too, good job.

I personally wouldn\'t use a variable explorer, but for those who do, this is nice.

Rebellious   -  Dec 18, 2007

I\'d really appreciate an explanation for such a low score please. Not developing a grudge or anything. Just like to know whats wrong or \'Not useful\' about this snippet so I can make updates.


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.