mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2006
Posts: 10
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Jul 2006
Posts: 10
hey, I wrote this script to read several files, and output the text to a channel. here is the script (alias FAHREAD is at line 4):
Code:
alias FAHREAD {
  scid 1 {
    if ($status != connected) {
      halt
      }   if (%udaline > %udaline.bak) {
      set %udaline %udaline.bak
    }
    set %udanumlines $lines(D:\program files\UD monitor\UDm Logs\Log.txt)
    if (%udaline > %udanumlines) {
      set %udaline 0
    }
    if (%udaline < %udanumlines) {
      if (%udaline < %udanumlines) {
        inc %udaline 
        msg #ubergeeks $read(D:\program files\UD monitor\UDm Logs\Log.txt,%udaline)
      }
    }
    if (%wuline > %wuline.bak) {
      set %wuline %wuline.bak
    }
    set %wunumlines $lines(D:\program files\UD Monitor\UDm Logs\WUs.txt)
    if (%wuline > %wunumlines) {
      set %wuline 0
    }
    if (%wuline < %wunumlines) {
      while (%wuline < %wunumlines) {
        inc %wuline
        msg #ubergeeks $read(D:\program files\UD monitor\UDm Logs\WUs.txt,%wuline)
      }
    }
    set %fahnumlines $lines(D:\program files\folding@home\FAHlog.txt)
    if (%fahline > %fahline.bak) {
      set %fahline %fahline.bak
    }
    if (%fahline > %fahnumlines) { 
      set %fahline 0
    }
    if (%fahline < %fahnumlines) {
      if ($calc(%fahnumlines - %fahline) < 6) {
        while (%fahline < %fahnumlines) {
          inc %fahline
          while ($remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35)) == $null) {
            inc %fahline
          }
          msg #ubergeeks $remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35))
        }
      }
      else { 
        inc %fahline
        while ($remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35)) == $null) {
          inc %fahline
        }
        msg #ubergeeks $remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35))
      }
    }
  }
  set %fahline.bak %fahline
  set %udaline.bak %udaline
  set %wuline.bak %wuline
}
this occaisonally locks up mIRC, I have to use ctrl+break to recover. after the script stops, mIRC indicates the script was stopped at line 45 and the script runs normally. it's locked up several times, enough for me to be writing this post. the FAH log looks something like this(the line that the script locked was either 10, or 11. I'm not sure.
Quote:
[03:42:14] Folding@home Core Shutdown: FINISHED_UNIT
[03:42:17] CoreStatus = 64 (100)
[03:42:17] Sending work to server
[Intentionally Left Blank]
[ILB]
[03:42:18] + Attempting to send results
[03:56:57] + Results successfully sent
[03:56:57] Thank you for your contribution to Folding@Home.
[03:56:57] + Number of Units Completed: 180
[ILB]
[03:57:13] - Preparing to get new work unit...
[03:57:13] + Attempting to get work packet
[03:57:13] - Connecting to assignment server
[03:59:07] - Successful: assigned to (171.64.65.58).
[03:59:07] + News From Folding@Home: Welcome to Folding@Home

this is what was output to the channel, both before the script locked up, and after
[20070316204216] <~igor> [03:42:14] Folding@home Core Shutdown: FINISHED_UNIT
[20070316204218] <~igor> [03:42:17] CoreStatus = 64 (100)
[20070316204218] <~igor> [03:42:17] Sending work to server
[20070316204218] <~igor> [03:42:18] + Attempting to send results
[20070316204846] <~igor> 2007.0316 20.48.46: #2: Save (+ 0.32.15)
[20070316205658] <~igor> [03:56:57] + Results successfully sent
[20070316205658] <~igor> [03:56:57] Thank you for your contribution to Folding@Home.
[20070316205658] <~igor> [03:56:57] + Number of Units Completed: 180
* Break: command halted (line 45, script1.ini)
[20070316213915] Closing Link: igor[fish.net] (Ping timeout)
[20070316213915] * Disconnected
[20070316213920] * Connect retry #1 zirc.org (6668)
[20070316213925] * Attempting to rejoin channel #ubergeeks
[20070316213928] * Rejoined channel #ubergeeks
[20070316213928] * ChanServ changes topic to 'Folding@Home log output channel (igor)'
[20070316213928] * ChanServ sets mode: +ntroq igor igor
[20070316213929] <~igor> [03:56:57] + Results successfully sent
[20070316213932] <~igor> [03:56:57] Thank you for your contribution to Folding@Home.
[20070316213935] <~igor> [03:56:57] + Number of Units Completed: 180
[20070316213937] <~igor> [03:57:13] - Preparing to get new work unit...
[20070316213939] <~igor> [03:57:13] + Attempting to get work packet
[20070316213941] <~igor> [03:57:13] - Connecting to assignment server
[20070316213943] <~igor> [03:59:07] - Successful: assigned to (171.64.65.58).
[20070316213945] <~igor> [03:59:07] + News From Folding@Home: Welcome to Folding@Home

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I noticed some unnecessary usage of braces, as well as some duplication of IF statements.
Since I don't have the text files in order to test this properly, here's a little re-write with the modifications made. This might be sufficient to resolve your problem. Please ensure that you let us know, one way or the other.
Code:
alias FAHREAD {
  scid 1 
  if ($status != connected) {      
    if (%udaline > %udaline.bak) {
      set %udaline %udaline.bak
    }
    set %udanumlines $lines(D:\program files\UD monitor\UDm Logs\Log.txt)
    if (%udaline > %udanumlines) {
      set %udaline 0
    }
    if (%udaline < %udanumlines) {
      inc %udaline 
      msg #ubergeeks $read(D:\program files\UD monitor\UDm Logs\Log.txt,%udaline)
    }
    if (%wuline > %wuline.bak) {
      set %wuline %wuline.bak
    }
    set %wunumlines $lines(D:\program files\UD Monitor\UDm Logs\WUs.txt)
    if (%wuline > %wunumlines) {
      set %wuline 0  
    }
    while (%wuline < %wunumlines) {
      inc %wuline
      msg #ubergeeks $read(D:\program files\UD monitor\UDm Logs\WUs.txt,%wuline)
    }
    set %fahnumlines $lines(D:\program files\folding@home\FAHlog.txt)
    if (%fahline > %fahline.bak) {      
      set %fahline %fahline.bak    
    }
    if (%fahline > %fahnumlines) {       
      set %fahline 0    
    }
    if ($calc(%fahnumlines - %fahline) < 6) {
      while (%fahline < %fahnumlines) {
        inc %fahline
        while ($remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35)) == $null) {
          inc %fahline
        }
        msg #ubergeeks $remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35))
      }
    }
    else { 
      inc %fahline
      while ($remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35)) == $null) {
        inc %fahline
      }
      msg #ubergeeks $remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35))
    }
  }
  set %fahline.bak %fahline
  set %udaline.bak %udaline
  set %wuline.bak %wuline
}

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
The following piece of code is a recipe for lockups
Code:
while ($remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35)) == $null) {
          inc %fahline
        }
Once %fahline grows bigger than %fahnumlines, $read() will return $null (as the line with index %fahline does not exist), thus $remove() will return $null too, and since you're just /inc-ing %fahline in that loop, it will go on forever.

Apart from that, I can see what seem to be logic errors, for example
Code:
   if (%udaline > %udanumlines) {
      set %udaline 0
    }
    if (%udaline < %udanumlines) {

If %udaline is greater than %udanumlines, it is set to 0. Since 0 is less than %udanumlines, the second if condition will always succeed. I believe that's not what you intended (if you did intend that, the second if statement is redundant since it will always be true so you may as well remove it) and that you meant "else if" instead of "if" in the second statement.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
Perhaps to better understand what the script is doing... use the -s switch with /set and /inc. The -s switch enables verbose display of variables.

/inc -s %varaible
/set -s %varaible [value]



Beware of MeStinkBAD! He knows more than he actually does!
Joined: Jul 2006
Posts: 10
G
Pikka bird
OP Offline
Pikka bird
G
Joined: Jul 2006
Posts: 10
Originally Posted By: qwerty
The following piece of code is a recipe for lockups
Code:
while ($remove($read(D:\program files\folding@home\FAHlog.txt,%fahline),$chr(35)) == $null) {
          inc %fahline
        }
Once %fahline grows bigger than %fahnumlines, $read() will return $null (as the line with index %fahline does not exist), thus $remove() will return $null too, and since you're just /inc-ing %fahline in that loop, it will go on forever.
ok, I've updated the script so that it's an IF, which uses the same syntax as the while, but instead executes a GOTO which is placed right after the msg
Originally Posted By: qwerty
Apart from that, I can see what seem to be logic errors, for example
Code:
   if (%udaline > %udanumlines) {
      set %udaline 0
    }
    if (%udaline < %udanumlines) {

If %udaline is greater than %udanumlines, it is set to 0. Since 0 is less than %udanumlines, the second if condition will always succeed. I believe that's not what you intended (if you did intend that, the second if statement is redundant since it will always be true so you may as well remove it) and that you meant "else if" instead of "if" in the second statement.
I have that set to clear the variable when the file is cleared (as it happens when the file exceeds X bytes)


Link Copied to Clipboard