|
arex
|
arex
|
I've got a while (condition) { echo -a $crc(file) /* stuff */ }. This loop may take a minute or two, and my problem is that this loop halts or hangs mIRC while it executes. Is there any way i can use my mIRC in a normal manner while a loop like this executes? (The loop is for crc-checking x number of files)
|
|
|
|
Joined: Dec 2002
Posts: 2,884
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,884 |
There's no direct scripting way to do what you want. mIRC scripting is single-threaded, which means that nothing else can run while another script is processing. The only way to use any kind of multi-threading in mIRC scripting is with the identifiers $comcall() and $dllcall(). It would be pretty easy for someone with a bit of C/C++/Delphi/lower-level-language-of-your-choice to make a DLL with a CRC function. Perhaps there's a way to do compute CRC's with COM aswell, but I don't know.
|
|
|
|
Joined: Apr 2003
Posts: 701
Hoopy frood
|
Hoopy frood
Joined: Apr 2003
Posts: 701 |
If the $crc of a single file takes too long then you have only the alternative given by starbucks_mafia.
However, if you find the delay of $crc'ing one file acceptable, you could use a timer instead of a while loop. Make a separate alias for the loop contents, /set the while index in a %var and use if instead of while, then, when you need to loop, do a /timer 1 0 /aliasname.
This timer will trigger immediately after your previous loop executes AND after handling all other mIRC stuff that was received dureing the $crc. Your mIRC will not timeout then, ofcourse the program will still seem slow since it updates text and editbox contents only between calls to $crc...
|
|
|
|
Joined: Dec 2002
Posts: 787
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 787 |
If your merely looping files, you might find $findfile() useful and fast., for example;
//echo -> $findfile($mircdir,*,0,echo -s -> $1- $crc($1-)) takes but a few seconds to loop the entire mIRC directory (here, its 500 files).
Eamonn.
|
|
|
|
arex
|
arex
|
Okay, i guess i need a DLL that i can call and would return the CRC-string of a file i've specified in $dllcall() then. I do not know any low-level-language good enough my self. Does anyone here know if a DLL like this exists? Or have the time and skills to make one? Would probably be to use for many people.
|
|
|
|
Joined: Dec 2002
Posts: 787
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 787 |
Yeah my appologies, brain sortta went off on one there, n all.
|
|
|
|
arex
|
arex
|
I quote from the help-file: $dllcall() is multi-threaded so it will not halt the script and will call the specified alias once the call returns.
|
|
|
|
Joined: Dec 2002
Posts: 787
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 787 |
I threw together the following DLL , see if its what you were looking for, if not let me know and I'll see what i can do, although it would be helpful for the exact script your trying to use.. $dll(CRC.dll,crc,[color:red]filename)[/color] Do not, include "s in the filename, these are added by the DLL. The .DLL will also return; $dll(CRC.dll,isconn,1) - CONNECTED/NOTCONNECTED in an attempt to check if you are connected to the Internet. $dll(CRC.dll,version,1) - DLL Information. Eamonn.
|
|
|
|
arex
|
arex
|
My problem now is that $dll is not multi-threaded. $dllcall is. I'm not sure how it works, but I think it can't return a value, but just start a process/thread. It would be nice if I could use $dllcall and that would return the CRC-string but I don't think that would work. Another soloution if $dllcall can't return data is to make the dll put the results in a txt-file and let mIRC read the file when the $dllcall is finished. However, I do not know how to do this.
Here is my mIRC-script:
alias crcsjekk { set %tal.sfv.fp $sfile(C:\, SVF File, Check) set %tal.sfv.f $nopath(%tal.sfv.fp) set %tal.sfv.p $nofile(%tal.sfv.fp) set %tal.sfv.lines $lines(%tal.sfv.fp)
var %hits.not.found = 0 var %hits.valid = 0 var %hits.not.valid = 0 var %total.files = 0
var %a = 1 set %tal.crc.msg Checking %tal.sfv.f
window -a @tal.CRC 0 0 640 480
if ($exists(%tal.sfv.fp) == $true) {
while (%a <= %tal.sfv.lines) {
if ( $left($read(%tal.sfv.fp, n, %a),1) != $chr(59) ) { inc %total.files if (%tal.crc.msg != $null) { aline 13 @tal.CRC %tal.crc.msg | unset %tal.crc.msg }
if ($exists(%tal.sfv.p $+ $gettok($read(%tal.sfv.fp, %a), 1, 32)) == $false) { aline 7 @tal.CRC NOT FOUND - $gettok($read(%tal.sfv.fp, %a), 1, 32) | inc %hits.not.found } ;;;;;;;; if ($crc(%tal.sfv.p $+ $gettok($read(%tal.sfv.fp, %a), 1, 32), 2) == $gettok($read(%tal.sfv.fp, %a), 2, 32)) { if ($dll(crc.dll, crc, %tal.sfv.p $+ $gettok($read(%tal.sfv.fp, %a), 1, 32)) == $gettok($read(%tal.sfv.fp, %a), 2, 32)) { aline 3 @tal.CRC VALID - $gettok($read(%tal.sfv.fp, %a), 1, 32) | inc %hits.valid } else { aline 4 @tal.CRC NOT VALID - $gettok($read(%tal.sfv.fp, %a), 1, 32) | inc %hits.not.valid }
}
inc %a
}
aline 13 @tal.CRC Total files: %total.files Valid: %hits.valid Not valid: %hits.not.found Not found: %hits.not.found
}
else { aline 11 @tal.CRC %tal.sfv.fp not found }
}
**EDIT** This may help someone understand some more. Perhaps this will help rewriting the DLL?
<QUOTE> The DLL can return an integer to indicate what it wants mIRC to do:
0 means that mIRC should /halt processing
1 means that mIRC should continue processing
2 means that it has filled the data variable with a command which it wants mIRC to perform, and has filled parms with the parameters to use, if any, when performing the command.
3 means that the DLL has filled the data variable with the result that $dll() as an identifier should return. </QUOTE>
Last edited by arex; 31/08/04 02:25 PM.
|
|
|
|
Joined: Dec 2002
Posts: 787
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 787 |
Currently the DLL, is coded to output the CRC Value and return '3', which i'll look into, but, you should most likely be using $dllcall(crc.dll,aliasname,crc,$mircexe) for example.
Eamonn.
|
|
|
|
arex
|
arex
|
I have this inside a loaded remote script: alias ie { echo -a $1- }
//echo $dllcall(crc.dll,ie,crc,$mircexe) this returns: REC: D:\mIRC\crc.dll
I want the CRC-string, not the filename of the dll :tongue:
|
|
|
|
|