Jump to content

Error: "Func" statement has no matching "EndFunc"."


Recommended Posts

I'm putting 2 scripts together that work fine apart, but I'm getting an error:

"Func Click_Cancel()

Error: "Func" statement has no matching "EndFunc"."

I can't figure out how to fix this. Nothing I've tried worked.

#include <Date.au3>

$StartTime = "08:30"     ;  adjust START time here in 24-hour time
$EndTime = "17:56"     ;  adjust END time here in 24-hour time
$CurrentTime = _NowTime(4)

If @WDAY = 4 Then     ;  Choose 1 = Sunday  //  2 = Monday  //  3 = Tuesday  //  4 = Wednesday  //  5 = Thursday  //  6 = Friday  //  7 = Saturday.
If $CurrentTime >= $StartTime AND $CurrentTime <= $EndTime Then YourCodeHere()     ;  YourCodeHere calls a function
EndIf




;==========================================================================================
Func YourCodeHere()     ;  Your script goes here below ...
;==========================================================================================
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
;-----------------------------------------------------------------------------------------
; CHANGE THE FIRST # FOR EACH REMINDER -- in the "LEFT" option in GUICreate just below ...
; Increment, as needed, when they overlap ... increase LEFT and RIGHT by "25" each time
$Form1 = GUICreate("Reminder ...", 400, 150, 90, 90)     ; Width, Height, Left, Top   .....   POSITION Left+Top = 90, 90
GUISetOnEvent($GUI_EVENT_CLOSE, "Click_Cancel")
;-----------------------------------------------------------------------------------------

SoundPlay(@ScriptDir & "\..\WAVs\WAVppro- Chopper 1 (helicopter).wav")
Sleep(2500)

$Label2 = GUICtrlCreateLabel("IN BASKET ..." & @CR & "Anything new been left in your In Basket?", 22, 16, 625, 50);  Left, Right, Width, Height of inside text box.
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Snooze = GUICtrlCreateButton("Snooze", 80, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Snooze")
$Cancel = GUICtrlCreateButton("Cancel", 176, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Cancel")
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
WEnd

Func Click_Cancel()
     Exit
EndFunc     ;  End "Click_Cancel".


Func Click_Snooze()
         GUISetState(@SW_HIDE)
         $input = InputBox("IN BASKET, anything ...?", "Snooze for how many minutes?", 15)
         $time = $input*1000*60
         Sleep($time)
         #NoTrayIcon     ; AutoIt's icon doesn't show in systray
         GUISetState(@SW_SHOW)
         SoundPlay(@ScriptDir & "\..\WAVs\WAVppro- Chopper 1 (helicopter).wav")
EndFunc     ;  End "Click_Snooze
;==========================================================================================
EndFunc     ; end of your code.
;==========================================================================================

I have a bunch of these reminders now and they work great, but I need to limit about 3 of them not to work after hours. They're annoying and unnecessary when I'm staying late after work.

Thanks! :)

Edited by Diana (Cda)
Link to comment
Share on other sites

You can not place a function inside of a function

#include <Date.au3>

$StartTime = "08:30"     ;  adjust START time here in 24-hour time
$EndTime = "17:56"     ;  adjust END time here in 24-hour time
$CurrentTime = _NowTime(4)

If @WDAY = 4 Then     ;  Choose 1 = Sunday  //  2 = Monday  //  3 = Tuesday  //  4 = Wednesday  //  5 = Thursday  //  6 = Friday  //  7 = Saturday.
If $CurrentTime >= $StartTime AND $CurrentTime <= $EndTime Then YourCodeHere()     ;  YourCodeHere calls a function
EndIf




;==========================================================================================
Func YourCodeHere()     ;  Your script goes here below ...
;==========================================================================================
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
;-----------------------------------------------------------------------------------------
; CHANGE THE FIRST # FOR EACH REMINDER -- in the "LEFT" option in GUICreate just below ...
; Increment, as needed, when they overlap ... increase LEFT and RIGHT by "25" each time
$Form1 = GUICreate("Reminder ...", 400, 150, 90, 90)     ; Width, Height, Left, Top   .....   POSITION Left+Top = 90, 90
GUISetOnEvent($GUI_EVENT_CLOSE, "Click_Cancel")
;-----------------------------------------------------------------------------------------

SoundPlay(@ScriptDir & "\..\WAVs\WAVppro- Chopper 1 (helicopter).wav")
Sleep(2500)

$Label2 = GUICtrlCreateLabel("IN BASKET ..." & @CR & "Anything new been left in your In Basket?", 22, 16, 625, 50);  Left, Right, Width, Height of inside text box.
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Snooze = GUICtrlCreateButton("Snooze", 80, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Snooze")
$Cancel = GUICtrlCreateButton("Cancel", 176, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Cancel")
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
WEnd

EndFunc ; added this here ****************************

Func Click_Cancel()
     Exit
EndFunc     ;  End "Click_Cancel".


Func Click_Snooze()
         GUISetState(@SW_HIDE)
         $input = InputBox("IN BASKET, anything ...?", "Snooze for how many minutes?", 15)
         $time = $input*1000*60
         Sleep($time)
         #NoTrayIcon     ; AutoIt's icon doesn't show in systray
         GUISetState(@SW_SHOW)
         SoundPlay(@ScriptDir & "\..\WAVs\WAVppro- Chopper 1 (helicopter).wav")
EndFunc     ;  End "Click_Snooze
;==========================================================================================
;EndFunc     ; end of your code.
;==========================================================================================

8)

Is there an echo in here... :)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Oh. Well, that explains it. Is there a solution to this problem? I need to set time limits so the original script below so that it only runs between, say, 08:30 and 17:00:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
;-----------------------------------------------------------------------------------------
; CHANGE THE FIRST # FOR EACH REMINDER -- in the "LEFT" option in GUICreate just below ...
; Increment, as needed, when they overlap ... increase LEFT and RIGHT by "25" each time
$Form1 = GUICreate("Reminder ...", 400, 150, 90, 90)     ; Width, Height, Left, Top   .....   POSITION Left+Top = 90, 90
GUISetOnEvent($GUI_EVENT_CLOSE, "Click_Cancel")
;-----------------------------------------------------------------------------------------

SoundPlay(@ScriptDir & "\..\WAVs\WAVppro- Chopper 1 (helicopter).wav")
Sleep(2500)

$Label2 = GUICtrlCreateLabel("IN BASKET ..." & @CR & "Anything new been left in your In Basket?", 22, 16, 625, 50);  Left, Right, Width, Height of inside text box.
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Snooze = GUICtrlCreateButton("Snooze", 80, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Snooze")
$Cancel = GUICtrlCreateButton("Cancel", 176, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Cancel")
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
WEnd

Func Click_Cancel()
     Exit
 EndFunc     ;  End "Click_Cancel".


Func Click_Snooze()
         GUISetState(@SW_HIDE)
         $input = InputBox("IN BASKET, anything ...?", "Snooze for how many minutes?", 15)
         $time = $input*1000*60
         Sleep($time)
         #NoTrayIcon     ; AutoIt's icon doesn't show in systray
         GUISetState(@SW_SHOW)
         SoundPlay(@ScriptDir & "\..\WAVs\WAVppro- Chopper 1 (helicopter).wav")
EndFunc     ;  End "Click_Snooze

Thanks! :)

Link to comment
Share on other sites

; TIME-LIMITED
#include <Date.au3>
$StartTime = "08:30"     ;  adjust START time here in 24-hour time
$EndTime = "16:30"     ;  adjust END time here in 24-hour time
$CurrentTime = _NowTime(4)

If $CurrentTime >= $StartTime AND $CurrentTime <= $EndTime Then YourCodeHere()     ;  YourCodeHere calls a functionoÝ÷ Ù«­¢+ØìQ%5­Qµ1%5%Q(¥¹±Õ±ÐíѹÔÌÐì(ÀÌØíMÑÉÑQ¥µôÅÕ½ÐìÀàèÌÀÅÕ½Ðìì©ÕÍÐMQIPÑ¥µ¡É¥¸Èе¡½ÕÈÑ¥µ(ÀÌØí¹Q¥µôÅÕ½ÐìÄØèÌÀÅÕ½Ðìì©ÕÍÐ9Ñ¥µ¡É¥¸Èе¡½ÕÈÑ¥µ(ÀÌØí
ÕÉɹÑQ¥µô}9½ÝQ¥µ Ф()%]dôÐQ¡¸ì
¡½½ÍÄôMչ似Èô5½¹ä¼¼ÌôQÕÍä¼¼Ðô]¹Íä¼¼ÔôQ¡ÕÉÍä¼¼Øôɥ似ÜôMÑÕÉä¸)%ÀÌØí
ÕÉɹÑQ¥µÐìôÀÌØíMÑÉÑQ¥µ9ÀÌØí
ÕÉɹÑQ¥µ±ÐìôÀÌØí¹Q¥µQ¡¸e½ÕÉ
½!É ¤ìe½ÕÉ
½!ɱ±Ìչѥ½¸)¹%

Is there a way to incorporate any of the date and/or time constraints above and then calling the "YourCodeHere()" part without using this "function" thing? Thx. :)

Link to comment
Share on other sites

I am still having trouble with this <sigh>. I thankfully did end up finding a solution for this type of problem on my own re putting time and/or date and time constraints to certain scripts but I think the FUNC is making this type of script have problems still, again. Nothing I've tried works. I still am missing something I guess and until I learn it, I guess I'm not going to make any progress.

Here is the original script type. I need to limit about 3 of these scripts to run only during working hours (this is because the scheduler that runs these is as limited as most of them are. I can tell it to run every x numbers of hours but not during which times so the time constraints built into the AutoIt script do that for me.)

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
;-----------------------------------------------------------------------------------------
; CHANGE THE FIRST # FOR EACH REMINDER -- in the "LEFT" option in GUICreate just below ...
; Increment, as needed, when they overlap ... increase LEFT and RIGHT by "25" each time
$Form1 = GUICreate("Reminder ...", 400, 150, 70, 70)     ; Width, Height, Left, Top   .....   POSITION Left+Top = 70, 70
GUISetOnEvent($GUI_EVENT_CLOSE, "Click_Cancel")
;-----------------------------------------------------------------------------------------

SoundPlay(@ScriptDir & "\...\WAVs\WAVppro- Blip.wav")
Sleep(2500)

$Label2 = GUICtrlCreateLabel("VOICE MAIL MESSAGES ..." & @CR & "Are there any?", 22, 16, 625, 75);  Left, Right, Width, Height of inside text box.
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Snooze = GUICtrlCreateButton("Snooze", 80, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Snooze")
$Cancel = GUICtrlCreateButton("Cancel", 176, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Cancel")
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
WEnd

Func Click_Cancel()
    Exit
EndFunc     ;  End "Click_Cancel".


Func Click_Snooze()
    GUISetState(@SW_HIDE)
    $input = InputBox("VOICE MAIL MESSAGES ... are there any?", "Snooze for how many minutes?", 15)
    $time = $input*1000*60
    Sleep($time)
    #NoTrayIcon     ; AutoIt's icon doesn't show in systray
    GUISetState(@SW_SHOW)
    SoundPlay(@ScriptDir & "\...\WAVs\WAVppro- Phone, rotary dialing.wav")
EndFunc     ;  End "Click_SnoozeoÝ÷ ØâêÞv­¢y²£    ð«p¢¹,y'±ë+zØ^¶)jw¢·Zµç(Ëkj)í°w«z+-æÚ²',¶»¶êÞ¡ú'zËajÙÞyÛhméb+^vÚ+ºvÞ·Ç«µ¨§¶)²åÉ«­¢+Øì´´´´´1¥µ¥ÑÌÑ¥µÑ¡¥ÌÍÉ¥ÁÐÝ¥±°ÉոѼÑݸÀàèÌÀ¹´¸¹ÔèÀÀÀ¹´¸è´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´(¥¹±Õ±ÐíѹÔÌÐì(ÀÌØíMÑÉÑQ¥µôÅÕ½ÐìÀàèÌÀÅÕ½Ðìì©ÕÍÐMQIPÑ¥µ¡É¥¸Èе¡½ÕÈÑ¥µ(ÀÌØí¹Q¥µôÅÕ½ÐìÄÜèÀÀÅÕ½Ðìì©ÕÍÐ9Ñ¥µ¡É¥¸Èе¡½ÕÈÑ¥µ(ÀÌØí
ÕÉɹÑQ¥µô}9½ÝQ¥µ Ф()%ÀÌØí
ÕÉɹÑQ¥µÐìôÀÌØíMÑÉÑQ¥µ9ÀÌØí
ÕÉɹÑQ¥µ±ÐìôÀÌØí¹Q¥µQ¡¸(ìôôôôôôôôôôôôôôôôôôôôôe½ÕÈÍÉ¥ÁСɱ½Üèôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô((졵äÍÉ¥Áн̡ɤ((ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô)¹%(ì´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´

When I carefully placed the first script above within the second script where it says "; (my script goes here)", I get this error:

Func Click_Cancel()

Error:  "If" statement has no matching "EndIf" statement.

I tried putting extra EndIf's in what felt like various logical places, but that did nothing. The error keeps repeating. My ignorance of AutoIt scripting is showing here as I don't know what else to do. Does anyone here know how to fix this? I believe it's just something simple I don't know and I hope it's the case and not that this type of script won't take the time constraint part, as has happened before.

Thanks! :)

Link to comment
Share on other sites

I am still having trouble with this <sigh>. I thankfully did end up finding a solution for this type of problem on my own re putting time and/or date and time constraints to certain scripts but I think the FUNC is making this type of script have problems still, again. Nothing I've tried works. I still am missing something I guess and until I learn it, I guess I'm not going to make any progress.

Here is the original script type. I need to limit about 3 of these scripts to run only during working hours (this is because the scheduler that runs these is as limited as most of them are. I can tell it to run every x numbers of hours but not during which times so the time constraints built into the AutoIt script do that for me.)

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
;-----------------------------------------------------------------------------------------
; CHANGE THE FIRST # FOR EACH REMINDER -- in the "LEFT" option in GUICreate just below ...
; Increment, as needed, when they overlap ... increase LEFT and RIGHT by "25" each time
$Form1 = GUICreate("Reminder ...", 400, 150, 70, 70)     ; Width, Height, Left, Top   .....   POSITION Left+Top = 70, 70
GUISetOnEvent($GUI_EVENT_CLOSE, "Click_Cancel")
;-----------------------------------------------------------------------------------------

SoundPlay(@ScriptDir & "\...\WAVs\WAVppro- Blip.wav")
Sleep(2500)

$Label2 = GUICtrlCreateLabel("VOICE MAIL MESSAGES ..." & @CR & "Are there any?", 22, 16, 625, 75);  Left, Right, Width, Height of inside text box.
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Snooze = GUICtrlCreateButton("Snooze", 80, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Snooze")
$Cancel = GUICtrlCreateButton("Cancel", 176, 112, 75, 25, 0)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetOnEvent(-1, "Click_Cancel")
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
WEnd

Func Click_Cancel()
    Exit
EndFunc     ;  End "Click_Cancel".


Func Click_Snooze()
    GUISetState(@SW_HIDE)
    $input = InputBox("VOICE MAIL MESSAGES ... are there any?", "Snooze for how many minutes?", 15)
    $time = $input*1000*60
    Sleep($time)
    #NoTrayIcon     ; AutoIt's icon doesn't show in systray
    GUISetState(@SW_SHOW)
    SoundPlay(@ScriptDir & "\...\WAVs\WAVppro- Phone, rotary dialing.wav")
EndFunc     ;  End "Click_SnoozeoÝ÷ Ùh^­çvØ^~*ì¶Ç+ZnÞÂ+a{azÇ¢wlr¸©·^­è­±¬¬ªê-+®*m¬êÞªê-"­¶¬zºè­Êx[§p)br@Ç¥ãN5ºè¯7à÷âËZµéØZ²z&j×!x7àIÝ!ýø²Ö­zg§·÷(uâ-®'¦ëmxÆÚÚwHl|!j×ÞÙbëÚ®*.²Z Æ¥¦VzÆî¶ØZµØaxç«®äyêl­ê^jا̢z+jw¡ð.¶-±Êâ¦Ø§+,"^­æ¬!Ú'ßÛd0«^Ç­¡Ú¡ë*'z«zIèÂ0¶âÆØb°Þ'¯z+wöÈî²Û(ëax,jexhmz0jwH^Ýý²Ø^q«jwg¢ÛajÛaËr¥ê±Êâ¦Ü(mµ©¶­g¢{-­¨§¶«µ«!jÈZ¦§yÖÞ~ÞN§Í÷þ«¨µäáz«¶ØZ·*.±ç§¶Z½é趫¢µë§uêì¶Éëb²ØZµû§rب×{b¶ìÞÅ©©ánɲ~éÜwEºwjyèµ·§zË^w­)Ú*-êÜ¡×*.®Ç+r¢æ«zÚòx-¢w¬·*.­û§rبÌ"¶§!ý7è+«­éíN)

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

The part that you seen to have not quite understood yet is that function defintitons

For example:

Func myfunc()

....

EndFunc

can not be nested within any other code

In your script you are trying to nest your functions within

If $CurrentTime >= $StartTime AND $CurrentTime <= $EndTime Then

;===================== Your script here below: ============================================

; (my script goes here)

;=================================================================================

EndIf

This is not valid

A small change will get it all working for you. ...

<g> Thanks for being so kind re this and for explaining. The education is much appreciated! <g> I'm a power user but scripting constantly humbles me still ... All this time I've used the approach that has worked everywhere else ... I just keep plugging head, with the occasional banging head against the wall, hoping that things will click faster soon. <phew>

This is amazing. Yes, it's now working. I'll convert all the pertinent scripts that need to be time-limited to this format. What a relief that will be. This week I worked a lot of overtime and it was a pain to have some of these scripts still keep popping up after hours when they weren't needed <g>.

Link to comment
Share on other sites

<g> Thanks for being so kind re this and for explaining. The education is much appreciated! <g> I'm a power user but scripting constantly humbles me still ... All this time I've used the approach that has worked everywhere else ... I just keep plugging head, with the occasional banging head against the wall, hoping that things will click faster soon. <phew>

This is amazing. Yes, it's now working. I'll convert all the pertinent scripts that need to be time-limited to this format. What a relief that will be. This week I worked a lot of overtime and it was a pain to have some of these scripts still keep popping up after hours when they weren't needed <g>.

I've been in the same situation in the past. Sometimes you just need someone to give you a hint to point you in right direction. Glad I could help on this occasion.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

  • 2 weeks later...

MERRY CHRISTMAS EVERYONE!!! :)

********************************

I'm having a horrible time of it ... sometimes we go round and round in circles and no longer know what's what ... That's where I am at this point.

I've come to the realization that I'm missing something ...

What Bowmore so kindly provided works just great:

;----- Limits time this script will run to between 08:30 a.m. and 5:00 p.m.: --------------------------------
#include <Date.au3>
$StartTime = "08:30"     ;  adjust START time here in 24-hour time
$EndTime = "16:35"     ;  adjust END time here in 24-hour time
$CurrentTime = _NowTime(4)

If Not ($CurrentTime >= $StartTime AND $CurrentTime <= $EndTime) Then
;It's not a valid time for script to run so exit without running
    Exit
EndIf

; ========== My script down below: ===========================================================

MsgBox(0,"Message Box.","Hello!" & @CRLF & "Hello!")oÝ÷ ØǬ±¨nb²;¬µ©ÞÅ©©çè®Ç+m«p¢é]Þ-ꮢ
It would be ice to make it have the same type of syntax as the beautiful time-limited script above where there is no call to a function. If the date and time are not according to what the script will allow, then the script just exits.

So the extra line of code in question that I can't make work adds the date into the equation:

If @WDAY = 4 Then   ;  Choose 1 = Sunday  //  2 = Monday  //  3 = Tuesday  //  4 = Wednesday  //  5 = Thursday  //  6 = Friday  //  7 = Saturday.
Link to comment
Share on other sites

perhaps something like this?

;----- Limits time this script will run to between 08:30 a.m. and 5:00 p.m.: --------------------------------
#include <Date.au3>
$StartTime = "08:30"     ;  adjust START time here in 24-hour time
$EndTime = "17:00"       ;  adjust END time here in 24-hour time
$CurrentTime = _NowTime(4)

Switch @WDAY ; list days script allowed to run (allows for multiple days allowed, just uncomment ';' Case line)
    ;Case 2 ; Monday
    ;Case 3 ; Tuesday
    Case 4 ; Wednesday ; allowed on Wednesday, all other days exit unless additional lines uncommented
    ;Case 5 ; Thursday
    ;Case 6 ; Friday
    Case Else ; any day not listed in case structure
        ; 'FreeRange' Time
        Exit
EndSwitch

If Not ($CurrentTime >= $StartTime AND $CurrentTime <= $EndTime) Then
;It's not a valid time for script to run so exit without running
    Exit
EndIf

Merry Non-Denominationally Specific Generic Festive Occasion

:)

I see fascists...

Link to comment
Share on other sites

perhaps something like this?

;----- Limits time this script will run to between 08:30 a.m. and 5:00 p.m.: --------------------------------
#include <Date.au3>
$StartTime = "08:30"     ;  adjust START time here in 24-hour time
$EndTime = "17:00"       ;  adjust END time here in 24-hour time
$CurrentTime = _NowTime(4)

Switch @WDAY ; list days script allowed to run (allows for multiple days allowed, just uncomment ';' Case line)
    ;Case 2 ; Monday
    ;Case 3 ; Tuesday
    Case 4 ; Wednesday ; allowed on Wednesday, all other days exit unless additional lines uncommented
    ;Case 5 ; Thursday
    ;Case 6 ; Friday
    Case Else ; any day not listed in case structure
        ; 'FreeRange' Time
        Exit
EndSwitch

If Not ($CurrentTime >= $StartTime AND $CurrentTime <= $EndTime) Then
;It's not a valid time for script to run so exit without running
    Exit
EndIf
<lol> You guys are going to fry my brain! Just when I sort of get used to one way, another way is presented ... <g> Just out of curiousity, what's wrong with the line I mention above? This one here:
If @WDAY = 4 Then   ;  Choose 1 = Sunday  //  2 = Monday  //  3 = Tuesday  //  4 = Wednesday  //  5 = Thursday  //  6 = Friday  //  7 = Saturday.
It works in its original format with the FUNC code before and after (that I then ran into no end of troubles with <g>).. It's just when I went and tried to change it to this new structure today that it won't work. It must be something simple, and I'm just really curious as to what the problem is. Why does it work one way and what did I do to make it not work? I know I must have done something as in this new way, it doesn't do the job it's supposed to Pls, I'd like to know what that is, if I may, otherwise I won't learn <g>.

Merry Non-Denominationally Specific Generic Festive Occasion

:)

<lol> Nope. Not for me. I've gotten tired of all the PC stuff related to the holidays. MERRY CHRISTMAS!!! And I won't apologize for _MY_ cultural leanings!!! It's been MERRY CHRISTMAS for the majority of my 45 years. Any visitors can just take it in the spirit it's meant and not take it personally. If we went to other people's countries, I can guarantee you that we'd have to follow their customs and be respectful of them! <lol> [i know since 8 years of my 45 I did live in a foreign country outside of Canada as an adult. We kept our own customs at home, but respected everyone else's! <g>]

Thanks and cheers!! :P

Link to comment
Share on other sites

I'm sorry, I'm sorry. I meant to add that this code is so much better and that it's super. I didn't meant to sound as awful as all that (when I re-read my post, wrong impression might be given.)

I will be using this code instead since more than one day can be specified. It's just that before closing the case on the other script structure, I'd like to know what would make _it_ work, despite the fact that it only allows for one day condition, it seems.

Thanks again. :)

Link to comment
Share on other sites

Two examples that do same thing

;----- Limits time this script will run to between 08:30 a.m. and 5:00 p.m.: --------------------------------
#include <Date.au3>
$StartTime = "08:30"     ;  adjust START time here in 24-hour time
$EndTime = "17:00"       ;  adjust END time here in 24-hour time
$CurrentTime = _NowTime(4)


; Exit if not Wednesday
If Not @WDAY = 4 Then Exit    ;  Choose 1 = Sunday  //  2 = Monday  //  3 = Tuesday  //  4 = Wednesday  //  5 = Thursday  //  6 = Friday  //  7 = Saturday.
; script exits immediately if not Wednesday
If Not ($CurrentTime >= $StartTime AND $CurrentTime <= $EndTime) Then
; It's not a valid time for script to run so exit without running
    Exit
EndIf
; It's Wednesday and between 08:30hrs and 17:00hrs so run code here.oÝ÷ Øêí+ºÚ"µÍËKKKKH[Z]È[YHÈØÜÚ[[È]ÙY[ÌKK[
NKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKBÚ[ÛYH   Ñ]K]LÉÝÂÌÍÔÝ[YHH    ][ÝÌÌ    ][ÝÈÈYÝÕT[YHH[[YBÌÍÑ[[YHH    ][ÝÌMÎ   ][ÝÈÈYÝS[YHH[[YBÌÍÐÝ[[YHHÓÝÕ[YJ
BÈ^]YÝÙYÙ^BYÑVHH
[ÈÚÛÜÙHHHÝ[^HËÈH[Û^HËÈÈHYÙ^HËÈ
HÙYÙ^HËÈ
HHÙ^HËÈ
HY^HËÈ
ÈHØ]^KNÈ]    ÌÎNÜÈÙYÙ^HÛÈÚXÚÈÝ[[YBRYÝ
    ÌÍÐÝ[[YH    ÝÏH   ÌÍÔÝ[YHS    ÌÍÐÝ[[YH    ÏH ÌÍÑ[[YJH[]    ÌÎNÜÈÝH[Y[YHÜØÜÈ[ÛÈ^]Ú]Ý][[ÂBQ^]Q[YNÈ]   ÌÎNÜÈÙYÙ^H[]ÙY[ÌÈ[MÎÈÛÈ[HØÜX]È  ÌÎNÒYÌÎNÈÝ][Y[[[ÈÈ ÌÎNÊÌÎNÂ[ÙBNÈ]  ÌÎNÜÈÝÙYÙ^HÛÈ^]Q^][]   ÌÎNÜÈÙYÙ^H[]ÙY[ÌÈ[MÎÈÛÈ[ÛÙHK

Merry Christmas and a Happy New Year Diana

I see fascists...

Link to comment
Share on other sites

I was going to edit the post above but the forum software is corrupting the AutoIt

code boxes (again) when I go to edit the post so...

I should add as stated in the help file that the 'If' statement

can also execute a conditionally run single statement.

If Not @WDAY = 4 Then ExitoÝ÷ Ù©®r%y©Þ­©Ý²)©'âyÛ-jצz{péÚuØ­ÚÊ&©Ý±ªÞgyç^v'Úë,+i×b¶*'jW(f§vÉÞyÛhmêî·¢·Æ+baz|¨ºwvØ^¢Ø^­é^éí²ííý!ýý²Ö­zg§¶'·ôIÝýýjëh×6If Not @WDAY = 4  Then
   Msgbox(0,"","It's Not Wednesday, Goodbye")
   Exit
;Else
; 'Else' used to handle all other conditions not met by above 'If' statement 'If Not @WDAY = 4'
; not needed in this case
EndifoÝ÷ ÛH~«¨·RzW·ZÝýK­rýj·[Ú®&­ì¡÷(Ø­ÚËZµéÛ-íýK­rý²ÚîrÛ«zÖ¤zƬx%yÊ&©Ý²Ö­zg§µ`Àa©Ýr©j·¬Ýý²·­º¹ïj[¶­i¹^¡úh²ÈêÞ¶ê罩nzÈ­jYhÂÇè®kÉ^jw«r^§ʢ}ý¶wvÚ¡©ò¶§él{­Ø^­ën®w½©nz)í+jÇ®z'yçm¡×ªÞjö«¦åzÚ.±çè®·­º¹ïj[ÞÅ©©â.±ëaÄ°×!ü&¬{ñ'u,"µÈl¶»¶êÞ~æzËæèÅë~Ø^­ën®{Úç®­é²Æ yº1Éè¶wuç^Ç°êÞ{azÇ+méÈv÷öØZ½ëhuç%j·½ªâi¹^¶hÛaz·¬º[b¬zØb±«­¢+ÙMÝ¥Ñ %5Í   ½à Ä°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí5Í    ½àÝ¥±°±½Í¥¸Ôͽ¹ÌÅÕ½Ðì°Ô¤(%
Í´ÄìQ¥µ½ÕÐ($%
½¹Ñ¥¹Õ
ÍìÕ±ÑÌѼÌäí=,Ìäì(%
ÍÄì=,($$í   À ÄÀÀÀ°Ô¤(%
ÍÈì
¹°(á¥Ð)¹MÝ¥Ñ oÝ÷ Û*.­,"µÈl¶»¶êÞr¥u©l¡·¡×)¶¬jëh×6Switch @WDAY ; list days script allowed to run (allows for multiple days allowed, just uncomment ';' Case line)
    Case 4 To 6 ; Allow script to run from Wednesday To Friday
    ;Case ; add any additional days allowed
    Case Else ; any day not listed in case structure
        Exit
EndSwitch

hope that explains it clearly.

I know its easy to get 'Lost In Code' when to understand something

you need to learn a multitude of other things simultaneously.

It's enough to give one a severe case of MEGO*

*'My Eyes Glaze Over" - The effect of long government press conferences

on dry boring subjects on reporters

I see fascists...

Link to comment
Share on other sites

I was going to edit the post above but the forum software is corrupting the AutoIt

code boxes (again) when I go to edit the post so...

I hear you! Happens too often!

I should add as stated in the help file that the 'If' statement

can also execute a conditionally run single statement.

If Not @WDAY = 4 Then ExitoÝ÷ Ù©®r%y©Þ­©Ý²)©'âyÛ-jצz{péÚuØ­ÚÊ&©Ý±ªÞgyç^v'Úë,+i×b¶*'jW(f§vÉÞyÛhmêî·¢·Æ+baz|¨ºwvØ^¢Ø^­é^éí²ííý!ýý²Ö­zg§¶'·ôIÝýýjëh×6If Not @WDAY = 4  Then
   Msgbox(0,"","It's Not Wednesday, Goodbye")
   Exit
;Else
; 'Else' used to handle all other conditions not met by above 'If' statement 'If Not @WDAY = 4'
; not needed in this case
EndifoÝ÷ ÛH~«¨·RzW·ZÝýK­r ...........
Thank you! This is excellent and very kind of you.

What is extremely frustrating is that I learn other computer skills so very easily! Code just has so many variables and the syntax varies from program to program, that it's a real challenge. I will print this message out and study it. One day I'll have a break through when it becomes less about words and when I can "read" the code (like Neo! <g>) instead of getting stuck on the words and trying to figure it out that hard way ... <g>

All these explanations really, really help. I feel I get one step closer ... :)

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