| View previous topic :: View next topic |
| Author |
Message |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Sun Jan 30, 2005 11:32 am Post subject: Help, Making a script do something on a date. |
|
|
Hi, All
Could some one help me with this crazy problem.? I just can't get my head around it.
What I want to do is create an application that will do something on certain day, month, etc.
PROBLEM
I want my script to do something on the last day of every month, but how on earth do i work out what the last day of the month is?
I tried writing a simple solution but I found that I had to preset the lst day of every month, which in turn does not help with years, since every year is different. also say my script ran on 30/1/06 and the next day was 1/2/06 but i cant figure out oh to count for the month as well.
I bet this become one of those imposible things.
Could this all be done using the calender dialog eliment or something?
Thank you, DW |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Sun Jan 30, 2005 2:34 pm Post subject: |
|
|
First, you need to obtain the current date and break it down to get the
current day. You may also need a simple database that just contains a
list of the months along with the number of days included within that
month. You will also need to determine if the current year is a leap year,
if it is then you will also need to deal with it accordingly as well.
I don't have any working code for this, but I do have a really good idea
how to go about it. If you need an example or some help developing the
code required, then you can email me or PM me and I'll see what I can do
to help. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sun Jan 30, 2005 5:31 pm Post subject: |
|
|
I'd just check if tomorrow is the first day of the month...
This is simplified so it's easier to understand, the last line
shows how to get tomorrow's day in one line of code.
| Code: |
OPTION DECIMALSEP, "."
rem -- get a float for today's date (before decimal point is day info) --
%%today_float = @name(@datetime())
rem -- add one day for tomorrow --
%%tomorrow_float = @succ(%%today_float)
rem -- get tomorrow's day of the month --
%%tomorrow_day = @datetime(d, %%tomorrow_float)
rem -- if tomorrow is day 1, today is last day of this month --
if @equal(%%tomorrow_day, 1)
INFO "Today is last day of month."
end
rem -- this just shows the info we gathered --
INFO tdf= %%today_float@cr()@cr()tmf= %%tomorrow_float@cr()@cr()tmd= %%tomorrow_day
rem -- get tomorrow's day with one line of code --
INFO tomorrow's day= @datetime(d,@succ(@name(@datetime())))
|
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Sun Jan 30, 2005 11:58 pm Post subject: |
|
|
This is not quite as simple as Mac's but just as effective.
| Code: |
title DoOnDate
rem This list contains the month names and how many days are in
rem each month.
list create,2
list loadtext,2
"1|31
"2|28
"3|31
"4|30
"5|31
"6|30
"7|31
"8|31
"9|30
"10|31
"11|30
"12|31
%%taskDone = FALSE
dialog create,DoOnDate,-1,0,300,150
dialog add,STYLE,St1,,12,BC
dialog add,TEXT,now,10,10,280,20,,,St1
dialog add,TEXT,t1,40,10,,15
dialog show
:Evloop
wait 0.1,event
%E = @event()
goto %E
:Timer
rem get the current date and save it into a variable
%%now = @datetime()
dialog set,now,@datetime(dddddd,%%now)
rem Get the day from the current date
%%today = @datetime(d,%%now)
%%month = @datetime(m,%%now)
rem Get the year from the current date.
%%year = @datetime(yy,%%now)
rem Check to see if this year is leap year.
%z = @fdiv(%%year,4)
%%zz = @ext(%z)
if @null(%%zz)
%%leapYear = TRUE
else
%%leapYear = FALSE
end
if @equal(%%leapYear,TRUE)
list seek,2,@pred(%%month)
parse "%a;%%numDays",@item(2)
if @equal(%%month,2)
%%numDays = 29
end
else
list seek,2,@pred(%%month)
parse "%a;%%numDays",@item(2)
end
if @equal(%%today,%%numDays)
rem do Our task here.
if @equal(%%taskDone,FALSE)
dialog set,t1,Today is the last day of the month
rem Set our task variable so that we don't keep repeating
rem the same task over and over.
%%taskDone = TRUE
end
else
dialog set,t1,Today is not the last day of the month
if @equal(%%taskDone,TRUE)
rem Reset our task variable
%%taskDone = FALSE
end
end
goto Evloop
:CLOSE
exit
|
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Mon Jan 31, 2005 8:10 am Post subject: |
|
|
good case of lateral thinking, mac
serge _________________
|
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Mon Jan 31, 2005 12:37 pm Post subject: |
|
|
Wow, I have been racking my brain with this for about a week. You guys are geniuses, you all make it look so easy.
Thank you all very very much. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|