mIRC Homepage

Evaluation of #-sign

Posted By: gencha

Evaluation of #-sign - 09/03/08 11:04 PM

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
Posted By: Wims

Re: Evaluation of #-sign - 09/03/08 11:24 PM

Try to use $chr(35) instead of #
Posted By: gencha

Re: Evaluation of #-sign - 09/03/08 11:30 PM

Like, how? The user puts in the #.
Posted By: hixxy

Re: Evaluation of #-sign - 10/03/08 12:03 AM

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.
Posted By: argv0

Re: Evaluation of #-sign - 10/03/08 04:51 AM

# 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.
Posted By: gencha

Re: Evaluation of #-sign - 10/03/08 06:37 AM

Well, this is the first issue that popped up. Do you have a suggestion maybe?
Posted By: gencha

Re: Evaluation of #-sign - 10/03/08 11:31 PM

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 )
}
© 2022 mIRC Discussion Forums