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-
halt
}