mIRC Home    About    Download    Register    News    Help

Print Thread
#78610 09/04/04 08:59 AM
Joined: Jan 2003
Posts: 109
S
Vogon poet
OP Offline
Vogon poet
S
Joined: Jan 2003
Posts: 109
Hi - I'm trying to use the [ and ] brackets not as evaluation brackets but just to put either side of a variable to send to the channel, so something like [ $+ %var $+ ] end result being [thetextinthevariable]

Is it possible to make it not evaluate?

Thanks!

=)


#Newsroom
Where News & Markets Connect
http://www.inewsroom.net
#78611 09/04/04 09:05 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
$+([,%var,])

#78612 09/04/04 09:14 AM
Joined: Jan 2003
Posts: 109
S
Vogon poet
OP Offline
Vogon poet
S
Joined: Jan 2003
Posts: 109
great - thanks alot Collective =)


#Newsroom
Where News & Markets Connect
http://www.inewsroom.net
#78613 09/04/04 02:04 PM
Joined: Dec 2002
Posts: 102
M
Vogon poet
Offline
Vogon poet
M
Joined: Dec 2002
Posts: 102
In other cases where you find yourself needing to display a character that's normally reserved for another purpose (the pipe | is a good example) you can use $chr() to display it:

//echo -s Ascii: $asc($?=Character?)

if you put a pipe in you should get 124. In your script you can use: $chr(124) and it will display a pipe instead of breaking up commands:

//echo thing1 | thing2
//echo thing1 $chr(124) thing2



-
MIMP
#78614 09/04/04 08:01 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Since you're speaking of the use of [ and ].. i still dont quite understand whats the usage and where to apply it. Would anyone mind helping me? smile

Thanks, Zyzzy.


"All we are saying is give peace a chance" -- John Lennon
#78615 09/04/04 10:52 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

the evaluation brackets are used to "evaluate what is in between those brackets", before processing the code.

It is often used to evaluate dynamic variables. I hope you know what dynamic variables are.

They represent a range of variables who have the same characteristics.
Lets say for example u have a range of dynamic variables who all begin with %friend.

Example:

%friend.zyzzy yes
%friend.john yes
%friend.linda no
%friend.jack yes

So its always %friend.nickname value

Now suppose u have an on join event to determine if the person that joins is a friend or not.

Code:
 
on *:JOIN:#{ if (%friend.$nick == yes) msg # A friend of mine has joined the channel } 

This is clearly wrong, because in this case mirc will try to see if there is a variable called %friend.$nick with a certain value.

That is wrong, because we don't have variables called %friend.$nick
We use actual names like john or linda. In other words, we need to evaluate the identifier $nick first, to find out what the meaning is of $nick, and then look in our variables section if that nickname is a friend or not

So thats where evaluation brackets come in:

--> if (%friend. [ $+ [ $nick ] ] == yes ) {

This will first evaluate $nick , which could be "zyzzy", and then it will go and look in the variables section if "zyzzy" is a friend or not. Since %friend.zyzzy shows 'yes' it will match as a friend.

Note how we do not use [ [ $nick ] ], but use [ $+ [ $nick ] ]

The $+ identifier groups words together, otherwise we would end up with looking for %friend. zyzzy , which is of course not what we want. We want %friend.zyzzy



Summary:

%friend.$nick --> nothing is evaluated, and mirc will look for a variable called %friend.$nick

%friend. [ $+ [ $nick] ] --> mirc first evaluates $nick which will return a name like zyzzy, then mirc will look at the variable %friend.zyzzy to determine wheter the value of that variable is yes or no.

Mirc also has another way of evaluating something, which is called $eval. You can find documentation about that by doing /help $eval in mirc, or using the "Search" function on this forum, or by asking someone to explain to u how $eval worx. I wont explain it right now as I think you should first try to grasp the idea of why and where evaluation is needed.

I hope this was somewhat helpful, and that you understand a bit better what evaluation brackets are for.

Greetz


Gone.
#78616 09/04/04 11:06 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
FiberOPtics, thank you very much for the lesson, i apreciate the time you took to write!!!! laugh grin

I'll try some basic scripts and put that new knowledge in practice! smile

Thanks a bunch!!

Zyzzy laugh


"All we are saying is give peace a chance" -- John Lennon
#78617 10/04/04 12:34 AM
Joined: Jan 2003
Posts: 109
S
Vogon poet
OP Offline
Vogon poet
S
Joined: Jan 2003
Posts: 109
cool thanks for the tip MIMP - I often need to display these characters in my newsroom, so good to know this stuff!

=)


#Newsroom
Where News & Markets Connect
http://www.inewsroom.net
#78618 10/04/04 12:59 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

I believe the following alias might be good for you then (just paste it in your alias section) :
Code:

ascii { 
  if ($1 isnum) echo -a Ascii character for number $1 ==> $chr($1) 
  else { var %char = $1 | echo -a Ascii number for character $1 ==> $asc(%char) }
} 

The var %char is needed, because mirc won't process certain characters like a "," or a "#"

To use it, simply type /ascii <number or character> without the < >

Enjoy


Gone.
#78619 10/04/04 03:38 AM
Joined: Jan 2003
Posts: 109
S
Vogon poet
OP Offline
Vogon poet
S
Joined: Jan 2003
Posts: 109
great thanks =)


#Newsroom
Where News & Markets Connect
http://www.inewsroom.net
#78620 10/04/04 06:34 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
You're welcome!

I only noticed now that i forgot a ':' in my on join code, so it should be:

on *:JOIN:#: { ...

Greetz


Gone.
#78621 20/09/04 11:25 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
And here I go correcting myself 5 months later grin

While it is true that certain chars won't be processed correctly if you would do //echo -a $asc(char) (a comma, # or other characters come to mind), it is also irrelevant, as it is already stored in the parameter $1.

Code:
 
ascii {
  if $$1 isnum { echo -ac info * Ascii character for number $1 ==&gt; $chr($1) }
  else { echo -ac info * Ascii number for character $1 ==&gt; $asc($1) }
} 
lol


Gone.
#78622 21/09/04 05:45 AM
Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
*hugs $iif*

alias ascii {
echo -ac Info * Ascii number for $iif($$1 isnum,number $1 ==> $chr($1),character $1 ==> $asc($1))
}

Eamonn.

#78623 21/09/04 09:57 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
*hugs readability* grin

Wasn't really the point of the reply to myself, and it's probably easier for relatively new scripters (or non-scripters) to understand.

/me feels haunted...me runs!


Gone.
#78624 21/09/04 10:22 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Btw, try /ascii 78 with your script :tongue:

* Ascii number for number 78 ==> N

Number for number? See even you can't read it anymore now :tongue:

Lol this is all a joke though, don't be offended, it's sure not intended that way, just fun :tongue:

Greets grin

Last edited by FiberOPtics; 21/09/04 10:23 AM.

Gone.
#78625 21/09/04 10:33 AM
Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
blah, missed that one! laugh

Besides, readability is overrated!

Eamonn.

#78626 21/09/04 02:16 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hehe.


Gone.

Link Copied to Clipboard