Jump to content

DateTimePicker keeps returning 0.


hogfan
 Share

Recommended Posts

Hello. I am working with the DateTimePicker control and am having some difficulty reading the current date. I am following the example the in AutoIT function documentation, and it's my understanding that the _GUICtrlDTP_GetSystemTime() function is supposed to return the currently selected date & time as an array. I have a button on my form that the user will click after selecting the date of their choice from the datepicker that executes the following code.

Func _LoadCallLog ()

Global $dateLogs, $mySelectedDay[7] = [False, @YEAR, 8, 19, 21, 57, 34]

$mySelectedDay = _GUICtrlDTP_GetSystemTime($dateLogs)
$myLogFileName = StringFormat("%02d-%02d-%04d", $mySelectedDay[1], $mySelectedDay[2], $mySelectedDay[0])
Msgbox (16,"", $myLogFileName)

;rest of my code below that will load the log file for the user to view

EndFunc

However, regardless of the date selected in the datepicker control, $myLogFilename always returns a value of "00-00-00". Is there something simple I am missing here?

$dateLogs is the name of my datepicker control. Thanks for any assistance showing me the error.

-hogfan

Edited by hogfan
Link to comment
Share on other sites

What's the value of @error after you called _GUICtrlDTP_GetSystemTime? Can you call _ArrayDisplay to display the content of $mySelectedDay?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

hogfan,

You are declaring $dateLogs as an empty Global variable in that function. Do you really mean to do that as you overwrite any other assignment you have made, such as the creaton of the date picker? As a result the function has no control to interrogate when you pass it the empty variable. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba

Yes, I did catch that as well a moment and and removed that from the function. This is actually on a second form in my application, so I have this in the GUI section:

Global $dateLogs = GUICtrlCreateDate("2013/02/14 13:42:38", 8, 32, 225, 20)

However, after making this change, I'm still getting the same results. I have another function that is execute before _LoadCallLog() that creates the form with the datepicker control.

-hogfan

Link to comment
Share on other sites

  • Moderators

hogfan,

Best you post the whole thing - trying to debug an error in that single function without context is just whistling in the dark. :whistle:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Ok, here is the function that launches the second form for my log file viewer:

Func _ViewCallLogsScript ()
;MsgBox(64 , "Coming Soon!", "This feature is not ready yet, but will be implemented soon!")
If Not WinExists("Call / UPH Log Viewer") Then
$currentTool = "Call / UPH Log Viewer"
$frmLogViewer = GUICreate($currentTool, 470, 461, 704, 94)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$Group1 = GUICtrlCreateGroup("Call Log for:", 0, 8, 467, 295)
Global $lstvwLogViewer = GUICtrlCreateListView("Caller"&Chr(39)&"s Name|DSL #|Callback #|Call Type|Logged Time", 7, 64, 450, 225, BitOR($GUI_SS_DEFAULT_LISTVIEW,$WS_VSCROLL), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 90)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 85)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 85)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 74)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 90)
Global $dateLogs = GUICtrlCreateDate("2013/02/14 13:42:38", 8, 32, 225, 20)
$Label12 = GUICtrlCreateLabel("TOTAL CALLS:", 318, 31, 95, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x800000)
$cmdLoadCallLog = GUICtrlCreateButton("View", 240, 32, 67, 20)
GUICtrlSetBkColor(-1, 0x65C621)
$lblTotalCallCount = GUICtrlCreateLabel("0", 427, 31, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Productivity for ", 0, 304, 465, 153)
$Label1 = GUICtrlCreateLabel("Dynamic Calls:", 11, 336, 93, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Static Calls:", 11, 361, 73, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Chats:", 11, 395, 41, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Tickets:", 11, 420, 51, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("New Orders:", 164, 336, 78, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Change Orders:", 164, 361, 98, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label7 = GUICtrlCreateLabel("Disconnects:", 164, 395, 81, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel("New Express:", 316, 333, 86, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label9 = GUICtrlCreateLabel("Change Express:", 316, 356, 106, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label10 = GUICtrlCreateLabel("Sus/Restore:", 164, 420, 82, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label11 = GUICtrlCreateLabel("UPH:", 334, 416, 52, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$lblDailyUPH = GUICtrlCreateLabel("", 392, 416, 59, 28, $WS_BORDER)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFF00)
$lblDynCallCount = GUICtrlCreateLabel("0", 120, 336, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblStatCallCount = GUICtrlCreateLabel("0", 120, 361, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblChatCount = GUICtrlCreateLabel("0", 120, 395, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblTKTCount = GUICtrlCreateLabel("0", 120, 420, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblNewOrdCount = GUICtrlCreateLabel("0", 277, 340, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblChangeOrdCount = GUICtrlCreateLabel("0", 277, 361, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblDiscCount = GUICtrlCreateLabel("0", 277, 395, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblSusResCount = GUICtrlCreateLabel("0", 277, 420, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblCngExpCount = GUICtrlCreateLabel("0", 428, 356, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblNewExpCount = GUICtrlCreateLabel("0", 428, 333, 28, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

_GUICtrlDTP_SetFormat($dateLogs,"mm:DD:YYYY")
GUICtrlSetOnEvent($cmdLoadCallLog, "_LoadCallLog")

Else
EndIf
EndFunc

and the function called when the cmdLoadCallLog button is clicked:

Func _LoadCallLog ()

Global $mySelectedDay[7] = [False, @YEAR, 8, 19, 21, 57, 34]

$mySelectedDay = _GUICtrlDTP_GetSystemTime($dateLogs)
$myLogFileName = StringFormat("%02d-%02d-%04d", $mySelectedDay[1], $mySelectedDay[2], $mySelectedDay[0])
_ArrayDisplay($mySelectedDay)
Msgbox (16,"", @error)
Msgbox (16,"", $myLogFileName)
EndFunc

-hogfan

Edited by hogfan
Link to comment
Share on other sites

  • Moderators

hogfan,

That is of no use - it tells me no more than you have already stated in the psots above. I wanted the whole script to see ehat was happening - up to you whether you want to post it. ;)

Have you checked the value of the $dateLogs variable immediately after creation of the control and just before you try to read it? That might give you a clue - although without the rest of the script it will not do a lot for anyone else. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba-

My entire script is over 6,000 lines. These two functions are the only two that should be relevant to this issue. The first function is called to create and display the gui for the log viewer form. This function is executed when the user clicks a "View Logs" button on the main form of the application.

The second function is simply the code that is executed when a user clicks on the "View" button in the log viewer form. What I'm basically trying to do here is read the date the user chose in the datepicker control, format it as 00-00-0000. I will then use that data to open a log file with the name in 00-00-0000 format. Does this help explain the issue a little better. I'm not trying to omit information. I'm trying not to include to much unnecessary and irrelevant information.

At the top of my script I do have :

#include <GuiDateTimePicker.au3>

In my includes.

-hogfan

Link to comment
Share on other sites

  • Developers

Aren't you simply missing to GUICtrlGetHandle() the control to retrieve the proper control handle needed?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

If you could shorten the code to just the relevant functions, and it still runs, that demonstrates the problem it might be more helpful.

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

  • Moderators

Jos,

I think you have it. :thumbsup:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I agree! Gonna give that a try now. I figured I was missing something simple as usual. I must have missed that part going off of the example here:

http://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlDTP_GetSystemTime.htm. Thanks for everybody's help on this one.

-hogfan

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...