|
Joined: Feb 2004
Posts: 119
Vogon poet
|
OP
Vogon poet
Joined: Feb 2004
Posts: 119 |
can someone help explain to me.. what $prop is used for? i read the mirc help file and did not understand it. here is an example of a code i found..
alias _get {
if ($0 == 2) && ($prop == unset) { return $hget($1,$2).unset }
elseif ($0 == 2) && ($prop == item) { return $hget($1,$2).item }
elseif ($0 == 2) && ($prop == data) { return $hget($1,$2).data }
elseif ($0 == 2) && ($prop == $null) {
if ($hget($1,$2) != $null) { return $iif($ifmatch != ~null,$ifmatch) }
}
elseif ($0 == 1) && ($prop == size) { return $hget($1).size }
elseif ($0 == 1) && ($prop == $null) { return $hget($1) }
elseif ($0 == 3) && ($prop == $null) { return $hget($1) }
elseif ($0 == 3) && ($prop == item) { return $hget($1,$2).item }
elseif ($0 == 3) && ($prop == data) { return $hget($1,$2).data }
else {
echo SERIOUS ERROR inform $hget(setup,url)
echo PROP:= $prop
echo Pars:= $0
echo Par1:= $1
echo Par2:= $2
echo Par3:= $4
echo Please type /feedback and submit this error and send it. Thanks
}
}
|
|
|
|
Joined: Nov 2003
Posts: 228
Fjord artisan
|
Fjord artisan
Joined: Nov 2003
Posts: 228 |
$identifier(1,2,...,N).prop $prop would return prop
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
Hello, the $prop refers to this part of an identifier : $() .prop The prop stands for "Property" You'll understand better with some examples: (note that the following aliases are only examples of usage of $prop, not identifiers you should actually use, as there are better ways to accomplish things)
alias calcit {
if !$prop { echo -a You must specify a property | return }
if ($prop == min) { return $calc($1 - $2) }
if ($prop == plus) { return $calc($1 + $2) }
} So u can do: //echo -a $calcit(2,3) .plus which would then return the sum of $1 and $2, here being 5 //echo -a $calcit(2,3) .min which would then return the remainder of $1 - $2, here being -1 $prop is really handy as you can simply create them yourself. So you can create properties in scripts of yours, simply by assigning different operations with different values for the property. Another example:
alias colorit {
if ($prop !isnum 1-15) { echo -a Pick a color code between 0 and 15 | return }
return $+(,$iif($prop < 10,0),$abs($prop)) $1-
} This is an identifier that will return the text you passed to the alias, in the color that you chose, thanks to the $prop identifier. So u can do: //echo -a $colorit(this is a test) .7 will echo to you: this is a test //echo -a $colorit(another test) .4 will echo to you: another test I hope that this has helped you to better understand the usage of the $prop identifier. Greetz
Last edited by FiberOPtics; 04/05/04 01:01 PM.
|
|
|
|
Joined: Feb 2004
Posts: 119
Vogon poet
|
OP
Vogon poet
Joined: Feb 2004
Posts: 119 |
back to that code..
_get {
if ($0 == 2) && ($prop == unset) { return $hget($1,$2).unset }
elseif ($0 == 2) && ($prop == item) { return $hget($1,$2).item }
elseif ($0 == 2) && ($prop == data) { return $hget($1,$2).data }
elseif ($0 == 2) && ($prop == $null) {
if ($hget($1,$2) != $null) { return $iif($ifmatch != ~null,$ifmatch) }
}
elseif ($0 == 1) && ($prop == size) { return $hget($1).size }
elseif ($0 == 1) && ($prop == $null) { return $hget($1) }
elseif ($0 == 3) && ($prop == $null) { return $hget($1) }
elseif ($0 == 3) && ($prop == item) { return $hget($1,$2).item }
elseif ($0 == 3) && ($prop == data) { return $hget($1,$2).data }
else {
echo SERIOUS ERROR inform $hget(setup,url)
echo PROP:= $prop
echo Pars:= $0
echo Par1:= $1
echo Par2:= $2
echo Par3:= $4
echo Please type /feedback and submit this error and send it. Thanks
}
}
and i do.. //echo -s $_get(setup,url) >> www.yahoo.comwhat is the $0 , $1, $2, $3, $4 in the code? and what is the ($prop == item) ?? i understand your expenation.. but can't relate to this.
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
Hi,
well it's even stated in the code what it means:
The $1, $2, $3 ... etc are the parameters that get passed to the alias, and $0 represents the total of parameters.
Like in the calcit alias i gave you, you can see if we do $calcit(7,4).plus
$0 is amount of parameters = 2 in this example $1 = 7 $2 = 4 $prop = plus
$prop == item, means that in this script, when the property is .item, it will look up the $2'th item in hash table $1. So you do: $_get(blah,5).item will return to you the 5th item in hash table "blah".
I get the impression that you are not yet very familiar with mirc scripting, so that code might be hard for you to grasp, especially if you wouldn't know what hash tables are.
/help hash tables /help $prop
As with many things...it requires practice to become better at things, and the same goes for mIRC scripting. First make some smaller aliases, try to read a lot of code and understanding what the code does. Try to follow the logics of the script that you are watching. When i look at that _get alias, it makes sense, but for the untrained eye, its probably a bunch of weird stuff.
Greetz
Last edited by FiberOPtics; 04/05/04 01:45 PM.
|
|
|
|
|