mIRC Home    About    Download    Register    News    Help

Print Thread
#83582 20/05/04 05:44 PM
Joined: Jun 2003
Posts: 195
N
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
The other day i decided to script for the first time in a while. I needed a custom identifier that could accept properties but didnt really need any arguments. The following may help show what i mean
Code:
Alias SomeIdent {
   if ($prop == SomeProp) return SomeValue
   return SomeOtherValue
}

Notice nowhere do i refference any arguments so something like this would be handy

var %Variable = $SomeIdent.SomeProp

Instead you have to call it using $SomeIdent(filler).SomeProp

Also instead of making a new post ill just add it here. How about refferences to variables. I know codematr suggested some time ago but i cant find it now and i dont think he got much response to it. example is as follows
Code:
Alias FillVar {
   $1 = "filled"
}


Code:
Alias Test {
   var %fil
   $FillVar(%fill)
   echo -a %fill
}


calling /Test would echo filled. Fillvar fills the value into the variable passed to it.

Note: in the above sample im not concerning with the mIRC format or its calling convention ill leave that up to khaled smile

Last edited by Narusegawa_Naru; 20/05/04 05:54 PM.

Have Fun smile
#83583 20/05/04 05:53 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Yeah, that would be great, shouldn't be too hard to add either.


New username: hixxy
#83584 20/05/04 05:55 PM
Joined: Jun 2003
Posts: 195
N
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
lol im assuming you mean about the props since i was just editing the post for the other suggestion.


Have Fun smile
#83585 20/05/04 07:09 PM
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Regarding your first suggestion; quite some of my scripts use dots in alias names, and this would break all of them. I'd rather see $myalias().prop being supported, ie. just the parentheses and no need for a filler. A detail maybe, but an important detail. smile

About the second suggestion, I believe that the general outcome of the last discussion about it was that you can achieve the same by just /return'ing a list of tokens. I'm not saying it's a bad suggestion, though...


Saturn, QuakeNet staff
#83586 20/05/04 07:44 PM
Joined: Apr 2004
Posts: 73
Z
Babel fish
Offline
Babel fish
Z
Joined: Apr 2004
Posts: 73
Hey there,

Your first idea is a great one, although as Sat said, there are some aliases that already use .'s in their name (for example something like: $passwd.id)... But, if there was a way mIRC could detect it after the (), that should eliminate that problem.

-Zelda4ever
aka "The Big 'Z'"


/tokenize 32 $gettok($1-,1-,32)
#83587 20/05/04 08:54 PM
Joined: Jun 2003
Posts: 195
N
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
well technically using . in alias names is not really mIRC's format.
there are some intrinsic identifiers that dont use arguments however like i said the actual format is not as important.
I dont think forcing the () empty argument list would even be worth the time since the following 2 lines only differ by one byte

$blah(1).prop -and-
$blah().prop

however mIRC could check to see if the alias using the . existed and if such call it otherwise call the alias with the prop

On idea 2 the main reason for refferences would be fewer calls to identifiers.
assume you have an alias wich returns color values for several properties such as text bg etc.. using the original method

Code:
var %color = $get_clr(text)
use %color
%color = $get_clr(bg)
use %color


using the returned token idea
Code:
var %color_tokens = $get_clr
parse token 1 for text color and use it
parse token 2 for colors and use it


using refferences
Code:
var %clrText,%clrBkg
$get_clr(%clrText,%clrBkg)
use both as you wish


With only two arguments you only see a slight advantage but imaging one that needs to accept 5 or 8 arguments

using method one you call the alias 5 to 8 times.
using the token method you call the alias once then parse the return value (another call to an identifer) 5 to 8 times.
Using refferences you call the alias once and your done. This can be heaps faster and smaller.

Last edited by Narusegawa_Naru; 20/05/04 09:03 PM.

Have Fun smile
#83588 21/05/04 05:29 AM
Joined: Dec 2002
Posts: 266
Z
Fjord artisan
Offline
Fjord artisan
Z
Joined: Dec 2002
Posts: 266
Yes, this broke my $day challenge I made a few years ago wink


You won't like it when I get angry.
#83589 21/05/04 09:53 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
A filler can also be a single space character, eg $myident( ).prop works smile


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#83590 21/05/04 02:55 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Maybe:
alias x.x { }
Could have priority over:
alias x {
if $prop == x { }
}


New username: hixxy
#83591 21/05/04 03:20 PM
Joined: Jun 2003
Posts: 195
N
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2003
Posts: 195
ya thats what i meant above. smile


Have Fun smile
#83592 21/05/04 04:00 PM
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Yup, that would be fine too.

qwerty: sure, but that's still a kludge. I'd guess that getting mIRC to accept zero arguments as well would be little work, and it'd be quite a bit neater. smile


Saturn, QuakeNet staff
#83593 21/05/04 04:07 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Agreed, if $id( ).prop works, $id().prop should too. I just offered the quickest/handiest filler, for those who didn't know, until the feature is added.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#83594 25/05/04 04:01 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:

The other day i decided to script for the first time in a while. I needed a custom identifier that could accept properties but didnt really need any arguments. The following may help show what i mean
var %Variable = $SomeIdent.SomeProp
Instead you have to call it using $SomeIdent(filler).SomeProp


Hi,

I'm curious why you don't just use the argument as property then. A good idea imo, would be simply to use the parameter $1 as you would use $prop

alias SomeIdent {
if $1 == prop1 { return SomeValue }
if $1 == prop2 { return SomeOtherValue }
...
return ValueThatCameWithoutProperty
}

The usage would be: var %Variable = $SomeIdent(Someprop) if you want to use a property.
And var %Variable = $SomeIdent if you have no need for a property.

Regarding your second suggestion: I would LOVE to see that, great suggestion.

Greetz

Edited post

Last edited by FiberOPtics; 25/05/04 04:21 PM.

Gone.

Link Copied to Clipboard