mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2004
Posts: 7
I
ircbum Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Sep 2004
Posts: 7
Hello,
I am trying to write a script to capture all XDCC pack lines in any channel window.
However, I am getting the message displayed in the channel window: "IF( Unknown command"
Does anyone know what is wrong with my if statement at the bottom of the code?
I searched this error and only found one related post, but no solution.

Thanks in advance,


Code:
 
on *:TEXT:*#*:#: { 

  ;------------- DECLARE LOCAL VARIABLES
  /var %TEXT_TO_REPLACE = @@
  /var %stripped_text
  /var %temp
  /var %text_line = $1-

  ;------------ STRIP ALL EXTRA CHARACTERS FROM THE TEXT

  ; Strip all codes from the line of text
  %stripped_text = $strip(%text_line)

  ; replace ASCII 93 = ']' AND ASCII 91 = '['
  %temp = $replace(%stripped_text,$chr(93),%TEXT_TO_REPLACE) 
  %temp = $replace(%temp,$chr(91),%TEXT_TO_REPLACE)

  ; replace ASCII 40 '(' and ASCII 41 ')'
  %temp = $replace(%temp,$chr(40),%TEXT_TO_REPLACE)
  %temp = $replace(%temp,$chr(41),%TEXT_TO_REPLACE)

  ; replace ASCII 124 '|'
  %temp = $replace(%temp,$chr(124),%TEXT_TO_REPLACE)

  ; replace '' AND ''
  %temp = $replace(%temp,,%TEXT_TO_REPLACE)
  %temp = $replace(%temp,,%TEXT_TO_REPLACE)

  %temp = $replace(%temp,@@,)

  ;------------- WRITE THE PROCESSED TEXT TO FILE

  /var %left_text = $left(%temp,1)
  /var %ascii_val = $asc(%left_text)

  if( $asc(#) == %left_text){
  /write $mircdir $+ \z_output.txt %temp
  /echo true
}
else{
/write $mircdir $+ \z_skipped_output.txt %temp
/echo false
}

 
crazy

Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
there must be a space after the IF and ELSE
so instead of
if( $asc(#) == %left_text){
it should be
if ($asc(#) == %left_text) {

Joined: Sep 2004
Posts: 7
I
ircbum Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Sep 2004
Posts: 7
Hey, thanks for the pointer... now i no longer get the Unknown
command error, however I am running into another problem.
I am trying to compare a character to the # character and do something if it is an equivalent character.

However this if statemnt only outputs false, that is it always goes to the ELSE section... any idea why?


Code:
;get the 1st character on the left side of the text line
  /var %left_text = $left(%temp,1)

  /echo LeftText is: %left_text

  if (%left_text == #) {
    /write $mircdir $+ \z_output.txt %temp
    /echo true
  }
  else {
    /write $mircdir $+ \z_skipped_output.txt %temp
    /echo false
  }

  

Last edited by ircbum; 21/09/04 08:40 PM.
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
use $chr(35) instead of # because mIRC thinks # is the current channel name in events that are triggered from a channel.

Joined: Sep 2004
Posts: 7
I
ircbum Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Sep 2004
Posts: 7
Hi, thanks for all of your help!

Mirc scripting is very tricky and even though i am fairly good at programming in other languages.. it really helps to know all of the mirc scripting tricks. Are there any good references besides under Mirc->Contents of the program?

Last edited by ircbum; 21/09/04 11:03 PM.
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
i learned everything i know now by just using Help -> Search...

I started by writing a bot thats still in use 2 years later and as i needed to add new features i used the help file to find out how to do it.

Perhaps not the best way of learning how to script as i only knew bits that were involved in my bot. After 2 years i still havn't mastered hash tables, @ windows, picture windows, binary files and regex as i havn't used them in my bot.

Joined: Jun 2003
Posts: 5,024
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Jun 2003
Posts: 5,024
mIRC is not a file trading program.

You do not need to specify the / before commands in a script. You can find scripting tutorials at sites such as mirc.net and mircscripts.org.

Regards,


Mentality/Chris

Link Copied to Clipboard