|
Joined: Jan 2004
Posts: 509
Fjord artisan
|
OP
Fjord artisan
Joined: Jan 2004
Posts: 509 |
Several input questions.
How would I get, in a $1-, to bring up spaces between words and , ! ?'s
For example,
Hello there !, would be, Hello there!
Secondly, how would I remove excessive of them chars.
Huh????? would be Huh?
Thirdly, now depending on the first and second code, there may not be need for a 3rd one.
A Hello there !!!, if the first code does not make it Hello there!!! and the second code does not make that one Hello there!, then yes, a third code to bring the two codes together.
And, in an input $1- string, how would I detect if one $N is before another $N?
For example, if the word 'Jackie' is before the word 'chan' in a $1- string,. I have a code that makes 'chan' 'channel' and was wondering if there was a way to have mirc detect if a certain word is before one, so I could use it in an if statement.
Thanks.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
on *:input:*:{
if ($target && !ctrlenter && !$inpaste) {
;^ must have a taget window and not be in ctrlentered line or a paste
;
tokenize 32 $1- | var %text = $1-
;^ store up $1- into something
;
var %text = $replacex(%text, $chr(32) $+ !,!, $chr(32) $+ ?,?)
;^ part 1(join blah ! to blah!)
;
while ((!! isin %text) || (?? isin %text)) { var %text = $replacex(%text, !!,!, ??,?) }
;^ part 2 (change blah!!!! to blah!)
;
if ($1- != %text) {
;^ somethings changed so cancel this line and reinsert the line into the editbox
;
haltdef | editbox $iif($target == Status Window,-ns,-n $target) %text
}
}
}
the 3rd part i didnt add becuase i cant quite be sure what you wanted. if (*jackie*chan* iswm $1-) { echo -a JACKIE THEN CHAN in $!1- } ^ however that doesnt need them to be whole words it could be "heres mac jackie and the chanters" if ((* jackie * chan * iswm $+($chr(32),$1-,$chr(32))) || (* jackie chan * iswm $+($chr(32),$1-,$chr(32))) { echo -a JACKIE THEN CHAN in $!1- } ^ that well make it whole words, i dont know if its the best method but it works, spaces needed adding around the $1- incase jackie or chan were the first or last words, and there are two wildmatches the second incase jackie and chan are next to each other with no word between.
|
|
|
|
Joined: Aug 2003
Posts: 314
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 314 |
Another way to get rid of the excess ! and ? while removing spaces in front of them is to use the substitution $regsub($1-,/ ?([?!])(?: ?\1)*/g,\1,%var)
Also Dave you missed a $ in !ctrlenter at the top. Might also want to check it's not a command (/* !iswm $1)
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
much nicer the regex is i must say, as to the errors in my script, well that well teach me for writting it in the thread reply window
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
on *:input:#:{
if (!$istok(/ $readini($mircini, text, commandchar), $left($1, 1), 32)) && (!$ctrlenter) && (!$inpaste) {
var %a
$null($regsub($1-, m/ ?([?!])\1+/g, \1, %a))
msg $chan %a
halt
}
}
New username: hixxy
|
|
|
|
Joined: Jan 2004
Posts: 509
Fjord artisan
|
OP
Fjord artisan
Joined: Jan 2004
Posts: 509 |
Hm sorry I don't get yours Sigh_. I tried it in an if statement, /say the whole thing etc. And tidy_trax yours doesn't work for me. Did you actually define %a?
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
Yes, %a is defined. I tested it with an echo to see what would happen and it works fine: alias test {
var %a
$null($regsub($1-, m/ ?([?!])\1+/g, \1, %a))
echo -a msg $!chan %a
halt
} Input: /test a???!!! b!?? c?!! Output: msg $chan a?! b!? c?!
New username: hixxy
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
You can use any other non-existant identifier too: alias t $¯($findfile($mircdir, *, 1, echo -a $1-)) /t
New username: hixxy
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
The only problem is that it might not be inexistant, somebody might have a /null alias.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
Of course. That's a problem with almost everything.
New username: hixxy
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Ok, I know I'm late to answer but what qwerty means is that once there is infact a custom null alias, your code cannot be escaped. In the case of commands, we can always escape with an exclamation mark ! as you know, but this is not possible with identifiers.
I know about the $~<identifier> hack, though it does not work to use as you would use $null.
//echo -a $~null($regex(1,/(\d)/)) -> $regml(1)
vs
//echo -a $null($regex(1,/(\d)/)) -> $regml(1)
That's the main reason I'll never use $null in a construct such as you displayed (I saw Online do that 2 years ago as well), as it's unescapable.
Gone.
|
|
|
|
|