sbrady Posted November 16, 2012 Share Posted November 16, 2012 I copied this code from the help file. It makes a window with 3 tabs on it. I just want to be able to add 1 button that displays a message box so I know it all works. But I cant get it to work. In the middle of all this code is ;sb added so you know what I added that does not work. It tells me: "Func" statement has no matching "EndFunc".: Func Example2() what am I doing wrong that simply adding a button does not work. ---- the code ; big fat GUI #include #include #include #include Example() Func Example() Local $msg GUICreate("DAW3 Scripts") ; will create a dialog box that when displayed is centered GUISetBkColor(0x0CCCCCC) GUISetFont(9, 300) GUICtrlCreateTab(10, 10, 370, 370); for all tabs GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 50, 20) GUICtrlCreateButton("OK0", 20, 50, 50, 20) GUICtrlCreateInput("default", 80, 50, 70, 20) GUICtrlCreateTabItem("tab----1") GUICtrlCreateLabel("label1", 30, 80, 50, 20) GUICtrlCreateCombo("", 20, 50, 60, 120) GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon GUICtrlCreateButton("OK1", 80, 50, 50, 20) GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateLabel("label2", 30, 80, 50, 20) GUICtrlCreateButton("OK2", 140, 50, 50) ;#cs ;sb added Example2() Func Example2() Local $Button_1, $msg Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("OK2sb", 140, 30, 50,30, $BS_LEFT) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ;BUTTON 1 clicked Case $msg = $Button_1 MsgBox(8192, "Test", "you pushed button 1", 5) ;Next EndSelect WEnd EndFunc ;end sb added ;#ce GUICtrlCreateTabItem("") ; end tabitem definition ;GUICtrlCreateLabel("label3", 20, 130, 50, 20); on main GUI GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
water Posted November 16, 2012 Share Posted November 16, 2012 There is no EndFunc for function Example. You can't have a function within a function. Could you please remove all empty lines from your code and add [autoit][/autoit] tags to make the code more readable? Thanks! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
WalterCarreiro Posted November 16, 2012 Share Posted November 16, 2012 Here's the correct code: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $msg GUICreate("DAW3 Scripts") ; will create a dialog box that when displayed is centered GUISetBkColor(0x0CCCCCC) GUISetFont(9, 300) GUICtrlCreateTab(10, 10, 370, 370); for all tabs GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 50, 20) GUICtrlCreateButton("OK0", 20, 50, 50, 20) GUICtrlCreateInput("default", 80, 50, 70, 20) GUICtrlCreateTabItem("tab----1") GUICtrlCreateLabel("label1", 30, 80, 50, 20) GUICtrlCreateCombo("", 20, 50, 60, 120) GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon GUICtrlCreateButton("OK1", 80, 50, 50, 20) GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateLabel("label2", 30, 80, 50, 20) GUICtrlCreateButton("OK2", 140, 50, 50) GUICtrlCreateTabItem("") ; end tabitem definition ;GUICtrlCreateLabel("label3", 20, 130, 50, 20); on main GUI GUISetState() Local $Button_1, $msg Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("OK2sb", 140, 30, 50,30, $BS_LEFT) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 MsgBox(8192, "Test", "you pushed button 1", 5) EndSelect WEnd EndFunc Link to comment Share on other sites More sharing options...
sbrady Posted November 16, 2012 Author Share Posted November 16, 2012 how come this GUI forum does not have the menu like the General Forum where you click on the AutoIT icon, paste in your code looks like you typed it right in..........guess I'll have to do it manual. I'll try pasting the function I know works outside the Example() function and see if it adds a button to the tab2 pane. Link to comment Share on other sites More sharing options...
sbrady Posted November 16, 2012 Author Share Posted November 16, 2012 walter....walter.....walter.......thank you so much for the code. I so appreciate it. You are thee 1st person to so easily and willing gave me the code I needed to accomplish my goal. I cannot thank you enough. I will study this and will learn where I went wrong and write better code faster. Thank you thank you thank you. I am a newbie trying to learn and this will help me a lot. shawn Link to comment Share on other sites More sharing options...
water Posted November 16, 2012 Share Posted November 16, 2012 That was quite easy. I pasted your code to SciTE and when I wanted to make it more readable by running Tidy (Ctrl+t) I got the following error messages: ;### Tidy Error -> func Not closed before "Func" statement. ;### Tidy Error -> "func" cannot be inside any IF/Do/While/For/Case/Func statement. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
sbrady Posted November 16, 2012 Author Share Posted November 16, 2012 walter, the buttons show up on all tabs, how do I get my "SB BUTTONS" to only show up on a specific tab. Link to comment Share on other sites More sharing options...
CoolDude69 Posted November 16, 2012 Share Posted November 16, 2012 You need to place the commands for the buttons in the each tab field. Once again here's the entire code; expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Local $Button_1, $msg Example() Func Example() GUICreate("DAW3 Scripts") ; will create a dialog box that when displayed is centered GUISetBkColor(0x0CCCCCC) GUISetFont(9, 300) GUICtrlCreateTabItem("") ; end tabitem definition GUICtrlCreateTab(10, 10, 370, 370); for all tabs GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 50, 20) GUICtrlCreateButton("OK0", 20, 50, 50, 20) GUICtrlCreateInput("default", 80, 50, 70, 20) $Button_0 = GUICtrlCreateButton("OK_Tab0", 250, 30, 80,30, $BS_LEFT) GUICtrlCreateTabItem("tab----1") GUICtrlCreateLabel("label1", 30, 80, 50, 20) GUICtrlCreateCombo("", 20, 50, 60, 120) GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon GUICtrlCreateButton("OK1", 80, 50, 50, 20) $Button_1 = GUICtrlCreateButton("OK_Tab1", 250, 30, 80,30, $BS_LEFT) GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateLabel("label2", 30, 80, 50, 20) GUICtrlCreateButton("OK2", 140, 50, 50) $Button_2 = GUICtrlCreateButton("OK_Tab2", 250, 30, 80,30, $BS_LEFT) GUISetState(@SW_SHOW) Opt("GUICoordMode", 2) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 MsgBox(8192, "Test", "you pushed button 1", 5) EndSelect WEnd EndFunc Link to comment Share on other sites More sharing options...
WalterCarreiro Posted November 16, 2012 Share Posted November 16, 2012 Hope this helps, it works the way you wanted expandcollapse popup#include #include Local $Button_1, $msg Example() Func Example() GUICreate("DAW3 Scripts") ; will create a dialog box that when displayed is centered GUISetBkColor(0x0CCCCCC) GUISetFont(9, 300) GUICtrlCreateTabItem("") ; end tabitem definition GUICtrlCreateTab(10, 10, 370, 370); for all tabs GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 50, 20) GUICtrlCreateButton("OK0", 20, 50, 50, 20) GUICtrlCreateInput("default", 80, 50, 70, 20) $Button_0 = GUICtrlCreateButton("OK_Tab0", 250, 30, 80,30, $BS_LEFT) GUICtrlCreateTabItem("tab----1") GUICtrlCreateLabel("label1", 30, 80, 50, 20) GUICtrlCreateCombo("", 20, 50, 60, 120) GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon GUICtrlCreateButton("OK1", 80, 50, 50, 20) $Button_1 = GUICtrlCreateButton("OK_Tab1", 250, 30, 80,30, $BS_LEFT) GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateLabel("label2", 30, 80, 50, 20) GUICtrlCreateButton("OK2", 140, 50, 50) $Button_2 = GUICtrlCreateButton("OK_Tab2", 250, 30, 80,30, $BS_LEFT) GUISetState(@SW_SHOW) Opt("GUICoordMode", 2) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_0 MsgBox(8192, "Test", "you pushed " & GUICtrlRead($msg), 5) Case $msg = $Button_1 MsgBox(8192, "Test", "you pushed " & GUICtrlRead($msg), 5) Case $msg = $Button_2 MsgBox(8192, "Test", "you pushed " & GUICtrlRead($msg), 5) EndSelect WEnd EndFunc JScript 1 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