Chimaera Posted November 5, 2010 Share Posted November 5, 2010 Hi all Working on a script and i have a large while > wend and i wondered if there was a maximum amount of case allowed within it? Ive prob got about 100 Case statements in it all for button presses to excute a file or webpage etc Since i added last dew its gone pear shaped giving me undefined function errors If i #cs the last lot all is fine, so i was wondering if i had hit a limit? Ive checked and rechecked and all seems fine on the text side Is it possible to split them into smaller wends maybe? The last time i tried the while =1 on both conflicted, unless im doing it wrong which is very possible If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
JohnOne Posted November 5, 2010 Share Posted November 5, 2010 I'm going to assume you you mean Switch...Case...EndSwitch. There is nothing in the helpfile to indicate a limit. If you are fetting an undefined function error, I would imagine the problem is just that. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 5, 2010 Moderators Share Posted November 5, 2010 Chimaera,Ive prob got about 100 Case statements in itAlthough I do not believe you have hit a limit, I would suggest that you are not coding in the most efficient manner. Perhaps if you posted the script so we could offer a different (and possibly better) way? 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...
Chimaera Posted November 5, 2010 Author Share Posted November 5, 2010 (edited) Ok it goes a bit like this in the gui $install_but_1 = GUICtrlCreateButton("Full Install", 40, 300, 120) then lower down While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _Exit() ;==> Tab 1 Case $install_but_1 _install_but_1() Case $install_but_2 _install_but_2() ;etc etc until Case $install_but_25 _install_but_25() Case $install_but_26 _install_but_26() ; then a few of these Case $tech_but_1 _tech_but_1() Case $tech_but_2 ; and so on till about 100 buttons ;and each one of them has one of these that it represents Func _install_but_1() ;==; Start VLC Install RunWait(@ScriptDir & "\file_includes\install\install_vlc.exe") EndFunc ;==> End VLC Install that should give you the rough idea, the gui has 3 tabs and a lot of buttons Chimaera Edited November 5, 2010 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
BrewManNH Posted November 5, 2010 Share Posted November 5, 2010 You could change all of your buttons into check boxes that have the installs you want to do tied to them. Then all you'd have to do is check off the ones that you wanted to use, scan all of the checked ones into an array, and parse the array one element at a time to find out which to install. Might make it a little easier for the user instead of hitting one button at a time and one install at a time. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 5, 2010 Moderators Share Posted November 5, 2010 Chimaera, BrewManNH has taken the words right out of my mouth! 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...
cageman Posted November 5, 2010 Share Posted November 5, 2010 Other option is to just make some excel code that generates the required code for all cases. Just an idea if you don't want the check boxes. This idea takes you 5 minutes max although its depending on your excel skills. Link to comment Share on other sites More sharing options...
ProgAndy Posted November 5, 2010 Share Posted November 5, 2010 Other option is to just make some excel code that generates the required code for all cases. Just an idea if you don't want the check boxes. This idea takes you 5 minutes max although its depending on your excel skills.What is excel code? Do you mean VBA? Then you could create an AutoIt-Script for the same task, too *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Chimaera Posted November 5, 2010 Author Share Posted November 5, 2010 Ok thats a possibility it might reduce the overall size of the tool as well because the checkboxes take less room. Can you give an example how to tie a install to a checkbox plz? ;==> Tab 1 Case $install_but_1 _install_but_1() ;--; Func _install_but_1() ;==; Start VLC Install RunWait(@ScriptDir & "\file_includes\install\install_vlc.exe") EndFunc ;==> End VLC Install Does the checkbox still use the same function call? #include <GUIConstants.au3> GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered GUICtrlCreateCheckbox ("Antivirus", 10, 10, 120, 20) GUICtrlCreateCheckbox ("Malware", 10, 30, 120, 20) GUISetState () ; will display an dialog box with 1 checkbox ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend found this bit, why does it need the while > wend is it for the detection of which boxes are ticked? Btw ive never used a checkbox or array before Thanks for the answers Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
BrewManNH Posted November 5, 2010 Share Posted November 5, 2010 Here's something I whipped up that should help you in understanding a part of what you can do with check boxes and arrays. The $CBR array isn't really needed because you could directly access the check box state using GUICtrlRead but you could use this as an example and use the $CBR array later in the script to store the state of the check boxes in case something gets changed after clicking the read button. You can see that for yourself by changing the state of one or more of the checked boxes after you have hit the read button and the MsgBox is showing, the Array will keep the state of the checked box regardless of whether it gets changed later or not. Here's the example script. #include <guiconstants.au3> Global $CB[10], $CBR[10] $Main = GUICreate("Test", 300, 300, -1, -1) For $I = 0 To 9 $CB[$I] = GUICtrlCreateCheckbox("Check box " & $I + 1, 10, 20 * $I) Next $Read = GUICtrlCreateButton(" Read ", 200, 50) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $Read _ReadCheckboxes() Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep(20) WEnd Func _ReadCheckBoxes() For $I = 0 To 9 $CBR[$I] = GUICtrlRead($CB[$I]) Next For $I = 0 To 9 If $CBR[$I] = 1 Then MsgBox(64, "Check box " & $I + 1, "Check box #" & $I + 1 & " is checked") Else MsgBox(64, "Check box " & $I + 1, "Check box #" & $I + 1 & " is not checked") EndIf Next EndFunc ;==>_ReadCheckBoxes If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted November 5, 2010 Author Share Posted November 5, 2010 Thanks for trying to help BrewManNH I will go and try and understand but based on what you have written very little of it makes sense i apologise but im not the sharpest tool in the box with code. The reason i was as far as i was was more down to previous questions and help from Melba23 than anything else. I will go and decipher as i can Thanks for taking the trouble to write that piece and thanks for the replys from everyone else Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() 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