mIRC Home    About    Download    Register    News    Help

Print Thread
Actions according to the text #232562 09/06/11 03:24 PM
Joined: Jun 2011
Posts: 6
M
mur_phy Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2011
Posts: 6
I want to take actions according to the text read, where is the fault?
Code:
alias example {
  set %text $read(info.txt)
  if (%text iswm #op) { echo -s op }
  elseif (%text iswm #ks) { echo -s ks }
  elseif (%text iswm #ud) { echo -s ud }
  else { echo -s 00 }
}

info.txt
#op00001-text information
#ks00002-text information
#ud00003-text information
#0000004-text information

Re: Actions according to the text [Re: mur_phy] #232568 09/06/11 05:11 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You're not being specific enough. What is it exactly you want to match against in those channels?

Are you trying to match the channel topics? If not, please be as detailed as you can so other people can assist you with a better understanding.

Re: Actions according to the text [Re: Tomao] #232569 09/06/11 05:31 PM
Joined: Jun 2011
Posts: 6
M
mur_phy Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2011
Posts: 6
"#" It is the beginning of each line of the. txt
could have been...

info.txt
@op00001-text information
@ks00002-text information
@ud00003-text information
@0000004-text information

The idea is to take a different action according the beginning of the line is chosen at random

Re: Actions according to the text [Re: mur_phy] #232572 09/06/11 05:49 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You have your comparisons backwards. Also, iswm expects a wildcard or it will only match an exact match.

Code:
if (#op* iswm %text) { }


Here's why it's backwards... Reading it the way you have it... If the entire text value (#op00001-text information) is in the wildcard match of #op, then do something. Well, #op00001-text information won't ever be in #op. The other way around, you're checking if #op is in #op00001-text information, which it is.

And for wildcard (iswm) comparisons... #op means an exact match when using iswm. #op* means it must start with #op but can have anything after it. *#op* would be the same as isin, where #op can be anywhere in the match. And *#op would match only if it ended in #op.



Invision Support
#Invision on irc.irchighway.net
Re: Actions according to the text [Re: mur_phy] #232577 09/06/11 08:46 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Well, the $read(info.txt) already performs the random choice of a line stored in the info.txt.

Perhaps this fits what you have in mind:
Code:
alias example {
  var %r = $read(info.txt)
  if (op isin %r) echo -s $v1
  elseif (#ks* iswm %r) echo -s ks
  elseif (#ud* iswm %r) echo -s ud
  elseif (#00* iswm %r) echo -s none
}
Edit - realized the goto is not necessary.

Last edited by Tomao; 09/06/11 10:46 PM.
Re: Actions according to the text [Re: Tomao] #232580 09/06/11 09:12 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I'd recommend leaving the # in there and still using iswm. There is a very good change additional text in those lines will include op or ks and an okay chance of ud or 00.


Invision Support
#Invision on irc.irchighway.net
Re: Actions according to the text [Re: Riamus2] #232584 09/06/11 10:48 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Yes, I heed your advice, Riamus2. I've edited the code...basically it's a reiteration of what you've suggested.

Last edited by Tomao; 09/06/11 10:48 PM.