mIRC Home    About    Download    Register    News    Help

Print Thread
Differentiating similar input styles #216593 21/11/09 07:02 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I'm working on a script that changes my nick after a period of time.
I'd like to be able to set it so that I can use a time (eg: 02:00, 3 am, 4 pm, 17:20) so that my nick changes at that time.

I'd also like to be able to set it to change after a period of time (eg: 2:00 for 2 hours)

Each of these, in and of itself is a relatively simple timer command.

What I'm unsure of, is how to get the script to recognize that 2:00 is 2 hours, yet 02:00 is 2 am?

Times/timings given here are examples only.

Re: Differentiating similar input styles [Re: RusselB] #216597 21/11/09 01:06 PM
Joined: Nov 2009
Posts: 117
gooshie Offline
Vogon poet
Offline
Vogon poet
Joined: Nov 2009
Posts: 117
You could use the colon only for the one that sets it to a time
and for duration use decimal point format as in 2.5 for two and
a half hours. Another way if you insist on having a colon for
both formats is to add maybe a d after the one for duration as
in 2:30d to indicate two hours thirty minutes. Of course you
will write conditional statements to use these the way you wish.

Re: Differentiating similar input styles [Re: RusselB] #216603 21/11/09 06:04 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
By allowing the user to type in whatever they want, you are setting yourself up for having to write tons of code for differentiation and error checking. Instead, I suggest using dialog elements to choose their time of day or duration.

Example:
- A radio button to switch between time of day and duration.

- Several drop-down boxes to choose hours/minutes/seconds (time of day and duration).

- A real-time text representation of when their selection will occur. ie "Time remaining: 3h 9m 43s"


Basically, don't give the users the chance to give you invalid or ambiguous data. Let them choose from pre-defined sets of data instead.

-genius_at_work


Re: Differentiating similar input styles [Re: genius_at_work] #216605 21/11/09 06:47 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks for the replies. One option that I thought of after submitting my request is to prompt the user for clarification if necessary.
Eg: 2:00 am would not be prompted for
but 2:00 would send a prompt to clarify if they wanted 2 hours, 2:00 am or 2:00 pm

As the script will be on each users mIRC, rather than on a bot, then the prompting is, imo, a valid option.

Re: Differentiating similar input styles [Re: RusselB] #216624 23/11/09 12:30 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
To make it easy Id suggest using a specific method to tell which is which.

I think you should use colon for a specific time and a floating point integer for duration.

02:00 = 2m
2 = 2 hours

This will make it easy to differentiate. If you like you can still double check with the user.

Re: Differentiating similar input styles [Re: RusselB] #216625 23/11/09 12:55 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Personally, I'd be annoyed if the program had to ask me what I meant. If it is going to accept any time that I give it, the program should be able to figure it out.

As I mentioned above, I would use dialog items to let the user choose. If you don't want that clutter on your main dialog, you could use a secondary dialog with a "Change" button on the main dialog.

-genius_at_work

Re: Differentiating similar input styles [Re: genius_at_work] #216628 23/11/09 04:59 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I only guessed when he said it was a script and not a bot that he was doing a remote control script. In that instance they wouldnt see the dialog.

Or maybe I misunderstood. I agree with the dialog suggestion unless it is controlled by a text event.

Re: Differentiating similar input styles [Re: DJ_Sol] #216631 23/11/09 06:27 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The script, when complete, will be available, initially, for DJ's, and will allow the DJ to use a single command to change their nick when they start their shift and automatically change it back at the end of their shift.

Eg: <RusselB> /dj 2:00 am
Would turn the nick to DJ^RusselB
Then at 2:00 am, turn it back to RusselB automatically.

However, some DJ's might prefer to use /dj 2:00
Which would turn their nick (as shown earlier), then change it again 2 hours later

Re: Differentiating similar input styles [Re: RusselB] #216641 23/11/09 07:05 PM
Joined: Nov 2009
Posts: 20
X
XperTeeZ Offline
Ameglian cow
Offline
Ameglian cow
X
Joined: Nov 2009
Posts: 20
Well, mIRC uses 24-hour clock for $time. So basically,
Code:
/timer 1 14:00 nick XperTeeZ|away

would change my nick at 2 pm.

Re: Differentiating similar input styles [Re: RusselB] #216643 23/11/09 07:26 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
In my opinion you should give them a specific protocol and not be ambiguous about it.

Me personally, I would have them set the time in military time.

/dj 02:00 means be done at 2 am.

If they wanted it for 2 hours use: dj 2

2.5 hours: /dj 2.5

This way if there is a : in it, you know its a specific time. Otherwise it's an amount of time.

Re: Differentiating similar input styles [Re: XperTeeZ] #216646 23/11/09 09:03 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Actually to my understanding, and experience with timers,
Quote:
/timer 1 14:00 nick XperTeeZ|away
should be formatted as
Code:
/timer 14:00 1 0 nick XperTeeZ|away


Re: Differentiating similar input styles [Re: DJ_Sol] #216647 23/11/09 09:04 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks for your reply and opinion.
Obviously doing it the way I was wanting will be difficult at best, thus I'm considering other options.

Re: Differentiating similar input styles [Re: RusselB] #216660 24/11/09 12:16 PM
Joined: Nov 2009
Posts: 20
X
XperTeeZ Offline
Ameglian cow
Offline
Ameglian cow
X
Joined: Nov 2009
Posts: 20
True, your timer format is correct, missed that spot smile