Jump to content

_DateDayofWeek in date.au3


Recommended Posts

Another method:

Dim $Dow[7], $Today, $i

$Dow[0] = "1Sunday"

$Dow[1] = "2Monday"

$Dow[2] = "3Tuesday"

$Dow[3] = "4Wednesday"

$Dow[4] = "5Thursday"

$Dow[5] = "6Friday"

$Dow[6] = "7Saturday"

$Today = StringLeft(@Wday,1)

For $i = 0 to 7

If $Today = String($i) Then

MsgBox(0, "Day of the Week","Today's Day of the Week is: " & StringTrimLeft($Dow[$i-1],1))

EndIf

Next

RocTx

Link to comment
Share on other sites

yah i used the @WDAY to do it. worked pretty well, couple lines of code.

but i have an other dillemma, i am using the monday for updating with this script, so evertime they select the exe it will check for updates if the creation dates are not the same and if it is monday. working with mde they get corrupt, alot. anyways, my problem is if they open the mde more than once on the monday it will run the update again, which is a problem. is there anyway to store that the update has been run already today and if the creation dates are the same then just open the program.

i guess i could store the computer name in a text file and look for it. if the name is there dont update, open program. if computer name not there, run update, put name there, and open program.

any other thoughts.

Josbe, I like yours better.. I was unaware of the  _DateDayOfWeek() function.

#include <Date.au3>

$szDay= _DateDayOfWeek( @WDAY, 0 )

MsgBox(0, "", "Today is " & $szDay)

Smaller code.  Great!

RocTx

<{POST_SNAPBACK}>

Link to comment
Share on other sites

i can do tha task scheduler, not sure if that is a good idea. how would the registry key thign work. the ini file doesnt seem plausible but i will mess with it and see what happens. thanks

you could make an INI and store the last day it was run on each person's computer. 

Or better yet a registry entry :)

You can also automate it with task squeduler, etc etc.

<{POST_SNAPBACK}>

Link to comment
Share on other sites

Felt like helping you a bit.

You can simply change the functions INIRead and INIWrite to RegRead and RegWrite if you want.

Here's the script:

;On startup
CheckUpdate()

;Rest of the script...

Func CheckUpdate()
   Dim $LastRun
   Dim $Today
   $Monday = "2"
   $Today = @YEAR & @MON & @MDAY
   $LastRun = INIRead(@ScriptDir, "Update", "LastRun", $Today)
   If $LastRun = $Today OR @WDAY <> $Monday Then
      Return
   Else
     ;Update part here...
      INIWrite(@ScriptDir, "Update", "LastRun", $Today)
   EndIf
EndFunc
Link to comment
Share on other sites

Okay what I would do is something like the following. I have this schedule my scripts...to run once on one day...modify as needed.

Dim $day = 1;Scans on Sunday (Sunday = 1 thru Saturday = 7)
Dim $scanned = 0;Makes sure the program only runs once on Sunday's
Dim $delay = 1;Time in hours that it checks the date
$delay = $delay * 60 * 60 * 1000

While 1
   If @WDAY = $day Then
      If $scanned = 0 Then
       ;Your Code goes Here
         $scanned = 1
      EndIf
   Else
      $scanned = 0
   EndIf
   Sleep($delay)
WEnd

Edit: With the above you can run this once and be assured that it will do what it is supposed to every monday before anyone is there unless they are there between 12AM and 1AM.

I hope that helps,

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...