mIRC Homepage
Posted By: RusselB Differentiating similar input styles - 21/11/09 07:02 AM
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.
Posted By: gooshie Re: Differentiating similar input styles - 21/11/09 01:06 PM
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.
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

Posted By: RusselB Re: Differentiating similar input styles - 21/11/09 06:47 PM
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.
Posted By: DJ_Sol Re: Differentiating similar input styles - 23/11/09 12:30 AM
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.
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
Posted By: DJ_Sol Re: Differentiating similar input styles - 23/11/09 04:59 AM
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.
Posted By: RusselB Re: Differentiating similar input styles - 23/11/09 06:27 AM
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
Posted By: XperTeeZ Re: Differentiating similar input styles - 23/11/09 07:05 PM
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.
Posted By: DJ_Sol Re: Differentiating similar input styles - 23/11/09 07:26 PM
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.
Posted By: RusselB Re: Differentiating similar input styles - 23/11/09 09:03 PM
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

Posted By: RusselB Re: Differentiating similar input styles - 23/11/09 09:04 PM
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.
Posted By: XperTeeZ Re: Differentiating similar input styles - 24/11/09 12:16 PM
True, your timer format is correct, missed that spot smile
© mIRC Discussion Forums