#include #include #include ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GIVEN DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; File names Global Const $File_1 = "Test.txt" Global Const $File_2 = "Test2.txt" Global Const $File_3 = "Test3.txt" ; Attribute names Local Const $Attribute_1 = "Controller" Local Const $Attribute_2 = "Simulator" Local Const $Attribute_3 = "Testing" ; Files attributes Global $File_1_Attr[3] = [$Attribute_1, $Attribute_2, $Attribute_3] Global $File_2_Attr[3] = [$Attribute_3, "", ""] Global $File_3_Attr[3] = ["", $Attribute_1, ""] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GUI FORM EXAMPLE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Form_Main = GUICreate("GUI managing Database", 250, 380) $Group_Attributes = GUICtrlCreateGroup("Attributes", 20, 20, 200, 130) $Checkbox_1 = GUICtrlCreateCheckbox($Attribute_1, 40, 50) $Checkbox_2 = GUICtrlCreateCheckbox($Attribute_2, 40, 80) $Checkbox_3 = GUICtrlCreateCheckbox($Attribute_3, 40, 110) $Group_Files = GUICtrlCreateGroup("Files", 20, 160, 200, 200) $Label_1 = GUICtrlCreateLabel("", 40, 180, 150, 20) $Label_2 = GUICtrlCreateLabel("", 40, 220, 150, 20) $Label_3 = GUICtrlCreateLabel("", 40, 260, 150, 20) GUISetState(@SW_SHOW) ; Files variablies Global $File_1_Content = "" Global $File_2_Content = "" Global $File_3_Content = "" Global $File_1_Access = False Global $File_2_Access = False Global $File_3_Access = False ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PROGRAM BODY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Files content read If Not File_read($File_1) Or Not File_read($File_2) Or Not File_read($File_3) Then Exit EndIf ; Endless loop While 1 ; Checkbox status changed $msg = GUIGetMsg() Switch $msg Case $Checkbox_1, $Checkbox_2, $Checkbox_3 $File_1_Access = False $File_2_Access = False $File_3_Access = False Access($Checkbox_1) Access($Checkbox_2) Access($Checkbox_3) ; Files show If $File_1_Access Then GUICtrlSetData($Label_1, $File_1_Content) Else GUICtrlSetData($Label_1, "") EndIf If $File_2_Access Then GUICtrlSetData($Label_2, $File_2_Content) Else GUICtrlSetData($Label_2, "") EndIf If $File_3_Access Then GUICtrlSetData($Label_3, $File_3_Content) Else GUICtrlSetData($Label_3, "") EndIf Case $GUI_EVENT_CLOSE ; Close GUI ExitLoop EndSwitch WEnd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func File_read($Filename) Local $hFileOpen = FileOpen($Filename, $FO_READ) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file " & $Filename) Return False EndIf Switch $Filename Case $File_1 $File_1_Content = FileRead($hFileOpen) Case $File_2 $File_2_Content = FileRead($hFileOpen) Case $File_3 $File_3_Content = FileRead($hFileOpen) EndSwitch FileClose($hFileOpen) Return True EndFunc ; Func Access($Checkbox) If GUICtrlRead($Checkbox) = $GUI_CHECKED Then For $vElement In $File_1_Attr If $vElement = GUICtrlRead($Checkbox, $GUI_READ_EXTENDED) Then $File_1_Access = True EndIF Next For $vElement In $File_2_Attr If $vElement = GUICtrlRead($Checkbox, $GUI_READ_EXTENDED) Then $File_2_Access = True EndIF Next For $vElement In $File_3_Attr If $vElement = GUICtrlRead($Checkbox, $GUI_READ_EXTENDED) Then $File_3_Access = True EndIF Next EndIF EndFunc