Simple eval script
Posted by B1NG3
Saturday, July 24, 2004
Description: Simple eval script

This is a simple eval script with error handling and use of [] so a function is not called twice. What makes this better than most eval scripts is the use of $error for error handling, lots of commenting and the lack of use of the $eval function.

alias e {
  if ([ [ $$1- ] ]) say $1- == $ifmatch
  else say $1- == $!null
  return
  ;if an error occurs lets catch it :)
  :error
  var %retval = $error
  ;remove the () via $regsub so our output is sexy
  if ($regsub(%retval,\(.+\),$null,%retval)) %retval = $right(%retval,-2)
  else %retval = $right($error,-2)
  ;output the error
  say $1- == %retval
  ;comment reseterror if you want mIRC to show the error locally with more info
  reseterror
}


What makes this better:

Standard eval scripts using $eval($1-,2) tend to call a funtion twice.
eg. $findfile($logdir,*#script*,1,echo -a $$read($1-,w,*#script*)) will show:
(oldtimestamp) <binge> #script r teh kewlies
(oldtimestamp) <binge> #script r teh kewlies
(newtimestamp) <+binge> $findfile($logdir,*#script*,1,echo -a $$read($1-,w,*#script*)) == #script.GameSurge.NET

while my script using [ [ $1- ] ] will show:
(oldtimestamp) <binge> #script r teh kewlies
(newtimestamp) <+binge> $findfile($logdir,*#script*,1,echo -a $$read($1-,w,*#script*)) == #script.GameSurge.NET
the one i use is easier
Posted by variant
Saturday, July 24, 2004 06:26pm PDT
the one i use is easier o_O got it off the site somewhere and just added process time..
here si teh it
Posted by variant
Saturday, July 24, 2004 06:26pm PDT

alias eval {
  var %ticks $ticks
  msg $active $1- == $iif($($1-,2) == $null,$($null,0),$($1-,2)) [pt: $+ $calc($ticks - %ticks) $+ ms]
}

alias se {
  var %ticks $ticks
  echo $active $1- == $iif($($1-,2) == $null,$($null,0),$($1-,2)) [pt: $+ $calc($ticks - %ticks) $+ ms]
}
well duh
Posted by B1NG3
Sunday, July 25, 2004 02:19pm PDT
there are smaller and easier eval scripts out there, but it doesn't mean they are good. Both of the ones you posted don't have $error handling and use exactly what I was saying is bad. (Read the comments on what makes my script better part.)
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world