mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2011
Posts: 21
T
ThatGuy Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Aug 2011
Posts: 21
I am the kind of person that does not like filling a script with a thousand-and-one aliases...but at the same time I realize that it is sometimes necessary to use one.

I got an idea in my head that multiple line %variables could be used at the start of an event; to be called later down the line, rather than having the script look for an alias outside of the event { brackets }

I have searched the forums every way I can think, but came up empty handed. Am I dreaming? Or is it possible to do something like this...
Code:
on *:anyevent: {
  var %this.var = {
    has some code
    on two lines
  }
  stuff happens now and I need to call %this.var
}


If it's not possible, how likely do you think Khaled is to implement this kind of thing in a future version of mIRC

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
That really isn't any better than using an alias even if it were possible.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2011
Posts: 21
T
ThatGuy Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Aug 2011
Posts: 21
You're probably correct. It was worth a shot, right? I will just have to keep on using aliases.

I know that "var %thisvar if (this != that) { you can do this | in a var. } | Technicaly multi-line | But not quite the same..."

Thanks for the speedy reply, Riamus.

Last edited by ThatGuy; 14/10/11 01:57 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I'm just wondering what the benefit would be. Either way, you are including the same amount (actually slightly more) code. It's just inserted in the event instead of an alias. Trying to troubleshoot it later will just be that much more complicated.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2011
Posts: 21
T
ThatGuy Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Aug 2011
Posts: 21
I'm working on helping someone fix their script, and there are multiple occasions were they call an alias that is only used once. I figured that I could insert the $alias into the event as a %var and reduce the file count by one in each occurance.

Instead I have moved the $alias into the same file, above the event.

This brings up a couple more question.
If the $alias is above the event, will it be put in to memory for quicker access later in the event execution?
Is it possible to put some of the information in to a hash table for even quicker execution? I haven't used hash tables enough to know much about them.

Thank you again for your speedy replies.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
If it's only used once, you can usually just insert the commands directly into the location.

Example:

Code:
on *:text:*:#: {
  doecho
}
alias doecho {
  echo @capture $1-
}


Becomes:
Code:
on *:text:*:#: {
  echo @capture $1-
}


Of course, in some instances, an alias works better -- multiple commands needed for /play or /timer, for example. But in general, if you are using the commands in an alias only once, you can just as easily insert them into the script without need of an alias or any new variable syntax.

Afaik, the location of the alias doesn't affect speed because the aliases are "loaded" when the script is loaded, so location no longer matters. Someone can correct me if that isn't right, but I believe it is.

Regarding hash tables, those are not usually the best option for handling commands. Just like with variables, you can use hash tables for commands, but that usually isn't the best way to do something. Hash tables are most beneficial for data storage, where you have a lot of data that is accessed often. If you have very little data, or the data isn't accessed very often, then you lose most of the benefit of hash tables and then other options are usually more efficient. You'd usually use hash tables as a replacement for variables or text/INI files (or in addition to those), but not as a replacement for aliases.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2011
Posts: 21
T
ThatGuy Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Aug 2011
Posts: 21
I had opted for replacing the single-use aliases in to the code, except for the ones that depended on calling additional data before it was utilized.

This brings me to another question, though it pulling away from my initial question.
Is there a limit on the amount of files (.mrc or whatever) that can be loaded? To make my job slightly easier I'm separating each alias, dialog (frame and guts together) and event to its own file. This makes error hunting easier (for me, at least). If there is no limitations on loaded scripts, the rest of the day will be a breeze!

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
There isn't a limit other than memory/drive space. However, having dozens or hundreds of files is really not the best option, imo.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2011
Posts: 21
T
ThatGuy Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Aug 2011
Posts: 21
I am only separating the aliases and events for error tracking. Once I know an alias is working I place it back in to a main file. I can also remove single-use aliases completely.

I also found my answer. After separating aliases for an hour, I checked the file count. It remained at 114. The other files are sitting in my mIRC folder. It seems that no matter what I do, I can not load more. Maybe I'm missing a setting or something...

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Hm... maybe there is a limit then. I have never had anywhere near that many files loaded at a time, so haven't seen any limit. Maybe someone else can verify it. I know there's a limit on open windows that is due to how Windows works, but I doubt this relates to open windows because only one script window is open at a time. So I'm not sure why there would be a limit like that.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard