Reinhardt1julian Posted February 14, 2013 Share Posted February 14, 2013 I have a script like BlahBlah Func a() $GUI1 = GUICTRLCreate(blahblahBlah) $Button1 = GUICtrlCreateButton(blah) While 1 Case $msg = GUIGetMsg() Switch $msg Case $Button 1 _funcB EndSwitch WEnd Endfunc Func _funcB $GUI2 = GUICtrlCreate(1, 1, -1, -1, -1, -1, $GUI1) EndFunc I want gui2 to be child of gui1, that u have to close gui2 before you can get back to gui 1. But it says: $GUI1: possibly used before declaration. And how can i make an If statement in a switch? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 (edited) Reinhardt1julian,I recommend you look at the Managing Multiple GUIs tutorial in the Wiki. M23Edit:And how can i make an If statement in a switch?The same way as anywhere else. Can you be more specific - what are you trying to do and what have you tried that has not worked? Edited February 14, 2013 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 I have a code like Switch $abc Case $button1 if $bcd && $hdf NOT = "" Then blahblah Else MSGbox(0,"ab","abcde") Endif EndSwitch But before the if it says Error: missind EndSwitch Link to comment Share on other sites More sharing options...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 Ok, i got this whole code expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> #include <GUIListBox.au3> #include <File.au3> #include <WindowsConstants.au3> Global $DIR_Data = @MyDocumentsDir & '\Messdienerplan\' Global $FileDir = $DIR_Data & "\Messdiener.ini" Global $INdirs = IniReadSection($FileDir,"Messdiener") Global $OUTdirs = IniReadSectionNames($FileDir) _main() Func _main() $Form2 = GUICreate("Plan Creator", 410, 299, -1, -1, BitOr($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX)) $MenuItem2 = GUICtrlCreateMenu("Datei") $MenuItem4 = GUICtrlCreateMenuItem("Neu", $MenuItem2) $MenuItem3 = GUICtrlCreateMenuItem("Speichern", $MenuItem2) $MenuItem7 = GUICtrlCreateMenuItem("Öffnen", $MenuItem2) $MenuItem8 = GUICtrlCreateMenuItem("Schließen", $MenuItem2) $MenuItem1 = GUICtrlCreateMenu("Termine") $MenuItem6 = GUICtrlCreateMenuItem("Termin hinzufügen", $MenuItem1) $MenuItem5 = GUICtrlCreateMenu("Liste der Messdiener") $MenuItem9 = GUICtrlCreateMenuItem("Anzeigen", $MenuItem5) $MenuItem11 = GUICtrlCreateMenuItem("Exportieren", $MenuItem5) $MenuItem10 = GUICtrlCreateMenuItem("Importieren", $MenuItem5) $mainsize = WinGetClientSize("Plan Creator") $Edit1 = GUICtrlCreateEdit("", 8, 8, $mainsize[0] - 15, $mainsize[1] - 15) GUISetState(@SW_SHOW) GUICtrlSetData(-1, "") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $MenuItem8 Exit Case $MenuItem9 _ShowDatabase() EndSwitch WEnd EndFunc Func _ShowDatabase() $Form1data = GUICreate("Messdiener", 702, 478, -1, -1) ;$listSize = WinGetClientSize("Messdiener") $List1data = GUICtrlCreateListView("Vorname|Nachname", 8, 8, 569, 461, -1, $WS_EX_ACCEPTFILES) $Button2data = GUICtrlCreateButton("Entfernen", 584, 72, 105, 25) $Button1data = GUICtrlCreateButton("Neu", 584, 16, 105, 41) $Button3data = GUICtrlCreateButton("Bearbeiten", 584, 112, 105, 25) $Button4data = GUICtrlCreateButton("Schließen", 584, 432, 105, 33) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE If @error Then MsgBox(4000, "", "FEHLER.") Else For $i = 1 to $INdirs [0][0] GuiCtrlCreateListViewItem($INdirs[$i][1],$List1data) Next EndIf Global $aBackend[100][100] ;100 is just a space holder for 100 values in x and y direction Global $aTmp, $j, $y = 0 For $i = 1 To UBound($INdirs) - 1 $aTmp = StringSplit($INdirs[$i][1], "|", 2) $y = UBound($aTmp) For $j = 0 To UBound($aTmp) - 1 $aBackend[$i - 1][$j] = $aTmp[$j] Next Next ReDim $aBackend[$i - 1][$y] ;resize the array to its real dimension _ArrayDisplay($aBackend) GUIDelete($Form1data) Case $Button4data GUIDelete($Form1data) Case $Button1data _NameHinzufuegen() Case $Button2data Case $Button3data EndSwitch WEnd EndFunc Func _NameHinzufuegen() $Form2name = GUICreate("Hinzufügen", 427, 106, 302, 218, -1, -1, $Form1data) $Label1name = GUICtrlCreateLabel("Vorname:", 19, 16, 62, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Vorname = GUICtrlCreateInput("", 96, 16, 317, 21) $Button1name = GUICtrlCreateButton("OK", 112, 72, 97, 25) $Button2name = GUICtrlCreateButton("Abbrechen", 240, 72, 89, 25) $Label2name = GUICtrlCreateLabel("Nachname:", 18, 42, 73, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Nachname = GUICtrlCreateInput("", 96, 40, 317, 21) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE GUIDelete($Form2name) Case $Button2name GUIDelete($Form2name) Case $Button1name $SVorname = GUICtrlRead($Vorname) $SNachname = GUICtrlRead($Nachname) If $Nachname && $Vorname NOT = "" Then GUICtrlCreateListViewItem($Vorname & "|" & $Nachname, $List1data) GUIDelete($Form2name) Else MsgBox(0,"Fehler","Bitte gebe den vollständigen Namen ein") EndIf EndSwitch WEnd EndFunc The Variables are again in german. For the if statement on the end of the code it wants a endswitch before. And in the same part it says $List1data probably used before declaration. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian,I count at least 3 errors in that short snippet:1. Where have you ever seen "$bcd && $hdf"?2. Same question for "NOT ="?3. The syntax for your If..Else..EndIf structure is wrong - and it is that that is giving yo the "Missing EndSwitch" error. Look at the examples in the Help file to see how you should write it.Fix those and your snippet will run. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 1. & 2. Maybe i'm too much into Java, i want that $bcd And $hdf should Not equal "" (null) 3. Seems like i fixed it Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian, i want that $bcd And $hdf should Not equal "" (null)If $bcd <> "" AND $hdf <> "" Then Now the condition is only True if neither is "". M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 OK, now i have the problem, that my script pauses when the _NameHinzufuegen() Function is done... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian,And how does the script ever leave the While...WEnd loop within that function? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 Oh, is ExitLoop the right command for that? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 14, 2013 Moderators Share Posted February 14, 2013 Reinhardt1julian,What does the Help file tell you about that function? "ExitLoop will break out of a While, Do or For loop"So it would seem that it might well be what you need. I suggest that you start reading the Help file before posting because asking simple questions like that will very soon exhaust the patience of other members. OK? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Reinhardt1julian Posted February 14, 2013 Author Share Posted February 14, 2013 I was unsure because of the While Do for loop. That#s why i asked. But thanks. Link to comment Share on other sites More sharing options...
Garp99HasSpoken Posted February 16, 2013 Share Posted February 16, 2013 I recommend you look at the Managing Multiple GUIs tutorial in the Wiki.This helps explain why I had some problems when calling a Form create directly vs from the main form where closing acted as expected.When is best to use GUIGetMsg() vs setting OnEvent() functions when creating the GUI elements?Is using OnEvent more for OO programming? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 16, 2013 Moderators Share Posted February 16, 2013 Garp99HasSpoken,Why hijack this thread with a completely unrelated question rather than opening a new one? Both GUI modes have their pros and cons and if you search the forum you will find many discussions about which is best (or better) in a given situation. Personally I use MessageLoop for nearly everything and limit OnEvent to the tray menu to get (almost) immediate response. I dislike having to write all the small functions needed for absolutely everything in OnEvent - and the inability to pass parameters directly to these same functions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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