jaberwacky Posted January 8, 2014 Author Share Posted January 8, 2014 (edited) Unfortunately, this is the best I've been able to do: Func __DateDayOfWeek($iDayNum, $iShort = 0) $iDayNum = Int($iDayNum) ; Cast as Int() in case a number is passed as a string. If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, "") $iShort = Int($iShort) ; Case as Int() to be either 0 or 1. Local Const $SYSTEMTIME = DllStructCreate("WORD wYear;WORD wMonth;WORD wDayOfWeek;WORD wDay;WORD wHour;WORD wMinute;WORD wSecond;WORD wMilliseconds") DllStructSetData($SYSTEMTIME, "wYear", @YEAR) DllStructSetData($SYSTEMTIME, "wMonth", @MON) DllStructSetData($SYSTEMTIME, "wDayOfWeek", $iDayNum) DllStructSetData($SYSTEMTIME, "wDay", @MDAY) DllStructSetData($SYSTEMTIME, "wHour", @HOUR) DllStructSetData($SYSTEMTIME, "wMinute", @MIN) DllStructSetData($SYSTEMTIME, "wSecond", @SEC) DllStructSetData($SYSTEMTIME, "wMilliseconds", @MSEC) Local Const $format = ($iShort ? "ddd" : "dddd") ;~ Local Const $date_str = DllStructCreate("str") Local Const $date_str = DllStructCreate("char[256]") Local Const $date_format = DllCall("Kernel32.dll", "int", "GetDateFormatEx", "wstr", '', _ "dword", 0, _ "ptr", DllStructGetPtr($SYSTEMTIME), _ "wstr", $format, _ "ptr", DllStructGetPtr($date_str), _ "int", DllStructGetSize($date_str), _ "wstr", '')[0] ConsoleWrite("@error: " & @Error & @CRLF & _ "date_format: " & $date_format & @CRLF & _ "DllStructGetData($date_str, 1): " & DllStructGetData($date_str, 1) & @CRLF) EndFunc (doesn't work) Edited January 8, 2014 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jpm Posted January 8, 2014 Share Posted January 8, 2014 Hi, I think that the jchd sugestion is best to leave the user override the dayname. there is may other place that only English is returned. But leaving the user the overriding with doc description can solve a lot of issue. Link to comment Share on other sites More sharing options...
Iczer Posted January 8, 2014 Share Posted January 8, 2014 jaberwocky6669 This wouldn't work on XP and shouldn't get used in official UDF/internal functions until AutoIt officially drop XP support GetDateFormatEx Note The application should call this function in preference to GetDateFormat if designed to run only on Windows Vista and later. Link to comment Share on other sites More sharing options...
jaberwacky Posted January 8, 2014 Author Share Posted January 8, 2014 True, you're right. Was just trying to get something to work though. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Myicq Posted January 9, 2014 Share Posted January 9, 2014 jaberwocky6669 This wouldn't work on XP and shouldn't get used in official UDF/internal functions until AutoIt officially drop XP support GetDateFormatEx Note The application should call this function in preference to GetDateFormat if designed to run only on Windows Vista and later. Does this mean that GetDateFormat() will not work on Vista++, or just that it's recommended to use GetDateFormatEx() ? Would other option be an XP- backwards compatible function, and use check on @OSVersion ? I am just a hobby programmer, and nothing great to publish right now. Link to comment Share on other sites More sharing options...
jaberwacky Posted January 9, 2014 Author Share Posted January 9, 2014 (edited) How about this possibility? Pass an array of weekdays into the function. Func _DateDayOfWeek($iDayNum, $iShort = 0, $aDaysOfWeek = Default) $iDayNum = Int($iDayNum) ; Cast as Int() in case a number is passed as a string. $iShort = Int($iShort) ; Case as Int() to be either 0 or 1. If $aDaysOfWeek = Default Then Redim $aDaysOfWeek[7] = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, '') Else If Not IsArray($aDaysOfWeek) Then Return SetError(2, 0, '') If $iDayNum < 1 Or $iDayNum > UBound($aDaysOfWeek, $UBOUND_ROWS) Then Return SetError(1, 0, '') EndIf Return $iShort ? StringLeft($aDaysOfWeek[$iDayNum - 1], 3) : $aDaysOfWeek[$iDayNum - 1] EndFunc ;==>_DateDayOfWeek Edited January 9, 2014 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted January 9, 2014 Author Share Posted January 9, 2014 (edited) Same idea as previous post but applied to _DateToMonth: expandcollapse popupFunc _DateToMonth($iMonth, $iShort = 0, $aMonthNumber = Default, $aMonthNumberAbbrev = Default) Select Case Not StringIsInt($iMonth) Return SetError(1, 0, "") Case Else Select Case $iShort = 0 If $aMonthNumber = Default Then Redim $aMonthNumber[12] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] If $iMonth < 1 Or $iMonth > 12 Then Return SetError(2, 0, "") Else If Not IsArray($aMonthNumber) Then Return SetError(4, 0, '') If $iMonth < 1 Or $iMonth > UBound($aMonthNumber) Then Return SetError(2, 0, "") EndIf Return $aMonthNumber[$iMonth - 1] Case $iShort = 1 If $aMonthNumber = Default Then Redim $aMonthNumber[12] = ["Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"] If $iMonth < 1 Or $iMonth > 12 Then Return SetError(2, 0, "") Else If Not IsArray($aMonthNumber) Then Return SetError(4, 0, '') If $iMonth < 1 Or $iMonth > UBound($aMonthNumber) Then Return SetError(2, 0, "") EndIf Return $aMonthNumberAbbrev[$iMonth - 1] Case Else Return SetError(3, 0, "") EndSelect EndSelect EndFunc ;==>_DateToMonth Edited January 9, 2014 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted January 9, 2014 Share Posted January 9, 2014 You can't ReDim on a non-Array datatype, this is where Dim comes into its own. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
BrewManNH Posted January 9, 2014 Share Posted January 9, 2014 How is it that Dim allows you to redeclare a function parameter but Local won't? Seems like a bug rather than a feature. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jaberwacky Posted January 9, 2014 Author Share Posted January 9, 2014 Just a concept. I didn't even test the code. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted January 10, 2014 Author Share Posted January 10, 2014 I submit for your approval two functions which return a day or a month which corresponds to an integer. Also, there is an option to pass an array of days or months for those users for whom english is not a first language. I removed the option to specify a shorted version of the day or month. If that is needed an array with the shortened names can be used. expandcollapse popupConsolewrite(_DateDayOfWeek(1) & @CRLF) Consolewrite(_DateDayOfWeek(2) & @CRLF) Consolewrite(_DateDayOfWeek(3) & @CRLF) Consolewrite(_DateDayOfWeek(4) & @CRLF) Consolewrite(_DateDayOfWeek(5) & @CRLF) Consolewrite(_DateDayOfWeek(6) & @CRLF) Consolewrite(_DateDayOfWeek(7) & @CRLF & @CRLF) Global Const $week_days = ["lunes", "martes", "miércoles", "jueves", "viernes", "sábado", "domingo"] Consolewrite(_DateDayOfWeek(1, $week_days) & @CRLF) Consolewrite(_DateDayOfWeek(2, $week_days) & @CRLF) Consolewrite(_DateDayOfWeek(3, $week_days) & @CRLF) Consolewrite(_DateDayOfWeek(4, $week_days) & @CRLF) Consolewrite(_DateDayOfWeek(5, $week_days) & @CRLF) Consolewrite(_DateDayOfWeek(6, $week_days) & @CRLF) Consolewrite(_DateDayOfWeek(7, $week_days) & @CRLF & @CRLF) Func _DateDayOfWeek($iDayNum, $aDaysOfWeek = Default) $iDayNum = Int($iDayNum) ; Cast as Int() in case a number is passed as a string. If $aDaysOfWeek = Default Then Dim $aDaysOfWeek[7] = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, '') Else If Not IsArray($aDaysOfWeek) Then Return SetError(2, 0, '') If $iDayNum < 1 Or $iDayNum > UBound($aDaysOfWeek, $UBOUND_ROWS) Then Return SetError(1, 0, '') EndIf Return $aDaysOfWeek[$iDayNum - 1] EndFunc ;==>_DateDayOfWeek Consolewrite(_DateToMonth(1) & @CRLF) Consolewrite(_DateToMonth(2) & @CRLF) Consolewrite(_DateToMonth(3) & @CRLF) Consolewrite(_DateToMonth(4) & @CRLF) Consolewrite(_DateToMonth(5) & @CRLF) Consolewrite(_DateToMonth(6) & @CRLF) Consolewrite(_DateToMonth(7) & @CRLF) Consolewrite(_DateToMonth(8) & @CRLF) Consolewrite(_DateToMonth(9) & @CRLF) Consolewrite(_DateToMonth(10) & @CRLF) Consolewrite(_DateToMonth(11) & @CRLF) Consolewrite(_DateToMonth(12) & @CRLF & @CRLF) Global Const $foreign_months[12] = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"] Consolewrite(_DateToMonth(1, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(2, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(3, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(4, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(5, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(6, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(7, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(8, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(9, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(10, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(11, $foreign_months) & @CRLF) Consolewrite(_DateToMonth(12, $foreign_months) & @CRLF & @CRLF) Func _DateToMonth($iMonth, $aMonths = Default) $iMonth = Int($iMonth) ; Cast as Int() in case a number is passed as a string. If $aMonths = Default Then Dim $aMonths[12] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] If $iMonth < 1 Or $iMonth > 12 Then Return SetError(1, 0, "") Else If Not IsArray($aMonths) Then Return SetError(2, 0, '') If $iMonth < 1 Or $iMonth > UBound($aMonths, $UBOUND_ROWS) Then Return SetError(1, 0, "") EndIf Return $aMonths[$iMonth - 1] EndFunc ;==>_DateToMonth Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted January 10, 2014 Share Posted January 10, 2014 On second thought should the "day of the week" function return 1 as Monday, because _DateToDayOfWeekISO() does?I will have a look at your functions in more detail later on, but I am not keen on removing the short hand parameter. Also UBound() is a preferred choice than IsArray(), because arrays can be "empty". UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted January 10, 2014 Author Share Posted January 10, 2014 (edited) The weekday corresponding to 1 in that function is becuase of the ISO 8601 standard if I am not mistaken (just looked this up). So, if it does return 1 for mon then should it be renamed accordingly? Well, ok, yeah, that's the difference between them. One corresponds to iso 8601 the oother doesn't. Well, no, not quite. They are similiar though. Edited January 10, 2014 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted January 10, 2014 Share Posted January 10, 2014 I am just thinking though that if the help file has date functions that class Monday as 1 then so should this function. Empty Arrays: Local $aArray[0] ConsoleWrite(IsArray($aArray) & @CRLF) ConsoleWrite(UBound($aArray) & @CRLF) ; ConsoleWrite($aArray[0] & @CRLF) ; <<<< Will cause an error. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Myicq Posted January 10, 2014 Share Posted January 10, 2014 First day of week is locale dependent, although Monday for most of world. I am just a hobby programmer, and nothing great to publish right now. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 10, 2014 Share Posted January 10, 2014 @WDAY Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday. From the help file. This is most likely the reason 1 corresponds to Sunday and not Monday. Link to comment Share on other sites More sharing options...
guinness Posted January 10, 2014 Share Posted January 10, 2014 From the help file. This is most likely the reason 1 corresponds to Sunday and not Monday. I just check and it seems that ISO function is the only which is different. So no problem leaving as it is. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted January 10, 2014 Author Share Posted January 10, 2014 (edited) I now see the wisdom in doing what jchd suggested, substituting a global array for another when needed. Otherwise, an array would have to be passed for every function call. I just wish that I could get GetDateFormatEx to work. As richard suggested, this may just be the best route overall. If I understand the function correctly. Just saw guinness' response to my other thread about this. Edited January 10, 2014 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted January 10, 2014 Share Posted January 10, 2014 As I said it seems the WinAPI version in the UDFs is using the non-recommended function call. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted January 10, 2014 Author Share Posted January 10, 2014 (edited) I think the GetDateFormatEx does not do what I thought it did. I was hoping to pass it a number of a weekday and have it return the name of that day in various languages, but I think that's not it's purpose. expandcollapse popupIf GetDateFormatEx(1) <> "Sunday" Then ConsoleWrite("!Error" & @CRLF) Else ConsoleWrite("Sunday" & @CRLF) EndIf If GetDateFormatEx(2) <> "Monday" Then ConsoleWrite("!Error" & @CRLF) Else ConsoleWrite("Monday" & @CRLF) EndIf If GetDateFormatEx(3) <> "Tuesday" Then ConsoleWrite("!Error" & @CRLF) Else ConsoleWrite("Tuesday" & @CRLF) EndIf If GetDateFormatEx(4) <> "Wednesday" Then ConsoleWrite("!Error" & @CRLF) Else ConsoleWrite("Wednesday" & @CRLF) EndIf If GetDateFormatEx(5) <> "Thursday" Then ConsoleWrite("!Error" & @CRLF) Else ConsoleWrite("Thursday" & @CRLF) EndIf If GetDateFormatEx(6) <> "Friday" Then ConsoleWrite("!Error" & @CRLF) Else ConsoleWrite("Friday" & @CRLF) EndIf If GetDateFormatEx(7) <> "Saturday" Then ConsoleWrite("!Error" & @CRLF) Else ConsoleWrite("Saturday" & @CRLF) EndIf Func GetDateFormatEx(Const $dow) Local Const $date_str = DllStructCreate("wchar[256]") Local Const $locale_name = GetUserDefaultLocaleName() Local Const $tSystemTime = DllStructCreate($tagSystemTime) DllStructSetData($tSystemTime, "Year", String(@YEAR)) DllStructSetData($tSystemTime, "Month", String(@MON)) DllStructSetData($tSystemTime, "Dow", String($dow)) DllStructSetData($tSystemTime, "Day", String(@MDAY)) DllCall("Kernel32.dll", "int", "GetDateFormatEx", "wstr", $locale_name, _ "dword", 0, _ "struct*", $tSystemTime, _ "wstr", "dddd", _ "struct*", $date_str, _ "int", DllStructGetSize($date_str), _ "ptr", 0) Return DllStructGetData($date_str, 1) EndFunc Func GetUserDefaultLocaleName() Local Const $tLocaleName = DllStructCreate("wchar[" & $LOCALE_NAME_MAX_LENGTH & ']') DllCall("Kernel32.dll", "int", "GetUserDefaultLocaleName", "struct*", $tLocaleName, "int", $LOCALE_NAME_MAX_LENGTH) Return DllStructGetData($tLocaleName, 1) EndFunc Edited January 10, 2014 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? 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