LMTA Posted November 15, 2010 Share Posted November 15, 2010 Dear AutoIT-guru's ,I am working on a script which should be able to check the contents of four directories. If the filecount exceeds a specific limit, the script will advice the user that this situation occurred. The script is working for the most part, though it's not complete yet, however: I am experiencing difficulties with the checkbox part. (Apologies that my arrays and variables are named in the Dutch language).What I would like to accomplish, is that the script will read the contents of the settings (INI) file, and accordingly set the checkbox in the right way. When the user changes the checkbox, the INI file should be updated and the GUI checkbox should stay the way it was set. With what I've produced so far, I am not able to set the checkbox at all. Furthermore, it seems that the INI file is not updated. The second problem I am having, is the fact that only one folder (the first in the function BestandenTellen()) is working, the other three are not. I have tried to debug to a messagebox, and I am seeing the the filecount is correct. I guess the coding problem lies in the fact that my While loops are not the right, or the 'Select / EndSelect' or 'Switch / EndSwitch' are wrong. I have to make a note that I am not a programmer at all, I think that is painfully clear with my code. My sincere apologies for this, but I am trying to do my best. Could anyone give me some advice, tips or other comments in order to solve the issues I have? Any help is very much appreciated!Kind regards,Sam, ICT Department - LMTA. Code follows, ICO file attached.Contents of INI file:[Instellingen] Map1="C:\1" Map2="C:\2" Map3="C:\3" Map4="C:\4" MinutenWachttijd=1 Waarschuwingsgeluid=1 AantalBestanden=50expandcollapse popup#Region ;**** Includes voor de functies in dit script **** #Include <Constants.au3> #Include <File.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIButton.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #EndRegion ;**** Einde regio includes **** #Region ;**** Opties **** Opt("TrayAutoPause", 0) Opt("TrayIconHide", 0) Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) #EndRegion ;**** Einde regio opties **** #Region ;**** Declaratie variabelen **** $Versie = "ElmoReader 0.5" $Icoon = TraySetIcon(@ScriptDir & "\" & "ElmoReader.ico") $Map1 = IniRead ("ElmoReader.ini", "Instellingen", "Map1", "L:\Koppeling_Apparatuur\CassControl\Import") $Map2 = IniRead ("ElmoReader.ini", "Instellingen", "Map2", "") $Map3 = IniRead ("ElmoReader.ini", "Instellingen", "Map3", "") $Map4 = IniRead ("ElmoReader.ini", "Instellingen", "Map4", "") $Wachttijd = IniRead("ElmoReader.ini", "Instellingen", "MinutenWachttijd", "1000") $Wachttijd = Number($Wachttijd*60000) $Geluid = IniRead("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "1") $AantalBestanden = IniRead("ElmoReader.ini", "Instellingen", "AantalBestanden", "50") Global $BestandError, $LockBestand = @ScriptDir & "\" & "ElmoReader.lck" #EndRegion ;**** Einde regio declaratie variabelen **** #Region ;**** Trayicoon instellen en gereedmaken voor gebruik **** $TrayInstellingen = TrayCreateItem("Instellingen aanpassen...") TrayItemSetOnEvent($TrayInstellingen, "InstellingenMenu") $TrayEinde = TrayCreateItem("Afsluiten") TrayItemSetOnEvent($TrayEinde, "Einde") TraySetState() #EndRegion ;**** Einde regio trayicoon instellen en gereedmaken voor gebruik **** BestandLezen() While 1 BestandenTellen() WEnd Func BestandLezen() If FileExists($LockBestand) Then BestandBestaat() Else BestandMaken() EndIf EndFunc Func BestandBestaat() $Gebruiker = FileReadLine($LockBestand, 1) $Station = FileReadLine($LockBestand, 2) MsgBox(48, "ElmoReader reeds gestart", "ElmoReader is al gestart door " _ & $Gebruiker & " op werkstation " & $Station & "." & @LF _ & "Zorg er eerst voor dat deze instantie wordt afgesloten," & @LF _ & "ElmoReader zal worden beƫindigd.") FileClose($LockBestand) Exit EndFunc Func BestandMaken() _FileCreate($LockBestand) $LB = FileOpen ($LockBestand, 2) FileWrite ($LockBestand, @UserName & @CRLF) FileWrite ($LockBestand, @ComputerName) FileClose ($LB) BestandenTellen() EndFunc Func BestandenTellen() $Aantal1 = DirGetSize($Map1, 3) $Aantal2 = DirGetSize($Map2, 3) $Aantal3 = DirGetSize($Map3, 3) $Aantal4 = DirGetSize($Map4, 3) Switch 1 Case $Aantal1[1] > $AantalBestanden TraySetState(4) If $Geluid=1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map1 & " zijn" & @LF & $Aantal1[1] & @LF & "bestanden gevonden!", -1, 2) Sleep ($Wachttijd) Else TrayTip("Elmo zegt:", "In de map " & $Map1 & " zijn" & @LF & $Aantal1[1] & @LF & "bestanden gevonden!", -1, 2) Sleep ($Wachttijd) EndIf Case $Aantal1[1] <= $AantalBestanden TraySetState(8) TrayTip("Leegmaken", "", 0) Sleep ($Wachttijd) Case $Aantal2[1] > $AantalBestanden TraySetState(4) If $Geluid=1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map2 & " zijn" & @LF & $Aantal2[1] & @LF & "bestanden gevonden!", -1, 2) Sleep ($Wachttijd) Else TrayTip("Elmo zegt:", "In de map " & $Map2 & " zijn" & @LF & $Aantal2[1] & @LF & "bestanden gevonden!", -1, 2) Sleep ($Wachttijd) EndIf Case $Aantal2[1] <= $AantalBestanden TraySetState(8) TrayTip("Leegmaken", "", 0) Sleep ($Wachttijd) Case $Aantal3[1] > $AantalBestanden TraySetState(4) If $Geluid=1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map3 & " zijn" & @LF & $Aantal3[1] & @LF & "bestanden gevonden!", -1, 2) Sleep ($Wachttijd) Else TrayTip("Elmo zegt:", "In de map " & $Map3 & " zijn" & @LF & $Aantal3[1] & @LF & "bestanden gevonden!", -1, 2) Sleep ($Wachttijd) EndIf Case $Aantal3[1] <= $AantalBestanden TraySetState(8) TrayTip("Leegmaken", "", 0) Sleep ($Wachttijd) Case $Aantal4[1] > $AantalBestanden TraySetState(4) If $Geluid=1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map4 & " zijn" & @LF & $Aantal4[1] & @LF & "bestanden gevonden!", -1, 2) Sleep ($Wachttijd) Else TrayTip("Elmo zegt:", "In de map " & $Map4 & " zijn" & @LF & $Aantal4[1] & @LF & "bestanden gevonden!", -1, 2) Sleep ($Wachttijd) EndIf Case $Aantal4[1] <= $AantalBestanden TraySetState(8) TrayTip("Leegmaken", "", 0) Sleep ($Wachttijd) EndSwitch EndFunc Func Waarschuwingsgeluid() Beep (150, 45) Sleep(35) Beep (250, 45) Sleep(35) Beep (350, 45) Sleep(35) Beep (450, 45) EndFunc Func InstellingenMenu() $FormINIaanpassen = GUICreate("ElmoReader - Instellingen", 387, 296, 195, 124) $MenuItemBestand = GUICtrlCreateMenu("&Bestand") $Menu_Afsluiten = GUICtrlCreateMenuItem("A&fsluiten", $MenuItemBestand) $FormINIaanpassencontext = GUICtrlCreateContextMenu() $MenuInformatie = GUICtrlCreateMenuItem("Meer informatie...", $FormINIaanpassencontext) GUISetFont(8, 400, 0, "Verdana") $BoxGeluid = GUICtrlCreateCheckbox("BoxGeluid", 339, 24, 15, 15) $BoxGeluidVinkje = IniRead("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "") GUICtrlSetCursor (-1, 0) $InputDrempelwaarde = GUICtrlCreateInput($AantalBestanden, 310, 53, 50, 21, BitOR($ES_NUMBER, $ES_RIGHT)) $OpNeerAantal = GUICtrlCreateUpdown($InputDrempelwaarde) GUICtrlSetLimit(-1, 200, 1) GUICtrlSetCursor (-1, 0) $InputMinuten = GUICtrlCreateInput($Wachttijd, 319, 86, 40, 21, BitOR($ES_NUMBER, $ES_RIGHT)) $OpNeerMinuten = GUICtrlCreateUpdown($InputMinuten) GUICtrlSetLimit(-1, 60, 1) GUICtrlSetCursor (-1, 0) $InputMap1 = GUICtrlCreateInput($Map1, 70, 120, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor (-1, 5) $ButtonMap1 = GUICtrlCreateButton("...", 351, 121, 20, 20) $InputMap2 = GUICtrlCreateInput($Map2, 70, 146, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor (-1, 5) $ButtonMap2 = GUICtrlCreateButton("...", 351, 147, 20, 20) $InputMap3 = GUICtrlCreateInput($Map3, 70, 172, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor (-1, 5) $ButtonMap3 = GUICtrlCreateButton("...", 351, 173, 20, 20) $InputMap4 = GUICtrlCreateInput($Map4, 70, 198, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor (-1, 5) $ButtonMap4 = GUICtrlCreateButton("...", 351, 199, 20, 20) ;$ButtonOpslaan = GUICtrlCreateButton("Opslaan", 225, 232, 60, 25, 0) $ButtonAfsluiten = GUICtrlCreateButton("OK", 290, 232, 60, 25, 0) $LabelGeluid = GUICtrlCreateLabel("Geluid in- of uitschakelen bij een alarmering:", 24, 26, 263, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelDrempelwaarde = GUICtrlCreateLabel("Bij hoeveel aangetroffen bestanden alarmeren:", 24, 56, 276, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelWachttijd = GUICtrlCreateLabel("Wachttijd tussen de controles, in minuten:", 24, 90, 245, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelMap = GUICtrlCreateLabel("Map 1:", 24, 123, 43, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelMap2 = GUICtrlCreateLabel("Map 2:", 24, 149, 43, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelMap3 = GUICtrlCreateLabel("Map 3:", 24, 175, 43, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelMap4 = GUICtrlCreateLabel("Map 4:", 24, 201, 43, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $GroupBox = GUICtrlCreateGroup(" Instellingen ", 5, 4, 377, 265, $WS_CLIPSIBLINGS) GUICtrlSetFont(-1, 8, 800, 2, "Verdana") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 2 $GUIBericht = GUIGetMsg() Select Case $GUIBericht = $GUI_EVENT_CLOSE Or $GUIBericht = $ButtonAfsluiten Or $GUIBericht = $Menu_Afsluiten ExitLoop Case $GUIBericht = $MenuInformatie MsgBox(64, "Informatie", "In dit venster kunnen diverse opties worden ingesteld," & @LF _ & "zoals de locatie waar bestanden moeten worden geteld door ElmoReader," & @LF _ & "of het waarschuwingsgeluid moet worden ingeschakeld of niet," & @LF _ & "wat de drempelwaarde is alvorens ElmoReader gaat alarmeren en" & @LF _ & "hoeveel tijd er tussen de controle pogingen in moet zitten.") Case $GUIBericht = $ButtonMap1 $Map1 = FileSelectFolder("Selecteer te controleren map 1:", "", 7) GUICtrlSetData ($InputMap1, $Map1) $Map1Lezen = GUICtrlRead ($InputMap1) IniWrite("ElmoReader.ini", "Instellingen", "Map1", '"' & $Map1Lezen & '"') Case $GUIBericht = $ButtonMap2 $Map2 = FileSelectFolder("Selecteer te controleren map 2:", "", 7) GUICtrlSetData ($InputMap2, $Map2) $Map2Lezen = GUICtrlRead ($InputMap2) IniWrite("ElmoReader.ini", "Instellingen", "Map2", '"' & $Map2Lezen & '"') Case $GUIBericht = $ButtonMap3 $Map3 = FileSelectFolder("Selecteer te controleren map 3:", "", 7) GUICtrlSetData ($InputMap3, $Map3) $Map3Lezen = GUICtrlRead ($InputMap3) IniWrite("ElmoReader.ini", "Instellingen", "Map3", '"' & $Map3Lezen & '"') Case $GUIBericht = $ButtonMap4 $Map4 = FileSelectFolder("Selecteer te controleren map 4:", "", 7) GUICtrlSetData ($InputMap4, $Map4) $Map4Lezen = GUICtrlRead ($InputMap4) IniWrite("ElmoReader.ini", "Instellingen", "Map4", '"' & $Map4Lezen & '"') Case $BoxGeluidVinkje = 0 Sleep(2500) GUICtrlSetState($BoxGeluid, $GUI_UNCHECKED) IniWrite("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "0") Case $BoxGeluidVinkje <> 0 Sleep(2500) GUICtrlSetState($BoxGeluid, $GUI_CHECKED) IniWrite("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "1") EndSelect WEnd GUIDelete() EndFunc Func InstellingenEinde() GUIDelete() EndFunc Func Einde() FileDelete($LockBestand) Sleep(500) Exit EndFuncElmoReader.ico Link to comment Share on other sites More sharing options...
Developers Jos Posted November 15, 2010 Developers Share Posted November 15, 2010 No problem these Dutch variables Try this updated Func: expandcollapse popupFunc InstellingenMenu() $FormINIaanpassen = GUICreate("ElmoReader - Instellingen", 387, 296, 195, 124) $MenuItemBestand = GUICtrlCreateMenu("&Bestand") $Menu_Afsluiten = GUICtrlCreateMenuItem("A&fsluiten", $MenuItemBestand) $FormINIaanpassencontext = GUICtrlCreateContextMenu() $MenuInformatie = GUICtrlCreateMenuItem("Meer informatie...", $FormINIaanpassencontext) GUISetFont(8, 400, 0, "Verdana") $BoxGeluid = GUICtrlCreateCheckbox("BoxGeluid", 339, 24, 15, 15) If IniRead("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "0") = "1" then GUICtrlSetState($BoxGeluid, $GUI_CHECKED) GUICtrlSetCursor(-1, 0) $InputDrempelwaarde = GUICtrlCreateInput($AantalBestanden, 310, 53, 50, 21, BitOR($ES_NUMBER, $ES_RIGHT)) $OpNeerAantal = GUICtrlCreateUpdown($InputDrempelwaarde) GUICtrlSetLimit(-1, 200, 1) GUICtrlSetCursor(-1, 0) $InputMinuten = GUICtrlCreateInput($Wachttijd, 319, 86, 40, 21, BitOR($ES_NUMBER, $ES_RIGHT)) $OpNeerMinuten = GUICtrlCreateUpdown($InputMinuten) GUICtrlSetLimit(-1, 60, 1) GUICtrlSetCursor(-1, 0) $InputMap1 = GUICtrlCreateInput($Map1, 70, 120, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor(-1, 5) $ButtonMap1 = GUICtrlCreateButton("...", 351, 121, 20, 20) $InputMap2 = GUICtrlCreateInput($Map2, 70, 146, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor(-1, 5) $ButtonMap2 = GUICtrlCreateButton("...", 351, 147, 20, 20) $InputMap3 = GUICtrlCreateInput($Map3, 70, 172, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor(-1, 5) $ButtonMap3 = GUICtrlCreateButton("...", 351, 173, 20, 20) $InputMap4 = GUICtrlCreateInput($Map4, 70, 198, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor(-1, 5) $ButtonMap4 = GUICtrlCreateButton("...", 351, 199, 20, 20) ;$ButtonOpslaan = GUICtrlCreateButton("Opslaan", 225, 232, 60, 25, 0) $ButtonAfsluiten = GUICtrlCreateButton("OK", 290, 232, 60, 25, 0) $LabelGeluid = GUICtrlCreateLabel("Geluid in- of uitschakelen bij een alarmering:", 24, 26, 263, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelDrempelwaarde = GUICtrlCreateLabel("Bij hoeveel aangetroffen bestanden alarmeren:", 24, 56, 276, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelWachttijd = GUICtrlCreateLabel("Wachttijd tussen de controles, in minuten:", 24, 90, 245, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelMap = GUICtrlCreateLabel("Map 1:", 24, 123, 43, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelMap2 = GUICtrlCreateLabel("Map 2:", 24, 149, 43, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelMap3 = GUICtrlCreateLabel("Map 3:", 24, 175, 43, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $LabelMap4 = GUICtrlCreateLabel("Map 4:", 24, 201, 43, 17) GUICtrlSetFont(-1, 8, 400, 2, "Verdana") $GroupBox = GUICtrlCreateGroup(" Instellingen ", 5, 4, 377, 265, $WS_CLIPSIBLINGS) GUICtrlSetFont(-1, 8, 800, 2, "Verdana") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 2 $GUIBericht = GUIGetMsg() Select Case $GUIBericht = $GUI_EVENT_CLOSE Or $GUIBericht = $ButtonAfsluiten Or $GUIBericht = $Menu_Afsluiten ExitLoop Case $GUIBericht = $MenuInformatie MsgBox(64, "Informatie", "In dit venster kunnen diverse opties worden ingesteld," & @LF _ & "zoals de locatie waar bestanden moeten worden geteld door ElmoReader," & @LF _ & "of het waarschuwingsgeluid moet worden ingeschakeld of niet," & @LF _ & "wat de drempelwaarde is alvorens ElmoReader gaat alarmeren en" & @LF _ & "hoeveel tijd er tussen de controle pogingen in moet zitten.") Case $GUIBericht = $ButtonMap1 $Map1 = FileSelectFolder("Selecteer te controleren map 1:", "", 7) GUICtrlSetData($InputMap1, $Map1) $Map1Lezen = GUICtrlRead($InputMap1) IniWrite("ElmoReader.ini", "Instellingen", "Map1", '"' & $Map1Lezen & '"') Case $GUIBericht = $ButtonMap2 $Map2 = FileSelectFolder("Selecteer te controleren map 2:", "", 7) GUICtrlSetData($InputMap2, $Map2) $Map2Lezen = GUICtrlRead($InputMap2) IniWrite("ElmoReader.ini", "Instellingen", "Map2", '"' & $Map2Lezen & '"') Case $GUIBericht = $ButtonMap3 $Map3 = FileSelectFolder("Selecteer te controleren map 3:", "", 7) GUICtrlSetData($InputMap3, $Map3) $Map3Lezen = GUICtrlRead($InputMap3) IniWrite("ElmoReader.ini", "Instellingen", "Map3", '"' & $Map3Lezen & '"') Case $GUIBericht = $ButtonMap4 $Map4 = FileSelectFolder("Selecteer te controleren map 4:", "", 7) GUICtrlSetData($InputMap4, $Map4) $Map4Lezen = GUICtrlRead($InputMap4) IniWrite("ElmoReader.ini", "Instellingen", "Map4", '"' & $Map4Lezen & '"') Case $GUIBericht = $BoxGeluid If GUICtrlRead($GUIBericht) = $GUI_CHECKED Then IniWrite("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "1") Else IniWrite("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "0") EndIf EndSelect WEnd GUIDelete() EndFunc ;==>InstellingenMenu 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 More sharing options...
LMTA Posted November 15, 2010 Author Share Posted November 15, 2010 Dear Jos,Thank you very much for your help, your suggestion did the trick! And I also understand how it works However, I am not that skilled that I understand why my script was working so fuzzy. I am going to continue in completing the script, maybe someone is interested in the final result, and if so, I will upload it here. Jos, do you also have a suggestion for me concerning the counting files function? At this point, the function only checks one directory: the first. All the others are not polled, as it seems and I cannot get my finger around it. Thanks again for your help and with regards,Sam. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 15, 2010 Developers Share Posted November 15, 2010 Not completely sure how you want this to operate, but your case logic doesn't look right. Is this what you are looking for? : expandcollapse popupFunc BestandenTellen() $Aantal1 = DirGetSize($Map1, 3) $Aantal2 = DirGetSize($Map2, 3) $Aantal3 = DirGetSize($Map3, 3) $Aantal4 = DirGetSize($Map4, 3) If $Aantal1[1] > $AantalBestanden Then TraySetState(4) If $Geluid = 1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map1 & " zijn" & @LF & $Aantal1[1] & @LF & "bestanden gevonden!", -1, 2) Sleep($Wachttijd) Else TrayTip("Elmo zegt:", "In de map " & $Map1 & " zijn" & @LF & $Aantal1[1] & @LF & "bestanden gevonden!", -1, 2) Sleep($Wachttijd) EndIf ElseIf $Aantal2[1] > $AantalBestanden Then TraySetState(4) If $Geluid = 1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map2 & " zijn" & @LF & $Aantal2[1] & @LF & "bestanden gevonden!", -1, 2) Sleep($Wachttijd) Else TrayTip("Elmo zegt:", "In de map " & $Map2 & " zijn" & @LF & $Aantal2[1] & @LF & "bestanden gevonden!", -1, 2) Sleep($Wachttijd) EndIf ElseIf $Aantal3[1] > $AantalBestanden Then TraySetState(4) If $Geluid = 1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map3 & " zijn" & @LF & $Aantal3[1] & @LF & "bestanden gevonden!", -1, 2) Sleep($Wachttijd) Else TrayTip("Elmo zegt:", "In de map " & $Map3 & " zijn" & @LF & $Aantal3[1] & @LF & "bestanden gevonden!", -1, 2) Sleep($Wachttijd) EndIf ElseIf $Aantal4[1] > $AantalBestanden Then TraySetState(4) If $Geluid = 1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map4 & " zijn" & @LF & $Aantal4[1] & @LF & "bestanden gevonden!", -1, 2) Sleep($Wachttijd) Else TrayTip("Elmo zegt:", "In de map " & $Map4 & " zijn" & @LF & $Aantal4[1] & @LF & "bestanden gevonden!", -1, 2) Sleep($Wachttijd) EndIf Else $Aantal4[1] <= $AantalBestanden TraySetState(8) TrayTip("Leegmaken", "", 0) Sleep($Wachttijd) EndIf EndFunc ;==>BestandenTellen Groet Jos 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 More sharing options...
Spiff59 Posted November 15, 2010 Share Posted November 15, 2010 To put to words what Jos explained very nicely via code, once any Case condition is found to be true, no further Case clauses in the Switch statement are evaluated. Link to comment Share on other sites More sharing options...
LMTA Posted November 15, 2010 Author Share Posted November 15, 2010 I might have a problem with my AutoIT version (I still run 3.3.6.0), after pasting your code, I get some 'Undefined function' errors: C:\_Scripts\ElmoReaderupd.au3(122,10) : ERROR: syntax error Else $Aantal4 ~~~~~~~~~^ C:\Scripts\ElmoReaderupd.au3(35,61) : ERROR: InstellingenMenu(): undefined function. TrayItemSetOnEvent($TrayInstellingen, "InstellingenMenu") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Scripts\ElmoReaderupd.au3(37,43) : ERROR: Einde(): undefined function. TrayItemSetOnEvent($TrayEinde, "Einde") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Scripts\ElmoReaderupd.au3(83,33) : ERROR: Waarschuwingsgeluid(): undefined function. Waarschuwingsgeluid() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Scripts\ElmoReaderupd.au3 - 4 error(s), 0 warning(s)At least, I saw some other people having this issue and some of those errors were resolved after installing the latest version. Or would this be something else in your opinion? Regards,Sam. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 15, 2010 Developers Share Posted November 15, 2010 I made the changes without any testing... an Else doesn't have any other parameters so just remove the rest. It was intended to get you started not to give you a full solution. Jos 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 More sharing options...
LMTA Posted November 15, 2010 Author Share Posted November 15, 2010 (edited) Apologies, my bad! I will give it a go and post the results back here tomorrow. A big thank you! Edited November 15, 2010 by LMTA Link to comment Share on other sites More sharing options...
LMTA Posted November 15, 2010 Author Share Posted November 15, 2010 (edited) To put to words what Jos explained very nicely via code, once any Case condition is found to be true, no further Case clauses in the Switch statement are evaluated.Hi Spiff, Thanks for the elaboration, this helps! It's completely clear to me now. I mis-used the Case statements for the purpose I had in mind.Regards,Sam. Edited November 15, 2010 by LMTA Link to comment Share on other sites More sharing options...
Spiff59 Posted November 15, 2010 Share Posted November 15, 2010 (edited) You could also, if interested, implement an array or two and shorten the code considerably, something like: Global $Map[5], $HuskerDu[5] = ["","L:\Koppeling_Apparatuur\CassControl\Import"] For $x = 1 to 4 $Map[$x] = IniRead ("ElmoReader.ini", "Instellingen", "Map" & $x, $HuskerDu[$x]) Next and Func BestandenTellen() Local $Aantal[5], $YegElskerDem For $x = 1 to 4 $YegElskerDem = DirGetSize($Map[$x], 3) $Aantal[$x] = $YegElskerDem[1] If $Aantal[$x] > $AantalBestanden Then TraySetState(4) If $Geluid=1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map[$x] & " zijn" & @LF & $Aantal[$x] & @LF & "bestanden gevonden!", -1, 2) Else TraySetState(8) TrayTip("Leegmaken", "", 0) EndIf Sleep ($Wachttijd) Next EndFunc Edit: changed variable name (The only Dutch I know.. or is it Dutch...? I think that is what is carved into a wooden whale hanging in the study. It's been a while since I glanced at it though, so I might have misquoted.) Edit2: poop. I googled it, looks like it's Norwegian. (and added HuskerDu variable) Edited November 15, 2010 by Spiff59 Link to comment Share on other sites More sharing options...
LMTA Posted November 15, 2010 Author Share Posted November 15, 2010 Hi Spiff!Thanks for your great suggestion, I will definately try that! I was already thinking about shortening the code, since the current code is not efficient at all. I will start this puzzle tomorrow and get back at this post to give a status report. You were right, btw: it's Dutch indeed Regards,Sam. Link to comment Share on other sites More sharing options...
LMTA Posted November 16, 2010 Author Share Posted November 16, 2010 Hello again, I am happy with the additions from Jos and Spiff. This is the result so far: expandcollapse popup#Region ;**** Includes voor de functies in dit script **** #Include <Constants.au3> #Include <File.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIButton.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #EndRegion ;**** Einde regio includes **** #Region ;**** Opties **** Opt("TrayAutoPause", 0) Opt("TrayIconHide", 0) Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) #EndRegion ;**** Einde regio opties **** #Region ;**** Declaratie variabelen **** $Versie = "ElmoReader 2.0Ć" $IcoonTray = TraySetIcon(@ScriptDir & "\" & "ElmoReader.ico") $Icoon = (@ScriptDir & "\" & "ElmoReader.ico") $MapSel1 = IniRead ("ElmoReader.ini", "Instellingen", "Map1", "L:\Koppeling_Apparatuur\CassControl\Import") $MapSel2 = IniRead ("ElmoReader.ini", "Instellingen", "Map2", "") $MapSel3 = IniRead ("ElmoReader.ini", "Instellingen", "Map3", "") $MapSel4 = IniRead ("ElmoReader.ini", "Instellingen", "Map4", "") $Wachttijd = IniRead("ElmoReader.ini", "Instellingen", "MinutenWachttijd", "1000") $Wachttijd = Number($Wachttijd*60000) ; Omzetten milliseconde naar minuten = vermenigvuldigen met 60.000 $Geluid = IniRead("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "1") $AantalBestanden = IniRead("ElmoReader.ini", "Instellingen", "AantalBestanden", "50") Global $BestandError, $LockBestand = @ScriptDir & "\" & "ElmoReader.lck", $Map[5], $Mappen[5] = ["","L:\Koppeling_Apparatuur\CassControl\Import"] For $x = 1 to 4 $Map[$x] = IniRead ("ElmoReader.ini", "Instellingen", "Map" & $x, $Mappen[$x]) Next #EndRegion ;**** Einde regio declaratie variabelen **** #Region ;**** Trayicoon instellen en gereedmaken voor gebruik **** $TrayInstellingen = TrayCreateItem("Instellingen aanpassen...") TrayItemSetOnEvent($TrayInstellingen, "InstellingenMenu") $TrayEinde = TrayCreateItem("Afsluiten ElmoReader") TrayItemSetOnEvent($TrayEinde, "Einde") TraySetState() #EndRegion ;**** Einde regio trayicoon instellen en gereedmaken voor gebruik **** BestandLezen() While 1 BestandenTellen() WEnd Func BestandLezen() If FileExists($LockBestand) Then BestandBestaat() Else BestandMaken() EndIf EndFunc Func BestandBestaat() $Gebruiker = FileReadLine($LockBestand, 1) $Station = FileReadLine($LockBestand, 2) MsgBox(48, "ElmoReader reeds gestart", "ElmoReader is al gestart door " _ & $Gebruiker & " op werkstation " & $Station & "." & @LF _ & "Zorg er eerst voor dat deze instantie wordt afgesloten," & @LF _ & "ElmoReader zal worden beĆ«indigd.") FileClose($LockBestand) Exit EndFunc Func BestandMaken() _FileCreate($LockBestand) $LB = FileOpen ($LockBestand, 2) FileWrite ($LockBestand, @UserName & @CRLF) FileWrite ($LockBestand, @ComputerName) FileClose ($LB) BestandenTellen() EndFunc Func BestandenTellen() Local $Aantal[5], $Mappen For $x = 1 to 4 $Mappen = DirGetSize($Map[$x], 3) $Aantal[$x] = $Mappen[1] If $Aantal[$x] > $AantalBestanden Then TraySetState(4) If $Geluid=1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map[$x] & " zijn" & @LF & $Aantal[$x] & @LF & "bestanden gevonden!", -1, 2) Else TraySetState(8) TrayTip("Leegmaken", "", 0) EndIf Sleep ($Wachttijd) Next EndFunc Func Waarschuwingsgeluid() Beep (150, 45) Sleep(35) Beep (250, 45) Sleep(35) Beep (350, 45) Sleep(35) Beep (450, 45) EndFunc Func InstellingenMenu() $GUILettertype = "Verdana" $FormINIaanpassen = GUICreate($Versie & " - Instellingen", 387, 296, 195, 124) $MenuItemBestand = GUICtrlCreateMenu("&Bestand") $Menu_Afsluiten = GUICtrlCreateMenuItem("A&fsluiten instellingen", $MenuItemBestand) $FormINIaanpassencontext = GUICtrlCreateContextMenu() $MenuInformatie = GUICtrlCreateMenuItem("Meer informatie...", $FormINIaanpassencontext) GUISetIcon($Icoon) GUISetFont(8.5, 400, 0, $GUILettertype) $BoxGeluid = GUICtrlCreateCheckbox("BoxGeluid", 355, 24, 15, 15) If IniRead("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "0") = "1" Then GUICtrlSetState($BoxGeluid, $GUI_CHECKED) GUICtrlSetCursor(-1, 0) $AantalBestanden = IniRead("ElmoReader.ini", "Instellingen", "AantalBestanden", "50") $InputDrempelwaarde = GUICtrlCreateInput($AantalBestanden, 320, 53, 50, 21, BitOR($ES_NUMBER, $ES_RIGHT)) $OpNeerAantal = GUICtrlCreateUpdown($InputDrempelwaarde) GUICtrlSetLimit(-1, 200, 1) GUICtrlSetCursor(-1, 0) $Wachttijd = IniRead("ElmoReader.ini", "Instellingen", "MinutenWachttijd", "1") $InputMinuten = GUICtrlCreateInput($Wachttijd, 330, 86, 40, 21, BitOR($ES_NUMBER, $ES_RIGHT)) $OpNeerMinuten = GUICtrlCreateUpdown($InputMinuten) GUICtrlSetLimit(-1, 60, 1) GUICtrlSetCursor(-1, 0) $InputMap1 = GUICtrlCreateInput($MapSel1, 70, 120, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor(-1, 5) $ButtonMap1 = GUICtrlCreateButton("...", 351, 121, 20, 20) $InputMap2 = GUICtrlCreateInput($MapSel2, 70, 146, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor(-1, 5) $ButtonMap2 = GUICtrlCreateButton("...", 351, 147, 20, 20) $InputMap3 = GUICtrlCreateInput($MapSel3, 70, 172, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor(-1, 5) $ButtonMap3 = GUICtrlCreateButton("...", 351, 173, 20, 20) $InputMap4 = GUICtrlCreateInput($MapSel4, 70, 198, 280, 21, BitOR($ES_AUTOHSCROLL, $ES_OEMCONVERT)) GUICtrlSetCursor(-1, 5) $ButtonMap4 = GUICtrlCreateButton("...", 351, 199, 20, 20) $ButtonAfsluiten = GUICtrlCreateButton("OK", 290, 232, 60, 25, 0) $LabelGeluid = GUICtrlCreateLabel("Geluid in- of uitschakelen bij een alarmering:", 24, 26, 263, 17) GUICtrlSetFont(-1, 8.5, 400, 2, $GUILettertype) $LabelDrempelwaarde = GUICtrlCreateLabel("Bij hoeveel aangetroffen bestanden alarmeren:", 24, 56, 276, 17) GUICtrlSetFont(-1, 8.5, 400, 2, $GUILettertype) $LabelWachttijd = GUICtrlCreateLabel("Wachttijd tussen de controles, in minuten:", 24, 90, 245, 17) GUICtrlSetFont(-1, 8.5, 400, 2, $GUILettertype) $LabelMap = GUICtrlCreateLabel("Map 1:", 24, 123, 43, 17) GUICtrlSetFont(-1, 8.5, 400, 2, $GUILettertype) $LabelMap2 = GUICtrlCreateLabel("Map 2:", 24, 149, 43, 17) GUICtrlSetFont(-1, 8.5, 400, 2, $GUILettertype) $LabelMap3 = GUICtrlCreateLabel("Map 3:", 24, 175, 43, 17) GUICtrlSetFont(-1, 8.5, 400, 2, $GUILettertype) $LabelMap4 = GUICtrlCreateLabel("Map 4:", 24, 201, 43, 17) GUICtrlSetFont(-1, 8.5, 400, 2, $GUILettertype) $GroupBox = GUICtrlCreateGroup(" Instellingen ", 5, 4, 377, 265, $WS_CLIPSIBLINGS) GUICtrlSetFont(-1, 8.5, 800, 2, $GUILettertype) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 2 $GUIBericht = GUIGetMsg() Select Case $GUIBericht = $GUI_EVENT_CLOSE Or $GUIBericht = $ButtonAfsluiten Or $GUIBericht = $Menu_Afsluiten ExitLoop Case $GUIBericht = $MenuInformatie MsgBox(64, "Informatie", "In dit venster kunnen diverse opties worden ingesteld," & @LF _ & "zoals de locatie waar bestanden moeten worden geteld door ElmoReader," & @LF _ & "of het waarschuwingsgeluid moet worden ingeschakeld of niet," & @LF _ & "wat de drempelwaarde is alvorens ElmoReader gaat alarmeren en" & @LF _ & "hoeveel tijd er tussen de controle pogingen in moet zitten.") Case $GUIBericht = $ButtonMap1 $MapSel1 = FileSelectFolder("Selecteer te controleren map 1:", "", 7) GUICtrlSetData($InputMap1, $MapSel1) $Map1Lezen = GUICtrlRead($InputMap1) IniWrite("ElmoReader.ini", "Instellingen", "Map1", '"' & $Map1Lezen & '"') Case $GUIBericht = $ButtonMap2 $MapSel2 = FileSelectFolder("Selecteer te controleren map 2:", "", 7) GUICtrlSetData($InputMap2, $MapSel2) $Map2Lezen = GUICtrlRead($InputMap2) IniWrite("ElmoReader.ini", "Instellingen", "Map2", '"' & $Map2Lezen & '"') Case $GUIBericht = $ButtonMap3 $MapSel3 = FileSelectFolder("Selecteer te controleren map 3:", "", 7) GUICtrlSetData($InputMap3, $MapSel3) $Map3Lezen = GUICtrlRead($InputMap3) IniWrite("ElmoReader.ini", "Instellingen", "Map3", '"' & $Map3Lezen & '"') Case $GUIBericht = $ButtonMap4 $MapSel4 = FileSelectFolder("Selecteer te controleren map 4:", "", 7) GUICtrlSetData($InputMap4, $MapSel4) $Map4Lezen = GUICtrlRead($InputMap4) IniWrite("ElmoReader.ini", "Instellingen", "Map4", '"' & $Map4Lezen & '"') Case $GUIBericht = $InputDrempelwaarde $InputDrempelwaardeLezen = GUICtrlRead($InputDrempelwaarde) IniWrite("ElmoReader.ini", "Instellingen", "AantalBestanden", $InputDrempelwaardeLezen) Case $GUIBericht = $InputMinuten $InputMinutenLezen = GUICtrlRead($InputMinuten) IniWrite("ElmoReader.ini", "Instellingen", "MinutenWachttijd", $InputMinutenLezen) Case $GUIBericht = $BoxGeluid If GUICtrlRead($GUIBericht) = $GUI_CHECKED Then IniWrite("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "1") Else IniWrite("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "0") EndIf EndSelect WEnd GUIDelete() EndFunc ;==>InstellingenMenu Func Einde() FileDelete($LockBestand) Sleep(500) Exit EndFuncThe only things that I am noticing, are:Sometimes the script jumps very fast through the folders it should search. Then I will get a series of sounds, if this is enabled (function Waarschuwingsgeluid()) very fast repeating each other. I think the script comes into a loop and disrespects the sleep time which is given;Changing e.g. the sound setting (right click on the script, choose 'Instellingen aanpassen...', remove the checkmark from 'Geluid in- of uitschakelen bij een alarmering' does not apply immediately after pressing OK. The script needs to be shut down and restarted in order to use this new setting.I hope I am explaining clearly. Would someone please be interested in giving me some more advice, since I do not see were the problem is located, I am really not a talented scripter, at all... Regards,Sam. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 16, 2010 Developers Share Posted November 16, 2010 Does updating these lines fix the 2 issues? Case $GUIBericht = $InputMinuten $InputMinutenLezen = GUICtrlRead($InputMinuten) IniWrite("ElmoReader.ini", "Instellingen", "MinutenWachttijd", $InputMinutenLezen) $Wachttijd = Number($InputMinutenLezen) * 60000 ; Omzetten milliseconde naar minuten = vermenigvuldigen met 60.000 Case $GUIBericht = $BoxGeluid If GUICtrlRead($GUIBericht) = $GUI_CHECKED Then IniWrite("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "1") $Geluid = 1 Else IniWrite("ElmoReader.ini", "Instellingen", "Waarschuwingsgeluid", "0") $Geluid = 0 EndIf EndSelect 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 More sharing options...
LMTA Posted November 16, 2010 Author Share Posted November 16, 2010 (edited) Hi Jos,Thanks for your code;I does indeed solve the issue with the sound, it's immediately effective now (I wish I'd thought of this solution myself)... The rest of the script is running fine, for one minute. (If the waittime was set to one minute). After that it will go into the loop without sleeps again. I did not multiply the $InputMinutenLezen value with 60000 milliseconds, because it was my idea to only put the value in minutes into the INI file and let the script internally deal with the milliseconds to minute calculation.I understand your suggestion with the multiplication; I guess it matters a lot in this case what is the right place to put it into the script, right? Edit: It's only applicable when I have changed the settings via 'Instellingen veranderen'. If I don't change anything, the script runs fine. Edited November 17, 2010 by LMTA Link to comment Share on other sites More sharing options...
Developers Jos Posted November 16, 2010 Developers Share Posted November 16, 2010 I understand you like to have the wachttijd defined in minutes, so you have to convert the read number of minutes to milisecs by converting the read INIn string to number and multiply that by 60000. You hadn't done that in the update menu. I am nit sure how it would run fine the first loop and then fail the next loop since you are using in both call the same func. So how do you thing the var $Wachttijd get changed? Jos 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 More sharing options...
LMTA Posted November 18, 2010 Author Share Posted November 18, 2010 In the region where I declare all the variables, I have commented the line:$Wachttijd = Number($Wachttijdms)*60000 ; Omzetten milliseconde naar minuten = vermenigvuldigen met 60.000 and I changed the INI file value of the waiting time (MinutenWachttijd) to 2000. I also commented Jos' code in the Function InstellingenMenu(), to test without the milliseconds to minute calculation. If I then run the script, I do not notice the issue with the timing anymore when I go to the 'Aanpassen instellingen...' choice from the right click menu. Thus, my conclusion is that when the INI value of (MinutenWachttijd) is set to 1 and the calculation is done into the script to multiply this value with 60000, this is assumably not applicable anymore when the Function 'InstellingenMenu()' has been called. I am going to search further in order to find a resolution and post my findings here. Link to comment Share on other sites More sharing options...
LMTA Posted December 28, 2010 Author Share Posted December 28, 2010 Dear people,I guess I (finally) figured out the problem with the waiting time issue, whenever the settings from within the script were modified. I solved the problem by placing the waiting time variable in function BestandenTellen():Func BestandenTellen() Local $Aantal[5], $Mappen, $Wachttijd = IniRead("ElmoReader.ini", "Instellingen", "MinutenWachttijd", "1"), $Wachttijd = Number($Wachttijdms)*60000 For $x = 1 to 4 $Mappen = DirGetSize($Map[$x], 3) $Aantal[$x] = $Mappen[1] If $Aantal[$x] > $AantalBestanden Then TraySetState(4) If $Geluid=1 Then Waarschuwingsgeluid() TrayTip("Elmo zegt:", "In de map " & $Map[$x] & " zijn" & @LF & $Aantal[$x] & @LF & "bestanden gevonden!", -1, 2) Else TraySetState(8) TrayTip("Leegmaken", "", 0) EndIf Sleep ($Wachttijd) Next EndFuncInstead of placing this value into the GUI section as shown in the previous posts. I know it might not be a real charming solution, but at least the timing value is respected this way in the script. I do, however, still have two questions; maybe someone could help me with this? This logic counts files in one folder of the array, waits the amount of time specified in the Waitingtime variable, then checks the next folder and so on. If one specifies e.g. one minute waitingtime, it could take up to 4 minutes with 4 folders until it is detected that the folder was made empty again. Could I check simultaniously and therefore increase this time? Whenever a person start the script, and the folders specified in the INI file (map1,2,3,3) do not exist, of course an array error is displayed. Could someone advise me how to make a good error handler in this case? What I'd like to do e.g. is that instead of the counting routine (Func BestandenTellen) the GUI with settings is displayed and the user can setup the right folders.Any help is very much appreciated, thanks a lot in forward. Link to comment Share on other sites More sharing options...
MvGulik Posted December 28, 2010 Share Posted December 28, 2010 Sam, Sander, Steve. Presume fast job turnaround over there at LMTA. Don't tell me, other ones got eaten by Microbes. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentaryĀ onĀ Quantum Physics byĀ Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...Ā Link to comment Share on other sites More sharing options...
LMTA Posted December 29, 2010 Author Share Posted December 29, 2010 (edited) People,So far I came up with this routine for 'errorhandling' in case some folder specified in the INI file, does not exist:Func ControleerMappen() Local $BestaatMap[5000] For $x = 1 to 4 $BestaatMap[$x] = DirGetSize($Map[$x], 2) If $BestaatMap[$x] = -1 Then MsgBox(48, "Maplocatie onjuist", "De waarde voor " & $Map[$x] & " in ElmoReader.ini is onjuist;" & @LF & "De map " & $Map[$x] & " bestaat niet." & @LF & "Voer hierna de juiste locatie in.") InstellingenMenu() EndIf Next BestandLezen() EndFuncThe script is now starting with this function instead of Func BestandenTellen().It works as expected. So, question 2 is not relevant anymore. Regards! Edited December 29, 2010 by LMTA Link to comment Share on other sites More sharing options...
LMTA Posted December 30, 2010 Author Share Posted December 30, 2010 (edited) Could someone explain to me as a programming-noob why the variable $Map1 (and all the rest) are not updated when I change their values via the GUI (func InstellingenMenu)? I discovered this because I am trying to present the user this GUI when one of the folder in the array do not exist. This part works, however after updating the script crashes due to the fact that the new values ($Map1 and so on) are not globally updated. As a result in func BestandenTellen the value of $Mappen gets -1 (errorcode for a folder that does not exist), on turn this makes the script crash. Edited January 7, 2011 by LMTA Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now