mIRC Home    About    Download    Register    News    Help

Print Thread
#120882 22/05/05 01:18 AM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
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.

#120883 22/05/05 04:06 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
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 macjackie 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.

#120884 22/05/05 05:41 AM
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
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)

#120885 22/05/05 06:19 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
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 smile

#120886 22/05/05 03:37 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
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
#120887 22/05/05 03:56 PM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
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?

#120888 22/05/05 04:02 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
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:

Code:
alias test {
  var %a
  $null($regsub($1-, m/ ?([?!])\1+/g, \1, %a))
  echo -a msg $!chan %a
  halt
}


Quote:
Input: /test a???!!! b!?? c?!!
Output: msg $chan a?! b!? c?!


New username: hixxy
#120889 22/05/05 08:24 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
love the useage of $null

#120890 22/05/05 09:27 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
You can use any other non-existant identifier too:

Code:
alias t $¯($findfile($mircdir, *, 1, echo -a $1-))


/t


New username: hixxy
#120891 23/05/05 09:45 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
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
#120892 23/05/05 03:42 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Of course.
That's a problem with almost everything.


New username: hixxy
#120893 10/10/05 06:18 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
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.

Link Copied to Clipboard