Jump to content

Date.au3


 Share

Recommended Posts

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 by jaberwocky6669
Link to comment
Share on other sites

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

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

 

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

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 by jaberwocky6669
Link to comment
Share on other sites

Same idea as previous post but applied to _DateToMonth:

Func _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 by jaberwocky6669
Link to comment
Share on other sites

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 Gude
How 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

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.

Consolewrite(_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
Link to comment
Share on other sites

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 by jaberwocky6669
Link to comment
Share on other sites

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 by jaberwocky6669
Link to comment
Share on other sites

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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.

If 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 by jaberwocky6669
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...