mIRC Home    About    Download    Register    News    Help

Page 1 of 3 1 2 3 >
Topic Options
#234535 - 02/11/11 01:59 AM Identifier to check if on start is mirc starting
pball Online
Fjord artisan

Registered: 04/11/09
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.

Top
#234536 - 02/11/11 02:56 AM Re: Identifier to check if on start is mirc starting [Re: pball]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
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"

Top
#234538 - 02/11/11 10:09 AM Re: Identifier to check if on start is mirc starting [Re: argv0]
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
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.

Top
#234542 - 02/11/11 02:17 PM Re: Identifier to check if on start is mirc starting [Re: starbucks_mafia]
pball Online
Fjord artisan

Registered: 04/11/09
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.

Top
#234543 - 02/11/11 05:00 PM Re: Identifier to check if on start is mirc starting [Re: pball]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1141
You can also use $event to identify whether it's triggered by LOAD or START

Top
#234547 - 02/11/11 08:57 PM Re: Identifier to check if on start is mirc starting [Re: maroon]
pball Online
Fjord artisan

Registered: 04/11/09
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.

Top
#234548 - 02/11/11 09:54 PM Re: Identifier to check if on start is mirc starting [Re: pball]
FroggieDaFrog Offline
Hoopy frood

Registered: 16/04/10
Posts: 910
Loc: USA
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

Top
#234550 - 02/11/11 11:15 PM Re: Identifier to check if on start is mirc starting [Re: FroggieDaFrog]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
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"

Top
#234554 - 03/11/11 06:51 AM Re: Identifier to check if on start is mirc starting [Re: argv0]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1141
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


Top
#234557 - 03/11/11 01:22 PM Re: Identifier to check if on start is mirc starting [Re: pball]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
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.
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#234558 - 03/11/11 02:25 PM Re: Identifier to check if on start is mirc starting [Re: westor]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#234561 - 03/11/11 06:15 PM Re: Identifier to check if on start is mirc starting [Re: Riamus2]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
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"

Top
#234564 - 03/11/11 07:04 PM Re: Identifier to check if on start is mirc starting [Re: argv0]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3496
Loc: France
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

Top
#234566 - 03/11/11 07:18 PM Re: Identifier to check if on start is mirc starting [Re: Wims]
pball Online
Fjord artisan

Registered: 04/11/09
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.


Edited by pball (03/11/11 07:19 PM)
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#234569 - 03/11/11 09:25 PM Re: Identifier to check if on start is mirc starting [Re: Wims]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#234570 - 03/11/11 09:29 PM Re: Identifier to check if on start is mirc starting [Re: pball]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#234572 - 03/11/11 10:42 PM Re: Identifier to check if on start is mirc starting [Re: Riamus2]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3496
Loc: France
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


Edited by Wims (03/11/11 10:43 PM)
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#234578 - 04/11/11 12:26 AM Re: Identifier to check if on start is mirc starting [Re: Wims]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#234582 - 04/11/11 01:53 AM Re: Identifier to check if on start is mirc starting [Re: Riamus2]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3496
Loc: France
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

Top
#234583 - 04/11/11 02:02 AM Re: Identifier to check if on start is mirc starting [Re: Wims]
RoCk Offline
Hoopy frood

Registered: 16/12/02
Posts: 2009
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.


Edited by RoCk (04/11/11 02:04 AM)

Top
Page 1 of 3 1 2 3 >