mIRC Home    About    Download    Register    News    Help

Topic Options
#196112 - 09/03/08 11:04 PM Evaluation of #-sign
gencha Offline
Ameglian cow

Registered: 04/11/04
Posts: 22
Loc: Frankfurt/Main, Germany
In my script i have a list of identifier names that are supposed to be used to process messages a user writes.
These identifiers fulfill purposed like nick-completion, replacing acronyms or replacing common typos.

To illustrate, i have this alias in the script:
Code:
; Applies a single input processor to the globally stored input text
alias _applyProcessor {
  %g_inputText = $( $+( $, $1, %OPEN_PARANTHESIS, %g_inputTarget, %COMMA, %g_inputText, %CLOSE_PARANTHESIS ), 2 )
}


I found it to be the best solution to take a string, turn it into an identifier and apply it.

Sadly it needs $eval() (or $()), which results in unwanted behavior. Namely, it will replace the #-sign with the current channel name.

I wonder how to get around that. And help ideas are appreciated wink

Top
#196114 - 09/03/08 11:24 PM Re: Evaluation of #-sign [Re: gencha]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3463
Loc: France
Try to use $chr(35) instead of #
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#196115 - 09/03/08 11:30 PM Re: Evaluation of #-sign [Re: Wims]
gencha Offline
Ameglian cow

Registered: 04/11/04
Posts: 22
Loc: Frankfurt/Main, Germany
Like, how? The user puts in the #.

Top
#196117 - 10/03/08 12:03 AM Re: Evaluation of #-sign [Re: gencha]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Try replacing the # characters with a character you know won't appear in the text, like a linefeed.

Code:
alias _applyProcessor {
  %g_inputText = $replace($( $+( $, $1, %OPEN_PARANTHESIS, %g_inputTarget, %COMMA, $replace(%g_inputText,$(#,),$lf), %CLOSE_PARANTHESIS ), 2 ),$lf,$(#,))
}


Whether this works perfectly will depend on what you're calling, what it does, and what it returns.

Top
#196122 - 10/03/08 04:51 AM Re: Evaluation of #-sign [Re: gencha]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
# is barely the least of your concerns if you're evaluating non-code as mIRC script... you should take a hard look at your design.
_________________________
- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"

Top
#196125 - 10/03/08 06:37 AM Re: Evaluation of #-sign [Re: argv0]
gencha Offline
Ameglian cow

Registered: 04/11/04
Posts: 22
Loc: Frankfurt/Main, Germany
Well, this is the first issue that popped up. Do you have a suggestion maybe?

Top
#196156 - 10/03/08 11:31 PM Re: Evaluation of #-sign [Re: gencha]
gencha Offline
Ameglian cow

Registered: 04/11/04
Posts: 22
Loc: Frankfurt/Main, Germany
argv0 helped me solved this. This is the final solution:
Code:
alias _applyProcessor {
  %g_inputText = $( $+( $, $1, %OPEN_PARANTHESIS, %g_inputTarget, %COMMA, $( %g_inputText, 0 ), %CLOSE_PARANTHESIS ), 2 )
}

Top