mIRC Home    About    Download    Register    News    Help

Print Thread
Problem with && / || function ! #190132 16/11/07 10:06 AM
Joined: Nov 2007
Posts: 7
T
tigger2k Offline OP
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.
Re: Problem with && / || function ! [Re: tigger2k] #190135 16/11/07 11:28 AM
Joined: Jul 2006
Posts: 3,764
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,764
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Problem with && / || function ! [Re: tigger2k] #190137 16/11/07 11:45 AM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
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* }
Re: Problem with && / || function ! [Re: Wims] #190138 16/11/07 11:51 AM
Joined: Nov 2007
Posts: 7
T
tigger2k Offline OP
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 ?

Re: Problem with && / || function ! [Re: Lpfix5] #190139 16/11/07 11:52 AM
Joined: Nov 2007
Posts: 7
T
tigger2k Offline OP
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 !

Re: Problem with && / || function ! [Re: tigger2k] #190141 16/11/07 12:00 PM
Joined: Nov 2007
Posts: 7
T
tigger2k Offline OP
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.
Re: Problem with && / || function ! [Re: tigger2k] #190148 16/11/07 01:32 PM
Joined: Jul 2006
Posts: 3,764
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,764
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.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Problem with && / || function ! [Re: Wims] #190151 16/11/07 03:31 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
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* }
Re: Problem with && / || function ! [Re: Lpfix5] #190152 16/11/07 03:37 PM
Joined: Dec 2002
Posts: 2,024
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,024

...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-
  }
}



Re: Problem with && / || function ! [Re: RoCk] #190154 16/11/07 03:49 PM
Joined: Nov 2007
Posts: 7
T
tigger2k Offline OP
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 !

Re: Problem with && / || function ! [Re: tigger2k] #190155 16/11/07 03:52 PM
Joined: Dec 2002
Posts: 2,024
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,024

Yes you can do that.

Code:

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



Re: Problem with && / || function ! [Re: tigger2k] #190157 16/11/07 04:40 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
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
Re: Problem with && / || function ! [Re: jaytea] #190332 19/11/07 08:47 AM
Joined: Nov 2007
Posts: 7
T
tigger2k Offline OP
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 !!!

Re: Problem with && / || function ! [Re: tigger2k] #190349 19/11/07 02:52 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
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.
Re: Problem with && / || function ! [Re: genius_at_work] #190401 20/11/07 11:58 AM
Joined: Nov 2007
Posts: 7
T
tigger2k Offline OP
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 ! :)
*/

Re: Problem with && / || function ! [Re: tigger2k] #190418 20/11/07 06:50 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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.