mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 3 1 2 3
Identifier to check if on start is mirc starting #234535 02/11/11 01:59 AM
Joined: Nov 2009
Posts: 295
P
pball Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
I have an on start event and the fact it runs when the script is loaded is a problem. I want to set a variable only when mirc starts. So perhaps an $isstart identifier which would return true if the on start event was triggered due to mirc starting or false if the script was loaded.


http://scripting.pball.win
My personal site with some scripts I've released.
Re: Identifier to check if on start is mirc starting [Re: pball] #234536 02/11/11 02:56 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Don't need an identifier for this:

Code:
on *:LOAD:set %myscript.isloading $true
on *:START: {
  if (%myscript.isloading) { echo -a LOADING }
  else { echo -a STARTING }
  unset %myscript.loading
}


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Identifier to check if on start is mirc starting [Re: argv0] #234538 02/11/11 10:09 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
While it is easy to script it's such a fundamental thing for a scripter to want to know I'd say it still justifies a built-in identifier.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Identifier to check if on start is mirc starting [Re: starbucks_mafia] #234542 02/11/11 02:17 PM
Joined: Nov 2009
Posts: 295
P
pball Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Of course I agree with him, this is a simple addition that would be quite useful.

I'll also say I personally don't understand why the on start event has to include on load in it's operation. I'd prefer to see the on start event trigger when mirc starts only. But people would rage and complain of backwards compatibility with that suggestion, event though there is an on load event.


http://scripting.pball.win
My personal site with some scripts I've released.
Re: Identifier to check if on start is mirc starting [Re: pball] #234543 02/11/11 05:00 PM
Joined: Jan 2004
Posts: 1,181
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,181
You can also use $event to identify whether it's triggered by LOAD or START

Re: Identifier to check if on start is mirc starting [Re: maroon] #234547 02/11/11 08:57 PM
Joined: Nov 2009
Posts: 295
P
pball Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
At first I was excited by $event but it returns the name of the event. So it doesn't differentiate between starting mirc and loading the script inside the on start event


http://scripting.pball.win
My personal site with some scripts I've released.
Re: Identifier to check if on start is mirc starting [Re: pball] #234548 02/11/11 09:54 PM
Joined: Apr 2010
Posts: 921
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 921
IMO this identifier is unneeded. Not because it can be done with scripting but because it's poor scripting to need such an $id'er.

The onLoad event is for just that; when the script is loaded. This is for things such as creating a hash table and filling it with defaults, setting default variables, creating files, etc.

onStart is an event for when mIRC(and the script) starts. This is for things like making sure needed files for day-to-day use are there, loading hashtables, etc.

The ONLY reason I can see the need for a $JustLoaded identifer is for a pretty(and unneeded) echo thanking the user for using your script, and as Argv0 stated, it's quite easy to handle this with the internal scripting engine


I am SReject
My Stuff
Re: Identifier to check if on start is mirc starting [Re: FroggieDaFrog] #234550 02/11/11 11:15 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Actually, $justloaded is even less necessary, because ON LOAD already does this. In other words, if you actually are just trying to thank your users for using your script, you should be handling ON LOAD, not ON START. If the situation is that a user might unload the script and load it later, you should have some kind of %myscript.isinstalled variable to test whether it was previously installed anyway.

So in fact, I see no real use case for testing whether mIRC is "starting" in ON START.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Identifier to check if on start is mirc starting [Re: argv0] #234554 03/11/11 06:51 AM
Joined: Jan 2004
Posts: 1,181
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,181
another way to discern between the ON-START event triggered by a script loading the 1st time vs mIRC itself loading up.

if ($uptime(mirc,3) isnum 0-30) echo -s mIRC probably starting up
else echo -s probably is a script being loaded


Re: Identifier to check if on start is mirc starting [Re: pball] #234557 03/11/11 01:22 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Originally Posted By: pball
Of course I agree with him, this is a simple addition that would be quite useful.

I'll also say I personally don't understand why the on start event has to include on load in it's operation. I'd prefer to see the on start event trigger when mirc starts only. But people would rage and complain of backwards compatibility with that suggestion, event though there is an on load event.


I agree with this opinion the mIRC can change the method to the ON START event to make it not working while a user loads an script. i think now the ON LOAD event is not useful because the thinks that you can do with the ON LOAD you can do it with the ON START event.

Re: Identifier to check if on start is mirc starting [Re: westor] #234558 03/11/11 02:25 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
on LOAD has very specific uses, westor. There are times when you want to do something only on loading the script and not when mIRC starts. So, yes, it is very useful. For example, if I want to create a file with default values when a script is loaded, then I'd put that in the on LOAD event. I wouldn't want that in the on START event because it would create the file every time mIRC starts, overwriting the new values that may have been added.

As far as on START, think of that as starting (not loading) the script instead of just starting mIRC. If I wanted all my hash tables loaded when mIRC starts up, then I would also want them all loaded if a script is loaded after mIRC starts. Basically everything that I would put in the on START event should run when loading a script as well. Regardless if the script is started because mIRC is started or because the script is loaded, I'd still want the stuff to be done. Now, yes, you could duplicate everything and stick it into the on LOAD event as well as the on START event, but that's rather pointless. It's better to just have on START trigger for loading a script and starting mIRC.

If you have trouble with these events, then you're probably using them incorrectly. Use on START for everything that you want to happen when a script starts up (for any reason... loading or mIRC starting). Use on LOAD for everything that should only occur when the script is loaded, such as creating default settings. If you're using these for other things, you should probably consider whether or not there is a better way to do what you're doing.

Now, there may be a scenario where you want something to happen when mIRC starts, but not when a script loads, but that should be rare. If you think you have such an example, please post it here. Someone might suggest a better option.


Invision Support
#Invision on irc.irchighway.net
Re: Identifier to check if on start is mirc starting [Re: Riamus2] #234561 03/11/11 06:15 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Originally Posted By: Riamus2
Now, there may be a scenario where you want something to happen when mIRC starts, but not when a script loads, but that should be rare. If you think you have such an example, please post it here.


Indeed, I think the problem is that we've yet to see a concrete example for this scenario. I'm curious as to what pball's use case is. I'm more skeptical that such a scenario even exists.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: Identifier to check if on start is mirc starting [Re: argv0] #234564 03/11/11 07:04 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
There are quite a lot of possible scenario, the easiest one being you want to count how many time you started mIRC.
Imo, people should stop discussing the "can it be scripted" part and should rather give their opinion about the "is it a good suggestion". I agree with starbucks_mafia.

Quote:
I'd prefer to see the on start event trigger when mirc starts only. But people would rage and complain of backwards compatibility with that suggestion, event though there is an on load event.
It probably has been done this way because most of the time you load a code that include an on start event, you want that event to be triggered, but this is most of the time, I agree we should have a way to tell the difference


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Identifier to check if on start is mirc starting [Re: Wims] #234566 03/11/11 07:18 PM
Joined: Nov 2009
Posts: 295
P
pball Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
I made a script to track up time as a percentage. It sets a fixed start time when it's first loaded and also uses another variable to track the time between start up and exiting mirc. So if you reload the script (to change the output alias for example), the start up variable will be reset and you'll track of your total up time.

I've had other suggestions on how to track the up time of mirc but neither work in the manner my script does. So in short I have a variable I need to set only when mirc starts and I can't check if it already exists to decide whether to set or not (due to another function of the script).

I'll post code if anyone is interested but I have to split now.

Last edited by pball; 03/11/11 07:19 PM.

http://scripting.pball.win
My personal site with some scripts I've released.
Re: Identifier to check if on start is mirc starting [Re: Wims] #234569 03/11/11 09:25 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Counting the number of times mIRC is started isn't really a valid example. Yes, you'd have 1 extra time, but then again, mIRC is running when the script is first loaded, so you might as well count that. After all, you're counting how many times mIRC is started and if you don't count that first time the script is loaded, then you are missing one time. You're already missing all previous times mIRC has been started, but you can't get those. You might as well at least get the time it's running when the script starts, though. There isn't any reason to ignore that one.

And I don't think this is a case of "can it be scripted" anyhow. The suggestion is FOR a scripting option. The fact is, it's already doing what it should be doing. I'm not seeing a good reason for any changes. You can easily tell the difference using a variable.


Invision Support
#Invision on irc.irchighway.net
Re: Identifier to check if on start is mirc starting [Re: pball] #234570 03/11/11 09:29 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
I'm not sure why it matters if you start checking time when the script is loaded. If you don't do that, then there will be 0 uptime until you exit and restart mIRC, which seems like a bad way to handle that.

on LOAD sets your fixed variable. on START sets your other variable that gives you your uptime from the time mIRC starts, but also gives you something to use from the first time the script is loaded without having to restart mIRC to make it work. That certainly sounds like how it should work, and that's what it does.

I just don't see why you'd want it to not start providing uptime as soon as the script is loaded without having to restart mIRC first.


Invision Support
#Invision on irc.irchighway.net
Re: Identifier to check if on start is mirc starting [Re: Riamus2] #234572 03/11/11 10:42 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
How it is not really valid? The purpose is to be able to say how many time you 'really' started mIRC, the example doesn't mention/care about previous times or if you might accept the value to be one more. It's a valid example you cannot handle without scripting and the fact that on start is triggered when you load a script has been and still can be a problem

Last edited by Wims; 03/11/11 10:43 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Identifier to check if on start is mirc starting [Re: Wims] #234578 04/11/11 12:26 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
It's a made-up scenario that there would be no good reason for doing. If you really cared, it's a simple -1 calculation. Remember that the request is for a SCRIPT solution as it is. If you can already do it very easily, then there is no good reason to spend time to create some other way to do it.


Invision Support
#Invision on irc.irchighway.net
Re: Identifier to check if on start is mirc starting [Re: Riamus2] #234582 04/11/11 01:53 AM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
It's a plausible scenario among several others that would require scripting to know that information.
Quote:
If you can already do it very easily, then there is no good reason to spend time to create some other way to do it.
I disagree, I'm pretty sure there's a lot of things that has been added that could have been done easily with scripting.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Identifier to check if on start is mirc starting [Re: Wims] #234583 04/11/11 02:02 AM
Joined: Dec 2002
Posts: 2,010
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,010
I agree with the addition of this identifier. The ON START event is a dual purpose event (LOAD/START), therefore we should have a way to distinguish between LOAD and START. I have had a scripted solution similar (identical?) to argv0's for a long time, but there should be a built-in identifier.

Last edited by RoCk; 04/11/11 02:04 AM.
Page 1 of 3 1 2 3