PDA

View Full Version : Need Help - Sys Tray Timer App


nigeldude
05-22-2006, 08:32 PM
Hi, I’m trying to create an app that will run in the background when closed and will launch itself at two specified time each weekday and present the user with an audio player with a "listbox playlist" containing one audio for each day. It will flash a message to the user to remind him/her that the audio is to be played, and then it will cue up the correct audio for the current day and wait for the user to click the play button.

Now this app must not just get the date and time and show it to the user, but instead it should be able to compare the current date and time to the ones specified and launch itself at these times.

Now I’m trying to set the part where it compares the current time with the ones specified and tell the menu to launch or not. I’m not really getting it correct, please have a look and tell me what am I doing wrong..
_____________On Timer___________________________________

date = System.GetDate(DATE_FMT_ISO);
day = System.GetDate(DATE_FMT_DAYOFWEEK);
time = System.GetTime(4) ..":".. System.GetTime(3);

if day == 2 or 3 or 4 or 5 or 6 then
playtoday = yes
elseif day == 1 or 7 then
playtoday = no;
end

if time >= 06:15 and <= 06:25 then
playnow = yes;
end
if time >= 09:15 and <= 09:25 then
playnow = yes;
end

if playtoday = yes and playnow = yes then
Application.Restore();
end

yosik
05-22-2006, 11:59 PM
You've got a few problems here:

1. your time variable is a string not a time number so you can't check its value with time values. You can circumvent this with using String.ToNumber with a proper calculation on your time numbers (sorry, no time here to post the code).

2. I am not sure you can do a multiple "or" condition (if day == 2 or 3 or 4 or 5 or 6), I would separate this to: if ((day ==2) or (day ==3) or (day ==4)) etc...

Good luck

Yossi

Roboblue
05-23-2006, 01:38 AM
Here is some code to get you started.
set the Page On Show timer
Page.StartTimer(1000);
then in the Page On Timer event
DRTimer()
and here's the function that is put into Project Global
function DRTimer()
nStime = System.GetTime(TIME_FMT_MIL);
sStime = String.Replace(nStime, ":", "", false);
nStime2 = String.ToNumber(sStime);
if nStime2 > 080000 and nStime2 < 080001 then
---put your function for the action you want to call here
elseif nStime2 > 120000 and nStime2 <= 120001 then
---put your function for the action you want to call here
elseif nStime2 > 160000 and nStime2 <= 160001 then
---put your function for the action you want to call here
end
end

This will run your desired function daily at 0800AM, 1200PM, and 1600PM. just change, add, delete the times you desire

nigeldude
05-23-2006, 02:03 AM
Hey thanks a lot guys, I really appreciate it.