mireazma Posted May 3, 2011 Share Posted May 3, 2011 Hello. I searched for the use of @WDAY in the way I want to but I only found it related to current date. I don't know how macros work and what they return, especially @WDAY. The manual is ambiguous. Would somebody please guide me how to use it to enumerate the dates from a starting one to an ending one, counting only the workdays? Here is something I'm trying to make, more or less pseudo-coded: ; arbitrary month/year $StartDate = 1 $EndDate = 14 For $Date = StartDate To EndDate If (@WDAY($Date) <> 1 OR @WDAY($Date) <> 7) Then <write the date output> EndIf Next Now, I've got the feeling $Date must be formatted somehow and I don't know how to use @WDAY. Besides, am I missing anything else? Link to comment Share on other sites More sharing options...
jchd Posted May 3, 2011 Share Posted May 3, 2011 _DateToDayOfWeek, DateToDayOfWeekISO This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
sahsanu Posted May 4, 2011 Share Posted May 4, 2011 As jchd pointed out to you... just an example: #include <Date.au3> $StartDate = 1 $EndDate = 40 ;I know I know ;-) For $Date = $StartDate To $EndDate $result = _DateToDayOfWeek (@YEAR, @MON,$Date) If Not @error Then If $result <> 1 And $result <> 7 Then ConsoleWrite(@YEAR & "/" & @MON & "/" & $Date & @TAB & _DateDayOfWeek($result) & @CRLF) EndIf EndIf Next Link to comment Share on other sites More sharing options...
mireazma Posted May 4, 2011 Author Share Posted May 4, 2011 (edited) Thank you very much. (I always hated that English has the same form for 2nd person sg and pl. Now I meant both). sahsanu, I don't think I could've done it without the snippet. It's unclear for me whether $Date must be string or numeric. Edited May 4, 2011 by mireazma Link to comment Share on other sites More sharing options...
jchd Posted May 4, 2011 Share Posted May 4, 2011 Help file tells you what type functions expect/return. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
mireazma Posted May 4, 2011 Author Share Posted May 4, 2011 Yeah, it says "$iDay" - a valid day in format DD.Accustomed to the rigorous C++, I find the variant being a source of ambiguity for me which not only I don't understand totally but as it seems it's a source of bugs as well. I couldn't test it at that moment so I couldn't know if I have to put "" around the assigned numerical constant. Now I know it has to be declared as string, otherwise it won't work.Another example is @YEAR which I'm not sure what it returns. In the manual it says "Current four-digit year". Now is it a string or a number? Oh, I forgot it's both at the same time . Takes time to get accustomed to variants Link to comment Share on other sites More sharing options...
jchd Posted May 4, 2011 Share Posted May 4, 2011 ConsoleWrite(VarGetType(@YEAR) & @LF) String This is to adhere to the YYYY format and common stringed dates. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
mireazma Posted May 4, 2011 Author Share Posted May 4, 2011 Well, I learned something new - VarGetType. I didn't have the time to read althrough the manual. I'm starting to think that anything you could imagine has a corresponding function in AutoIt (everything is covered) Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 4, 2011 Share Posted May 4, 2011 (edited) The native AutoIt functions and operators will attempt to recast parameters to correct type on the fly. The macro @YEAR will return a string but you can still get away with this: $iNext = @YEAR + 1 ConsoleWrite("Next year will be: " & $iNext & "; Type = " & VarGetType($iNext) & @LF) Because of the arithmetic operation, AutoIt performs as if the first line was: $iNext = Number(@YEAR) + 1 Note there is no guarantee that a particular UDF will do that for you. Edited May 4, 2011 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
mireazma Posted May 7, 2011 Author Share Posted May 7, 2011 Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now