mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2007
Posts: 7
T
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Nov 2007
Posts: 7
Hiho @ all,
sorry for my worse englisch, but i do my best ! smile

I am workin on several scripts and each time its the same prob.

If i do an if function with and/or seperators the script do not work if there is an linebreak.

for Example:
on *:TEXT:*:* {
if (%show != on) { halt }
var %line $strip($1-)
if ((*option1* iswm %line) || (*option2* iswm %line)) {
echo -g @lookilooki [ $date - $time ] - [ $chan ] $chr(32) $+ $strip($1-) $+
var %ifexist $null
var %ifexist $read(show.txt, s, $strip($2))
if (%ifexist == $null) {
/write show.txt $date $time $chan $strip($1-)
}
}
}
the script ^^ works fine



on *:TEXT:*:* {
if (%show != on) { halt }
var %line $strip($1-)
if ((*option1* iswm %line) ||
(*option2* iswm %line)) {
echo -g @lookilooki [ $date - $time ] - [ $chan ] $chr(32) $+ $strip($1-) $+
var %ifexist $null
var %ifexist $read(show.txt, s, $strip($2))
if (%ifexist == $null) {
/write show.txt $date $time $chan $strip($1-)
}
}
}
this script ^^ will not work



I use Mirc 6.16.
For Scripting i use UltraEdit.

What do i wrong ?!?

mille thx
tigger2k

Last edited by tigger2k; 16/11/07 10:10 AM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
You don't use the correct syntax :

Code:
if ((*option1* iswm %line) || (*option2* iswm %line)) {
or
if (*option1* iswm %line) { same command here }
if (*option2* iswm %line) { same command here }


But the first method is the best, and you should use it everytime


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
remember an IF statement should be checking its statements on the same line while the commands can be on seperate lines


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Nov 2007
Posts: 7
T
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Nov 2007
Posts: 7
Yes, this possible too.
I know, but i schrink the script that i can post it here.
If there round about 200 lines, and more, its to much or not ?

Isn t it possible to use && || with an linebreak ?

Joined: Nov 2007
Posts: 7
T
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Nov 2007
Posts: 7
Originally Posted By: Lpfix5
remember an IF statement should be checking its statements on the same line while the commands can be on seperate lines


thx...

thats what i doesn t know till yet...

if is only possible at the same line !

Joined: Nov 2007
Posts: 7
T
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Nov 2007
Posts: 7
Ok, if i understand right i possible can use an other way..

on *:TEXT:*:* {
if (%show != on) { halt }
var %line $strip($1-)
;options
if (*option1* iswm %line) { goto gon }
elseif (*option2* iswm %line) { goto gon }
elseif (*option3* iswm %line) { goto gon }
else { stop }
;no option match = script end !
:gon
echo -g @lookilooki [ $date - $time ] - [ $chan ] $chr(32) $+ $strip($1-) $+ {
/write show.txt $date $time $chan $strip($1-)
}
}
}


is it right !?

Last edited by tigger2k; 16/11/07 12:44 PM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Yes but here is a better way to do what you want :
Code:
on *:TEXT:*:*:{
if (%show != on) return
tokenize 32 $strip($1-)
;options
if (*option1* !iswm $1-) && (*option2* !iswm $1-) && (*option3* !iswm $1-) stop
;no option match = script end !
echo -g @lookilooki [ $date - $time ] - [ $chan ] $chr(32) $+ $1- $+ {
/write show.txt $date $time $chan $1-
}



Edit : thx Lpfix5 & Rock

Last edited by Wims; 16/11/07 03:45 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Wims you added *option1* twice


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

...and it should be && instead of ||

Code:

on *:TEXT:*:*: {
  if (%show != on) return
  tokenize 32 $strip($1-)
  ;options
  if ((*option1* !iswm $1-) && (*option2* !iswm $1-) && (*option3* !iswm $1-)) return
  ;no option match = script end !
  echo -g @lookilooki [ $date - $time ] - [ $chan ] $chr(32) $+ $1- $+ {
  write show.txt $date $time $chan $1-
}


or

Code:

on *:TEXT:*:*: {
  if (%show != on) return
  tokenize 32 $strip($1-)
  ;options
  if ((*option1* iswm $1-) || (*option2* iswm $1-) || (*option3* iswm $1-)) {
    ;option match = script continue !
    echo -g @lookilooki [ $date - $time ] - [ $chan ] $chr(32) $+ $1- $+ {
    write show.txt $date $time $chan $1-
  }
}



Joined: Nov 2007
Posts: 7
T
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Nov 2007
Posts: 7
Yes, but than i have a long line again wich i do not want.

In Mirc Help i found the $& identifier.
With this , help tells, its possible to split long lines into multiple.

like
if ($&
(*option1* iswm $1-) || $&
(*option2* iswm $1-) || $&
(*option3* iswm $1-))


I try to if i m home again !

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

Yes you can do that.

Code:

if $& 
  ((*option1* iswm $1-) || $&
  (*option2* iswm $1-) || $&
  (*option3* iswm $1-))



Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
in this case it's also possible to use:

Code:
if ($count($1-,option1,option2,option3)) 


there's almost always little tricks like this you can use to shorten or make your code cleaner/easier to follow, trick is to know what to use when laugh


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Nov 2007
Posts: 7
T
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Nov 2007
Posts: 7
So i try all ur tipps and i think the best way is to use
elseif (*option2* iswm %line) { goto gon }

If i use the if || $& option it only works with round about 30 arguments, then the script msg error !

count i haven t use till now, so perhaps i will try it later !

thx for ur help !!!

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Remember that mIRC commands are limited to about 950 characters. Lines that have $& to make them look shorter are actually part of the same command, so all of the lines lengths must be added together. If you have 30 arguments, you are likely at the 950 character limit.

If you post the exact code you are trying to create (without substitution if possible), then someone may be able to help you make a more efficient version of your code.

Another option you could use is this:

Code:

var %s = 0
if (*option1* iswm $1) %s = 1
elseif (*option2* iswm $1) %s = 1
elseif (*option3* iswm $1) %s = 1
...
elseif (*option300* iswm $1) %s = 1

if (%s == 1) return



-genius_at_work

Last edited by genius_at_work; 19/11/07 02:54 PM.
Joined: Nov 2007
Posts: 7
T
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Nov 2007
Posts: 7
The script i m using now works fine, in original it has 130 lines, so i hope i make no mistake by posting it here !

Code:
on *:TEXT:*:* {
  if (%show != on) { halt } 
  var %line $strip($1-)
  if (Option Section 1 begins here iswm %line) { goto gon }
    elseif (*Option1* iswm %line) { goto gon }
    elseif (*or*Option*2* iswm %line) { goto gon }
    elseif (*or_Option3_EP?* iswm %line) { goto gon }
  elseif (Other Option Section* iswm %line) { goto gon }
    elseif (*Option1* iswm %line) { goto gon }
    elseif (*or*Option*2* iswm %line) { goto gon }
    elseif (*or_Option3_EP?* iswm %line) { goto gon }
 elseif (*Option checking ends* iswm %line) { goto gon }
    else { halt }
:gon { if ((*[Word1]* iswm %line) || (*[other]* iswm %line)) { halt }
       if ((*Other* iswm %line) || (*text*to*stop* iswm %line)) { halt } 
         echo -g @lookilooki [ $date $time ]-[ $chan $nick ] $chr(32) $+ $strip($1-) $+ 
          /write show.txt $date $time $chan $nick $strip($1-)
   }
}
;A Menu system
menu @lookilooki {
  Enable:set %show on | echo -g @lookilooki $time 12SHOW is now active ..
  Disable:set %show off | echo -g @lookilooki $time 4SHOW is now off ..
  REload:echo -g @lookilooki  $time 12SHOW reloaded | reload -rs Z:\path to my script001_show.mrc
  UNload:echo -g @lookilooki  $time 4SHOW is now off | Unload -rs Z:\path to my script.mrc
  Clear Window:/clear @lookilooki
}

/*
Here are some Comments what the hell im doin ! :)
*/

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Quick suggestion, making use of a hash table and the $hfind feature

Code:
on *:text:*:*: {
  ; if the hash tabe does not exist, trigger the "make table" alias 
  if (!$hget(iswmtable)) { make.iswm.table }
  var %line = $strip($1-)
  ; check %line for any wilcard match of all the items in the hash table
  if ($hfind(iswmtable,%line,0,W)) {
    echo $target iswm per hfind triggers: $v1 items wildmatch the text.
  }
}

; creating a hash table holding all the words for your "many words" iswm comparison
alias make.iswm.table {
  hadd -m iswmtable *test*
  hadd iswmtable *something*
  hadd iswmtable *word*
}

Last edited by Horstl; 20/11/07 07:03 PM.

Link Copied to Clipboard