Sign in to follow this  
Followers 0
cdm_Death

AHHH Date wont select?

7 posts in this topic

So im at a loss, new to GUI's but its still got me stumped, why wont it return the variable for the dates selected, I cant seem to find the place to put thoes little $sdate $fdate variable "sets" at... I either get back the starting dates for the date selection, or I get back a "Variable used without defined" thing... help?

$INFO = ("THIS IS THE INFO")

Func EClose()

MSgBox(1, "PMG's Weekly Trip Reports", "You have closed early, Your progress will not be saved.")

FileDelete ( @DesktopDir & "\PMG's Weekly Trip Reports.txt" )

GUIDelete ("PMG's Weekly Trip Reports")

Sleep(3000)

Exit

EndFunc

Func Write1()

$file = FileOpen("PMG's Weekly Trip Reports.txt", 1)

If $file = -1 Then

MsgBox(0, "PMG's Weekly Trip Reports.txt", "An Error Has Accured, Call PMG to have this issue solved.")

Exit

EndIf

FileWrite ( $file, $1 & " Through " & $2)

FileClose ( $file )

EndFunc

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

MsgBox(0, "PMG's Weekly Trip Reports.txt", "Welcome to PMG's Weekly Trip Report, Please ensure that you have ample time to complete your log now, there will be no opertunity to save your progress.")

GUICreate ( "PMG's Weekly Trip Reports" , 300, 175)

;COLOR SET

GUICtrlCreateLabel ( "Start Date:", 10, 5)

GUICtrlCreateLabel ( "End Date:", 10, 60)

$sdate = GUICtrlCreateDate ( "2006/07/31", 20, 20, 250, 25)

$fdate = GUICtrlCreateDate ( "2006/08/06", 20, 75, 250, 25)

$next1=GUICtrlCreateButton ( "Next", 125, 125)

GUICtrlSetOnEvent($next1, "NextButton")

GUISetOnEvent($GUI_EVENT_CLOSE, "EClose")

GUISetState (@SW_SHOW)

While 1

Sleep(1000) ; Idle around

WEnd

Func NextButton()

$1 = GUICtrlRead($sdate)

$2 = GUICtrlRead ($fdate)

Write1()

GUIDelete ("PMG's Weekly Trip Reports")

EndFunc

Share this post


Link to post
Share on other sites



Your problem is that you are only setting the variables $1 and $2 in a function, and then trying to use them in another function. To make the variables global you could simply set thyem to anything in the main program like this say

GUISetState (@SW_SHOW)

$1='A'

$2='B'

Then your program will work


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

try declaring the variables as Global

Thanks a BUNCH but let me get this straight before I finish... so to set them globally i need to...

$1=GUICtrlRead($sdate)

$2=GUICtrlRead ($fdate)

And place it directly after the "show command" for the GUI?

If i rember correctly what happened whene i did this is read the variable whene it reached that point in the script, and failed to register the correct date whene it wrote to the file...

I may be wrong, but I need to set the variables from the "nextbutton" function so that it reads them after the button has been hit... Is there a global set command to attach to the;

$1 = GUICtrlRead($sdate)

$2 = GUICtrlRead ($fdate)

or even if I could globally declare;

$sdate = GUICtrlCreateDate ( "2006/07/31", 20, 20, 250, 25)

$fdate = GUICtrlCreateDate ( "2006/08/06", 20, 75, 250, 25)

and them call them from outside the function would that work?

please help :whistle: so far my scripts have been limmited to basic tasks, mostly aimed at d2 but my perants company needs a program to help there drives log there trip records, I would GREATLY apreciate the help on this...

Share this post


Link to post
Share on other sites

not test, just to show you:

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global $INFO = "THIS IS THE INFO"
Global $1, $2

MsgBox(0, "PMG's Weekly Trip Reports.txt", "Welcome to PMG's Weekly Trip Report, Please ensure that you have ample time to complete your log now, there will be no opertunity to save your progress.")
GUICreate("PMG's Weekly Trip Reports", 300, 175)
;COLOR SET
GUICtrlCreateLabel("Start Date:", 10, 5)
GUICtrlCreateLabel("End Date:", 10, 60)
$sdate = GUICtrlCreateDate("2006/07/31", 20, 20, 250, 25)
$fdate = GUICtrlCreateDate("2006/08/06", 20, 75, 250, 25)
$next1 = GUICtrlCreateButton("Next", 125, 125)
GUICtrlSetOnEvent($next1, "NextButton")
GUISetOnEvent($GUI_EVENT_CLOSE, "EClose")
GUISetState(@SW_SHOW)




While 1
    Sleep(1000) ; Idle around
WEnd


Func NextButton()
    $1 = GUICtrlRead($sdate)
    $2 = GUICtrlRead($fdate)
    
    Write1()
    GUIDelete("PMG's Weekly Trip Reports")
    
EndFunc   ;==>NextButton

Func EClose()
    MsgBox(1, "PMG's Weekly Trip Reports", "You have closed early, Your progress will not be saved.")
    FileDelete(@DesktopDir & "\PMG's Weekly Trip Reports.txt")
    GUIDelete("PMG's Weekly Trip Reports")
    Sleep(3000)
    Exit
EndFunc   ;==>EClose



Func Write1()
    $file = FileOpen("PMG's Weekly Trip Reports.txt", 1)
    If $file = -1 Then
        MsgBox(0, "PMG's Weekly Trip Reports.txt", "An Error Has Accured, Call PMG to have this issue solved.")
        Exit
    EndIf
    FileWrite($file, $1 & " Through " & $2)
    FileClose($file)
EndFunc   ;==>Write1

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

not test, just to show you:

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Global $INFO = "THIS IS THE INFO"
Global $1, $2

MsgBox(0, "PMG's Weekly Trip Reports.txt", "Welcome to PMG's Weekly Trip Report, Please ensure that you have ample time to complete your log now, there will be no opertunity to save your progress.")
GUICreate("PMG's Weekly Trip Reports", 300, 175)
;COLOR SET
GUICtrlCreateLabel("Start Date:", 10, 5)
GUICtrlCreateLabel("End Date:", 10, 60)
$sdate = GUICtrlCreateDate("2006/07/31", 20, 20, 250, 25)
$fdate = GUICtrlCreateDate("2006/08/06", 20, 75, 250, 25)
$next1 = GUICtrlCreateButton("Next", 125, 125)
GUICtrlSetOnEvent($next1, "NextButton")
GUISetOnEvent($GUI_EVENT_CLOSE, "EClose")
GUISetState(@SW_SHOW)
While 1
    Sleep(1000) ; Idle around
WEnd
Func NextButton()
    $1 = GUICtrlRead($sdate)
    $2 = GUICtrlRead($fdate)
    
    Write1()
    GUIDelete("PMG's Weekly Trip Reports")
    
EndFunc   ;==>NextButton

Func EClose()
    MsgBox(1, "PMG's Weekly Trip Reports", "You have closed early, Your progress will not be saved.")
    FileDelete(@DesktopDir & "\PMG's Weekly Trip Reports.txt")
    GUIDelete("PMG's Weekly Trip Reports")
    Sleep(3000)
    Exit
EndFunc   ;==>EClose
Func Write1()
    $file = FileOpen("PMG's Weekly Trip Reports.txt", 1)
    If $file = -1 Then
        MsgBox(0, "PMG's Weekly Trip Reports.txt", "An Error Has Accured, Call PMG to have this issue solved.")
        Exit
    EndIf
    FileWrite($file, $1 & " Through " & $2)
    FileClose($file)
EndFunc   ;==>Write1

So you are saying to put global in front of the variable to globally declare it? If I put global in front of

$sdate = GUICtrlCreateDate("2006/07/31", 20, 20, 250, 25)

$fdate = GUICtrlCreateDate("2006/08/06", 20, 75, 250, 25)

would I be able to call these variables from another function?

Share this post


Link to post
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
Sign in to follow this  
Followers 0