mIRC Home    About    Download    Register    News    Help

Print Thread
Custom Operators. #183356 19/08/07 09:30 AM
Joined: Aug 2007
Posts: 13
I
iStink Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Aug 2007
Posts: 13
I was thing about my scripts when i suggest this.
Anyway... {
My scripts are usually challenging, and simple... BUT: I like them to be clean. so i dont like to see the little boxes. instead I use $+($chr(3),03) I don't use $+ alone. it must have multiple paramaters for me to even use $+ smile
Anyway!! To the point {
The custom operator would be nice versus using an alias like: $iif(isowner $nick $chan,,)
you could use $iif($nick isowner $chan)
I've been thinking about it and my buddies think its a great idea.
the operators could be stored in their own tab on the scripts editor, and they could have the option in the remotes section (where you can put everything lol)
would be an example of:
Code:
operator isowner {
return $iif($nick(#,$nick).pnick == ~,$true,$false)
}

Re: Custom Operators. [Re: iStink] #183360 19/08/07 10:39 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I thought I'd seen an isowner operator in the help file already, and that Khaled had mentioned that it only worked on certain types of networks, but I was unable to locate where I was getting this information from in order to confirm it.

Re: Custom Operators. [Re: iStink] #183361 19/08/07 11:08 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Why don't simply use good old aliases to set this operation:
Code:
alias isowner { return $iif((~ isin $nick(#$2,$1).pnick),$true,$false) }
...and go on evaluating this "operation" in your script with:
Code:
if ($isowner($nick,$chan)) { stuff }
else { elsestuff }
or:
Code:
$iif(($isowner($nick,$chan)),ifstuff,elsestuff)


"if ($isowner($nick,$chan))" is as short as a hypothetical "if ($nick isowner $chan)", isn't it? smile

At first, I liked the idea of custom operators. But then: these operations can be scripted with ease (as shown above). Finally, there is a lot of "operations" we'd use in scripts that need more parameters than v1 and v2, imho here the use of aliased "operations" is inevitable smile

Aliases are far more flexible: $some_returning_alias(param1,param2,...,paramN).property_possible

Re: Custom Operators. [Re: iStink] #183362 19/08/07 11:48 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
I'd love to see this, but your way of doing things is a little odd. I'd prefer that we have access to $v1/$v2 from within the operator.

Code:
operator " { return $v1 $+ $v2 }


var %x = x " y

xy

Originally Posted By: Horstl
Why don't simply use good old aliases to set this operation:


The flow of using an alias within the script is not as logical:

if ($isowner($nick,$chan))

Reads (in my head): if isowner nick on chan

if ($nick isowner $chan)

Reads (again in my head): if nick isowner on chan

It's a lot more logical.

Re: Custom Operators. [Re: hixxy] #183363 19/08/07 11:58 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Originally Posted By: hixxy
Reads (in my head): if isowner nick on chan
Well, mine is reading "if isowner is true for nick on chan" smile
I did not want to dismiss the whole custom operator idea at all... I just cannot think of any crucial advantage so far

Re: Custom Operators. [Re: Horstl] #183364 19/08/07 12:03 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
There isn't really, it's purely a syntax thing, although I imagine it'd be slightly faster to parse operators than it would identifiers.

Re: Custom Operators. [Re: iStink] #183367 19/08/07 01:51 PM
Joined: Aug 2007
Posts: 13
I
iStink Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Aug 2007
Posts: 13
well, i dont like aliases and identifiers as much as i do operators, because they make scripts look cleaner. commas make scripts look sloppy (to me) and so does the rest of the 11k people who script on the swiftirc network, smile I'm saying that putting in more things that people want or would use, they would use the product better. and var %money = 11000 * 20
while (%money) noop

Re: Custom Operators. [Re: iStink] #183374 19/08/07 02:33 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Even if custom operators were possible they would still need a prefix to distinguish them from ordinary text, otherwise you could end up with horrible problems like:
if (hello moo [color:red]newoperator %blah) ...[/color]
becoming
if (hello [color:red]moo newoperator %blah) ...[/color]
if a new script introduced a moo operator.

So with that in mind, is:
$iif($nick [color:red]$~isowner $chan)[/color]
(assuming $~ as the operator prefix) really much cleaner than
$iif($isowner($nick, $chan))

There are some uses to having custom operators, I just don't think saving a couple of commas is one of them.

Note 1: As RusselB mentioned, mIRC already has an undocumented operator isowner which works as expected on most networks that support it.

Note 2: If you call an alias in an event then all special identifiers (such as $nick and $chan) will be available to the alias too. So if you're really worried about commas you could write a custom identifier like this:
Code:
alias isowner {
  var %chan = $iif($2,$2,$chan), %nick = $iif($1,$1,$nick)
  return $iif($nick(%chan, %nick).pnick == ~, $true, $false)
}


and call it as:
Code:
if ($isowner) ...

inside events.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Custom Operators. [Re: starbucks_mafia] #183465 20/08/07 04:59 AM
Joined: Aug 2007
Posts: 13
I
iStink Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Aug 2007
Posts: 13
Originally Posted By: starbucks_mafia
Even if custom operators were possible they would still need a prefix to distinguish them from ordinary text, otherwise you could end up with horrible problems like:
if (hello moo [color:red]newoperator %blah) ...[/color]
becoming
if (hello [color:red]moo newoperator %blah) ...[/color]
if a new script introduced a moo operator.

So with that in mind, is:
$iif($nick [color:red]$~isowner $chan)[/color]
(assuming $~ as the operator prefix) really much cleaner than
$iif($isowner($nick, $chan))

There are some uses to having custom operators, I just don't think saving a couple of commas is one of them.

Note 1: As RusselB mentioned, mIRC already has an undocumented operator isowner which works as expected on most networks that support it.

Note 2: If you call an alias in an event then all special identifiers (such as $nick and $chan) will be available to the alias too. So if you're really worried about commas you could write a custom identifier like this:
Code:
alias isowner {
  var %chan = $iif($2,$2,$chan), %nick = $iif($1,$1,$nick)
  return $iif($nick(%chan, %nick).pnick == ~, $true, $false)
}


and call it as:
Code:
if ($isowner) ...

inside events.

Well...
What you said above wont work in $nick(#,$nick).pnick if they were +q in a network that only supports ohv, or @%+.
Second, this is off topic but i wanted to know how you make an alias that can use the extra paramaters outside of the parenthases, eg: $eaten(%food).percent
smile Other words, i LOVE mIRC, and as sOON as I can muster up $20 ill buy it.
EDIT:{
Sorry about the large quote, im too lazy to look for stuff cuz im not usually a forum-eer

Last edited by iStink; 20/08/07 05:00 AM.
Re: Custom Operators. [Re: iStink] #183468 20/08/07 05:16 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
look up /help Custom Identifiers

e.g.:
Code:
alias custom {
  if ($prop == int) { return $int($1) }
  elseif ($prop isnum) { return $round($1,$prop) }
  else { return $1 }
}

//echo -a $custom($pi).int --- $custom($pi).3 --- $custom($pi)
returning: 3 --- 3.142 --- 3.14159265358979323846

(well, it's a quite witless example whistle )

Originally Posted By: iStink
What you said above wont work in $nick(#,$nick).pnick if they were +q in a network that only supports ohv, or @%+.
...Nor will a custom operater work in this case

Re: Custom Operators. [Re: RusselB] #183469 20/08/07 06:05 AM
Joined: Dec 2002
Posts: 155
S
Strider Offline
Vogon poet
Offline
Vogon poet
S
Joined: Dec 2002
Posts: 155
Originally Posted By: RusselB
I thought I'd seen an isowner operator in the help file already, and that Khaled had mentioned that it only worked on certain types of networks, but I was unable to locate where I was getting this information from in order to confirm it.


From the full versions.txt:
Quote:
23/09/99 - mIRC v5.61
...
2.Improved support for IRCX servers:

Added property $nick().owner, isowner if comparison, and "q"
property to $nick(#,N,aohvrq,aohvrq) where "q" is for owners.
...

Re: Custom Operators. [Re: Strider] #183470 20/08/07 06:44 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I didn't think I was going crazy...just didn't check the right location...tried looking on the forums and in the help files for versions 6.2, 6.21 and 6.3

Re: Custom Operators. [Re: starbucks_mafia] #183545 20/08/07 07:46 PM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Originally Posted By: starbucks_mafia
Even if custom operators were possible they would still need a prefix to distinguish them from ordinary text, otherwise you could end up with horrible problems like:
if (hello moo [color:red]newoperator %blah) ...[/color]
becoming
if (hello [color:red]moo newoperator %blah) ...[/color]
if a new script introduced a moo operator.

So with that in mind, is:
$iif($nick [color:red]$~isowner $chan)[/color]
(assuming $~ as the operator prefix) really much cleaner than
$iif($isowner($nick, $chan))


Perhaps a more subtile method is possible:

//if (hello=hello2) echo -a $v1 and $v2
is the same as if (string)

//if (hello =hello2 hello) echo -a $v1 and $v2
is the same as if (hello = hello) which is valid but deprecated
so hello2 is basicly cut off. However mIRC could in this case try to evaluate what its cutting off smile

same with
//if ($nick =opper $chan) echo -a $v1 and $v2
//if ($nick ==opper $chan) echo -a $v1 and $v2
//if ($nick !=opper $chan) echo -a $v1 and $v2


this opens up the possibility to call alias opper with $1 and $2 and perhaps a new alias $negate returning true when negated.
the called alias just returns $true or $false.

isopper is a bad example because if ($isopper) is much more cleaner in my opinion but i guess theres situations where the above can come in really handy.


$maybe
Re: Custom Operators. [Re: iStink] #183749 22/08/07 11:09 AM
Joined: Aug 2007
Posts: 13
I
iStink Offline OP
Pikka bird
OP Offline
Pikka bird
I
Joined: Aug 2007
Posts: 13
this is getting out of hand.
First off, (lol)
I had only used isowner as an example.
there could be stuff like isquadratic, or isregexmatch, ishex, isbin(ary) ishelpful isword, isblank isdone isopen isactive isheld isnick iswmword iswmwordcs so its endless for the properties for what they can manage versus aliases when they dont have $v1 or $v2.
if you want more operators, ill suggest them smile
but isowner isnt all of what im worried about... it could also be that is $nick isactive $chan, seeing how long they have been inactive/idle on $chan.
Another question, what is the difference between $~calc and $calc ?

Re: Custom Operators. [Re: iStink] #183752 22/08/07 11:25 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Personally, I don't see a reason to create additional operators when the function is already available. And just because you don't like the look of it doesn't really mean it's a good thing to add additional ways to do things. Just my opinion. I don't really care either way. I just don't see any legitimate reason for it other than the cosmetic issue you mentioned.


Invision Support
#Invision on irc.irchighway.net
Re: Custom Operators. [Re: iStink] #183865 23/08/07 05:43 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Regarding $~calc and $calc, as far as I can determine, the only differences are:
1) $~calc uses one character more
2) $~calc isn't in the help file.

Re: Custom Operators. [Re: RusselB] #183867 23/08/07 06:35 AM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Originally Posted By: RusselB
1) $~calc uses one character more
2) $~calc isn't in the help file.

3) Doesn't trigger the Identifier Warning
4) Ignores aliases
5) Has a point I can never remember

Re: Custom Operators. [Re: Collective] #183882 23/08/07 11:43 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
4) is $. and $/, $~ has a different purpose but I can't remember either.

Edit: no it's not, I misread what you said.

Last edited by hixxy; 23/08/07 12:32 PM.
Re: Custom Operators. [Re: hixxy] #183885 23/08/07 12:04 PM
Joined: Jul 2006
Posts: 3,582
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,582
$/ can be used when you have a custom alias that already exist in mIRC, exemple :

Code:
alias time return Ga!


$time will return the current time
$/time will return Ga!

I never see $~ before, i wonder what is it's utility.
$. seems to not works in mirc 6.3, not tested in previous version.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Custom Operators. [Re: Wims] #184326 27/08/07 09:19 PM
Joined: Apr 2004
Posts: 759
M
Mpdreamz Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
$/ overides mirc internal alias
[code]
alias ip return dont hack my ip!
[code]

echo -a $ip and $/ip
echo's: 77.251.101.xxx and dont hack my ip!

$. silents identifiers that return a value
this also only works for mIRC internal identifiers ie:
[code]
alias return 5
[code]
//echo -a $dot $.dot $regsub(,,,,%re) $.regsub(,,,,%re) $me $.me
returns 5 5 1 Mpdreamz
the 2nd $dot isn't silenced but the 2nd $regsub and $me are.

Funny thing to note that is if you call $.ip and you have overriden $ip with your own identifier it will return your custum identifier! So we can script a simple alias to see if a mIRC ident is overriden smile

//if ($.ip != $null) echo -a $!ip is overriden by some script

This of course only work when the ident is expected to return a value and of course there's $isalias :p

also note that $/.ip (seems) to be the exact same as $/ip


I'm baffled what $~ip is doing, Khaled if you read this could you shed some light on this ??

it seem $isalias takes into account for . and /
$isalias(......./.ip) will still return $true if aliased
$isalias(~ip) will not

calling $~someCustumIdent wont work, only $~someMircIdent does.

Last edited by Mpdreamz; 27/08/07 09:27 PM.

$maybe