MacScript Posted July 18, 2014 Posted July 18, 2014 I am going thru my code and cleaning it up. I have a couple or controls that are created by use of a for loop. So the control will be something like $btncolor[0], $btncolor[1], etc.. Currently I have inside my message loop case statement a separate case statement for each of the 7 sets of buttons. As can been seen below : For $i = 0 To $filterCount - 1 GUICtrlCreateLabel("Filter #" & $i + 1 & ": ", 3, 26 +($rowsize * $i), 50, 21, $SS_RIGHT) GUICtrlSetResizing(-1, 802) $btnClr[$i] = GUICtrlCreateButton("Color", 55, 24 +($rowsize * $i), 30, 21) GUICtrlSetResizing(-1, 802) $inpClr[$i] = GUICtrlCreateInput("0x00FF00", 89, 24 +($rowsize * $i), 64, 21) GUICtrlSetResizing(-1, 802) Next While 1 Global $iMsg = GUIGetMsg() Switch $iMsg Case $btnClr[0] SetFontColor ($btnClr[0], $inpClr[0]) Case $btnClr[1] SetFontColor ($btnClr[1], $inpClr[1]) Case $btnClr[2] SetFontColor ($btnClr[2], $inpClr[2]) Case $btnClr[3] SetFontColor ($btnClr[3], $inpClr[3]) Case $btnClr[4] SetFontColor ($btnClr[4], $inpClr[4]) Case $btnClr[5] SetFontColor ($btnClr[5], $inpClr[5]) Case $btnClr[6] SetFontColor ($btnClr[6], $inpClr[6]) EndSwitch WEnd What I thought I could do was the follow: Case $btnClr[0] to $btnClr[$filterCount - 1] Global $iIndex = $iMsg - $btnClr[0] SetFontColor ($btnClr[$iIndex], $inpClr[$iIndex]) But it is getting the following error on the SetFontColor command-> array variable has incorrect number of subscripts or subscript dimension range exceeded. I have done this before with a different set of code, so not sure what I am doing incorrectly. Thanks in advance for all help provided.
careca Posted July 18, 2014 Posted July 18, 2014 Hello, what im gonna ask you, is that, if you want me to test your example, make it so i copy/paste and run, make it so that when i run it, it gives the error, don't make us declare the variables and put in the missing pieces for the script to work. Best regards Reveal hidden contents Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
Solution MacScript Posted July 18, 2014 Author Solution Posted July 18, 2014 Careca - Normally I do post functional scripts. Brain was not thinking when I posted and I am sorry. As for a solution to the issue I came up with one. The problem why it was not working was cause in the for loop that makes the controls I am making multiple controls for each loop and my $iIndex was not taking that into account. So the solution I just figured out is below -> Case $btnClr[0], $btnClr[1], $btnClr[2], $btnClr[3], $btnClr[4], $btnClr[5], $btnClr[6] Global $iIndex = ($iMsg - $btnClr[0]) / 7 SetFontColor ($btnClr[$iIndex], $inpClr[$iIndex]) Case $btnFont[0], $btnFont[1], $btnFont[2], $btnFont[3], $btnFont[4], $btnFont[5], $btnFont[6] Global $iIndex = ($iMsg - $btnFont[0]) / 7 SetFontTypeSize ($inpFont[$iIndex], $inpFtSize[$iIndex]) To create the proper index I had to take divide the difference between the ($imsg - the Base control) by 7 which is the number of individual controls being made per loop. Thanks for the help.
careca Posted July 18, 2014 Posted July 18, 2014 Awesome! Glad you sorted it out. Reveal hidden contents Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
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