mIRC Home    About    Download    Register    News    Help

Print Thread
#223450 25/07/10 03:00 AM
Joined: May 2007
Posts: 37
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: May 2007
Posts: 37
Hi there,

I've been looking into COMs recently, and I've run across a dilemma. My problem is that I'm trying to retain a variable across two different COM objects. For example:

$com(a,method,2) is invoked, and I would like to use the value of this operation in another COM - $com(b,method,bstr,value of a's result)

Obviously I can use $com(b,method,bstr,$com(a).result), however this runs into problems in that I am using very large strings that surpass mIRC's variable limit.

Has anyone got any suggestions how to pass the value of the first call as a parameter to the second? I was wondering if it had anything to do with using * after the type, as I don't fully understand what this does.

Thanks!

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Hi Chessnut, long time no speak! laugh

Cannot be done in the way that you're thinking, but there is a long and somewhat hacky workaround. You can use COM to interpret VBscript which of course doesn't have the line length limits. Then you can have it write the results that you need to a file, which you can then $read or /bread (depending on length) to gain access to the data in mIRC.

This is my old /exec|$exec snippet which you can look at for ideas:

Code:
/*
 
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)
  }
}


Of course you'll need to know a bit of VBscript too.

Hope this helps!

FYI, I've just posted a feature suggestion to add binary variable support to $com.

hixxy #223462 25/07/10 12:32 PM
Joined: May 2007
Posts: 37
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: May 2007
Posts: 37
Hey hixxy - very long time no speak, hope you've been well!

I originally wrote the script using VBScript and interpreting it, and was trying to convert it to pure mIRC COM calls. I was really hoping it could be done, but apparently not!

It's a shame $com result values can't be loaded into a bvar. I did make the suggestion ages ago but nothing came of it.

Ah well, thanks for the help!

Edit: In fact I didn't realise Mpdreamz had posted a suggestion for exactly what I wanted to do! https://forums.mirc.com/ubbthreads.php?ub...&Main=36759 and the suggestion I thought I'd made was actually me replying to another Mpdreamz' post: https://forums.mirc.com/ubbthreads.php?ub...&Main=35855

Last edited by Chessnut; 25/07/10 12:38 PM.

Link Copied to Clipboard