mIRC Homepage

Appending to variables

Posted By: Alkiser

Appending to variables - 27/08/04 03:51 AM

Howdy,

I'm trying to develop some IRC scripts for my work and have hit a bit of a snag.

I'm trying to do a nick change and want it to read the current users nick and append the text I want after it. So I thought this would work:

nick $me_sometext but only get an error

$me_sometext Erroneous nickname.

I noticed that with passed in paramater variables it seems to work... ie.

/alias /cookie say Don't eat $1's cookie

so if I went /cookie Brian it would produce:

Don't eat Brian's cookie

Just curious why you can't append things to the predefined variables... or if there is a way.. how?
Posted By: biggem001

Re: Appending to variables - 27/08/04 04:06 AM

wat do u mean append things i could help ya out here but ya gotta try to use dummer turms lol or explane more of wat ur trying to do (i suggest talk dummer lol)
Posted By: KingTomato

Re: Appending to variables - 27/08/04 04:13 AM

As a rule of thumb, assume the variable to not have the appending capabilites you see with $1. Almost all do not have the capability, with few exceptions. Whenever you wish to prefix ro append a value to an identifier, use either $+() (concatenation identifier) or the $+'s. Using your eexample, the following would also be acceptable:

alias cookie { say Don't eat $1's cookie }
alias cookie { say Don't eat $1 $+ 's cookie }
alias cookie { say Don't eat $+($1,'s) cookie }

The exceptions (generally) to these however are as follows:

Token identifiers - $1, $2, 3, ....
Directories -- $mircdir, $mididir, $mircexe, $mircini, etc
There are a few others, but just to give you the idea.

So again, to make your problem go away, use either $me $+ <text> or $+($me,<text>)
Posted By: Alkiser

Re: Appending to variables - 27/08/04 04:27 AM

Thanks King, that worked out perfectly. Gives me a better understanding of mirc scripting aswell.

This certainly isn't the PHP programming I'm used to...
© 2020 mIRC Discussion Forums