/exec

By hixxy on Oct 18, 2005

/exec will let you execute code in VBScript. You can also return values by using $exec.

The code is commented with an explanation and some examples.

/*

What does /exec do?

/exec will let you execute code in one of two languages: VBScript or mIRC.

How do I use /exec?

The syntax is: /exec <language name> <code> -or- $exec(<language name>, <code>)
You can use $exec(<language name>, <code>) to get the return value from the script executed if there is one.

How does /exec work? (For scripters)

/exec uses a COM object (MSScriptControl.ScriptControl) to execute code in (J/VB)Script.

Can you show me an example?

I'll show you two examples for each supported language, the examples use $& for readability.

VBScript:

1)
exec VBScript $&
  While MsgBox("Do you like my snippet?", vbYesNo) <> vbYes $crlf $&
  Wend
2) echo -a $exec(VBScript, Now)

mIRC:

1)
exec mIRC $&
  var $+(%, x) = that $(|,) echo -a $+(%, x)
2) echo -a $exec(mIRC, return $time)

Is there anything else I should know about /exec?

Yes, when using the mIRC code executor everything is evaluated an extra time, so $exec(mIRC, return $!time) would still return the time.

*/

alias exec {
  if ($1 == VBScript) {
    var %exec = $+(exec, $ticks)
    .comopen %exec MSScriptControl.ScriptControl
    if ($com(%exec)) {
      .echo -q $com(%exec, Language, 4, bstr, $1)
      if (!$isid) { .comclose %exec $com(%exec, ExecuteStatement, 3, bstr, $2-) }
      else {
        .echo -q $com(%exec, Eval, 3, bstr, $2)
        var %result = $com(%exec).result
        .comclose %exec
        return %result
      }
    }
  }
  elseif ($1 == mIRC) {
    tokenize 124 $2-
    scon -r $( $* , 2)
  }
}

Comments

Sign in to comment.
hixxy   -  Jan 12, 2012

I only responded like that because of the manner in which you wrote your initial comment. You implied my script was broken rather than asking for help.

The two example scripts work fine. Try them :)

 Respond  
hm2k   -  Jan 12, 2012

Likewise, all you've done is criticise my initial code rather than offering even a hint of a solution.

I'm unlikely to go out of my way to give you constructive criticise now am I? You've done yourself no favours.

 Respond  
hixxy   -  Jan 12, 2012

Which part of my documentation isn't clear enough?

This is the part of my documentation that shows the code examples:

1)
exec VBScript $&
  While MsgBox("Do you like my snippet?", vbYesNo) <> vbYes $crlf $&
  Wend
2) echo -a $exec(VBScript, Now)

This is how you used the script:

 var %code = exec VBScript $&
  While MsgBox("Do you like my snippet?", vbYesNo) <> vbYes $crlf $&
  Wend
echo -a $exec(VBScript, %code)

That is nothing like what my documentation says.

Feel free to provide constructive criticism of my documentation and/or the script itself. So far your claims are baseless.

 Respond  
hm2k   -  Jan 12, 2012

If my code was incorrect, I can only put that down to your poor documentation.

I have no use nor interest in this script, but you should consider fixing it for other users.

 Respond  
hixxy   -  Jan 12, 2012

It worked, you just used it wrong. The script that you've now deleted was incorrect.

 Respond  
hm2k   -  Jan 12, 2012

If it never worked, I never used it.

 Respond  
hixxy   -  Jan 12, 2012

I have no idea, you clearly couldn't use it so I'm not sure.

 Respond  
hm2k   -  Jan 12, 2012

wow, why was I ever interested in this junk?

 Respond  
Sorasyn   -  Jan 11, 2012

There's something about code evaluation that I like. For VBS users this would be, more or less, a major tool in their mIRC arsenal. I've actually been looking to do the same with a Java bot client I've been working on although the out look is dim without third party support...

 Respond  
hixxy   -  Jan 11, 2012

Only just noticed this comment. I provided a working example. What you've done is butchered my example and then said it doesn't work. Look at what I wrote and what you wrote...there's a difference.

 Respond  
hm2k   -  May 23, 2008

.

 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.