Sign in to follow this  
Followers 0
timmyc

My $variables aren't coming through, have a made a wrong 'case' statement?

6 posts in this topic

#1 ·  Posted (edited)

Hi All,

Im setting up something that starts with a GUI with 3 radio buttons (shift1,shift2 and shift3) 

Depending on what radio button (shift) you select will determine the times of that shift. The night shift (shift3) will finish on a different date than it starts so i have made a separate variable for that

The issue im having is that $d (which should change based on the radio button) is not coming through when i call on it later on in the script.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_2 = GUICreate("Date/Time Changer", 503, 331, 192, 132)
$shift1 = GUICtrlCreateRadio("Day Shift", 32, 120, 137, 25)
$shift2 = GUICtrlCreateRadio("Arvo Shift", 30, 158, 137, 25)
$shift3 = GUICtrlCreateRadio("Night shift", 30, 198, 137, 25)
$HPOV = GUICtrlCreateLabel("HPOV Date Changer", 104, 16, 330, 52)
GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman")
$Go = GUICtrlCreateButton("Go", 288, 264, 153, 33)
$date1 = GUICtrlCreateInput("DD/MM/14", 216, 72, 137, 24)
$Startlabel = GUICtrlCreateLabel("Starting Date", 112, 80, 89, 20)
$Finlabel = GUICtrlCreateLabel("Finishing Date     (For Night Shift only)", 168, 200, 113, 36)
$date2 = GUICtrlCreateInput("DD/MM/14", 288, 200, 137, 24)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $start, $finish, $shift1, $shift2, $shift3, $dateme, $d

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
  Exit
Case $Go
if GUICtrlRead($shift1) then $start = "08:30"
 if GUICtrlRead($shift1) then $finish = "15:00"
If GUICtrlRead($shift1) Then $d = $date1


  if GUICtrlRead($shift2) then $start = "15:00"
  if GUICtrlRead($shift2) then $finish = "23:30"
 If GUICtrlRead($shift2) Then $d = $date1


if GUICtrlRead($shift3) then $start = "23:30"
if GUICtrlRead($shift3) then $finish = "09:00"
  If GUICtrlRead($shift3) Then $d = $date2


runjob ()
EndSwitch
WEnd

 



Can anyone have a look at the above and make sure it is formatted correctly.

Thanks
Tim

Edited by timmyc

Share this post


Link to post
Share on other sites



The night shift always ends startdate + 1 day? So you could always calculate the end date yourself for shift 3. You would avoid typos etc.

Check the example script for GUICtrlCreateRadio to see how to check for a checked radio.

Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED




			
		

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

here you go

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_2 = GUICreate("Date/Time Changer", 503, 331, 192, 132)
$shift1 = GUICtrlCreateRadio("Day Shift", 32, 120, 137, 25)
$shift2 = GUICtrlCreateRadio("Arvo Shift", 30, 158, 137, 25)
$shift3 = GUICtrlCreateRadio("Night shift", 30, 198, 137, 25)
$HPOV = GUICtrlCreateLabel("HPOV Date Changer", 104, 16, 330, 52)
GUICtrlSetFont(-1, 20, 800, 0, "Times New Roman")
$Go = GUICtrlCreateButton("Go", 288, 264, 153, 33)
$date1 = GUICtrlCreateInput("DD/MM/14", 216, 72, 137, 24)
$Startlabel = GUICtrlCreateLabel("Starting Date", 112, 80, 89, 20)
$Finlabel = GUICtrlCreateLabel("Finishing Date     (For Night Shift only)", 168, 200, 113, 36)
$date2 = GUICtrlCreateInput("DD/MM/14", 288, 200, 137, 24)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $start, $finish, $shift1, $shift2, $shift3, $dateme, $d

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
  Exit
Case $Go
    $bContinue = True
    If GUICtrlRead($shift1)=1 Then
        $start = "08:30"
        $finish = "15:00"
        $d = $date1
    ElseIf GUICtrlRead($shift2)=1 Then
        $start = "15:00"
        $finish = "23:30"
        $d = $date1
    ElseIf GUICtrlRead($shift3)=1 Then
        $start = "23:30"
        $finish = "09:00"
        $d = $date2
    Else
        $start = ""
        $finish = ""
        $d = ""
        MsgBox(1,1,"No shift selected")
        $bContinue = False
    EndIf
    MsgBox(1,1, $start & @CRLF & $finish & @CRLF & $d)
    If $bContinue Then runjob ()

EndSwitch
WEnd
1 person likes this

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks alot jdelaney!

...hmm only thing is when i use your script the message box that should pop up and show me the variables is pulling $start $finish fine but not $d, it just says that $d = 8, also when the script continues and dumps the values in a field it comes out as 8.

Any idea what would be causing that?

Edited by timmyc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ah, I just worked on the switch.  You would need to guictrlread those 'dates'.

$d = guictrlread($date2)

 

Edited by jdelaney
1 person likes this

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You are a legend my friend! 
Thanks alot (i should of thought of that) 

Edited by timmyc

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