mIRC Home    About    Download    Register    News    Help

Print Thread
#81854 04/05/04 12:27 PM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
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..

Code:
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
  }
}

#81855 04/05/04 12:36 PM
Joined: Nov 2003
Posts: 228
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Nov 2003
Posts: 228
$identifier(1,2,...,N).prop
$prop would return prop

#81856 04/05/04 12:53 PM
Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
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)

Code:

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:
Code:

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.
#81857 04/05/04 01:27 PM
Joined: Feb 2004
Posts: 119
D
da_hype Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Feb 2004
Posts: 119
back to that code..

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.com
what 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. frown

#81858 04/05/04 01:36 PM
Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
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.

Link Copied to Clipboard