mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
I've been looking at this script and it's driving me crazy. it's opening the socket and executing the first sockwrite, but then I'm getting this error:
* /goto: 'TO' not found (line 114, mail.mrc)
Here's the code:
Code:
on *:sockread:sendmail:{
  sockread %temptext
  echo -a %temptext
  write mailtemp.txt %temptext
  :START
  if (220 isin %temptext) { sockwrite -n $sockname helo $host | goto FROM }
  :FROM
  if (250 isin %temptext) { 
    if (%250.From != 1) {  
      echo From does not equal 1
      sockwrite -n $sockname MAIL From: $+ %email 
      set %250.From 1
      goto TO 
    }
    else {    
      goto TO 
    }  
  }
}
:TO
if (250 isin %temptext) { 
  if (%250.To != 1) {
    sockwrite -n $sockname RCPT To: $+ %toaddress 
    set %250.To 1
    goto DATA 
  }  
  else {
    goto DATA  
  }
}    
:DATA
if (250 isin %temptext) { 
  if (%250.Data != 1) {
    sockwrite -n $sockname data 
    set %250.Data 1
    goto QUEUE
  }  
  else {
    goto MSG  
  }
}    
:MSG
if (354 isin %temptext) {
  sockwrite -n $sockname From: %email
  sockwrite -n $sockname Date: $date
  sockwrite -n $sockname Subject: %subject
  sockwrite -n $sockname $crlf
  sockwrite -n $sockname %body 
  sockwrite -n $sockname . 
  unset %250 $+ *  
  set %MSG 1
}
:QUEUE
echo -a %temptext
sockwrite -n $sockname quit
goto END
:END
if (221 isin %temptext) {
  if (%MSG = 1) {
    unset %MSG
    unset %250 $+ *
    sockwrite -n $sockname quit  
  }
}

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
If you notice the indentation of the code, you'll see that you have a bracket mismatch somewhere, so mirc thinks the :TO and :FROM labels are outside the on sockread event. Use the {} button in Editor to check for mismatches.

On a sidenote, at least half of your goto commands are redundant and only make your code harder to read and maintain. You should generally avoid using goto and keep in mind that a script is executed line by line, so there is no point in having something like:
Code:
  :START
  if (220 isin %temptext) { sockwrite -n $sockname helo $host | goto FROM }
  :FROM
mirc will go to FROM either way, that is whether the if condition succeeds or fails, simply because :FROM is the next line.


Also, instead of having something like this:
Code:
  if (something) {
    <commands>
    goto LABEL
  }
  else {
    goto LABEL
  }
you can have something like this:
Code:
  if (something) {
    <commands>
  }
  goto LABEL
The above 2 are equivalent.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard