pl123 Posted November 20, 2010 Posted November 20, 2010 (edited) I borrowed the following script to add to my GUI from this link, So I changed it around a bit, and added into the GUI. However, whenever I run it, it gives the me error'Next' statement with no matching 'For' statementHowever, there is a For statement before the Next statement...What's wrong? Thanks! Also, I've marked the errors in the code.expandcollapse popupFunc _HighestRes () Local $tDEVMODE = DllStructCreate ('byte[32];dword[10];byte[32];dword[6]') Local $pDEVMODE = DllStructGetPtr ($tDEVMODE) Local $i = 0, $Ret $Res = "" ; popluate resources into buffer While 1 $Ret = DllCall('user32.dll', 'int', 'EnumDisplaySettings', 'ptr', 0, 'dword', $i, 'ptr', $pDEVMODE) If (@error) Or ($Ret[0] = 0) Then ExitLoop EndIf $HighWidth = DllStructGetData ($tDEVMODE, 4, 2) $HHeight = DllStructGetData ($tDEVMODE, 4, 3) $Bits = DllStructGetData ($tDEVMODE, 4, 1) $Res = $Res & $HighWidth & "," & $HighHeight & "," & $Bits & ":" $i += 1 WEnd $arrRes = StringSplit($Res, ":") ; Split string using : as delimiter $ColorDepth = 0 For $i = 1 To 5000 $tmp1 = StringSplit($arrRes[$i], ",") If @error Then ExitLoop If UBound($tmp1) = 4 Then ; check if array has 4 elements (640, 480, 8, null), if so, obtain the highest color depth from the array If Number($tmp1[3]) > $ColorDepth Then $ColorDepth = Number($tmp1[3]) EndIf EndIf Next ; ERROR! $XResHigh = 0 For $i = 1 To 5000 $tmp1 = StringSplit($arrRes[$i], ",") If @error Then ExitLoop If UBound($tmp1) = 4 Then; check if array has 4 elements (640, 480, 8, null), if so, obtain the highest color depth from the array If Number($tmp1[1]) > $XResHigh Then $XResHigh = Number($tmp1[1]) EndIf EndIf Next ; ERROR! $YResHigh = 0 For $i = 1 To 5000 $tmp1 = StringSplit($arrRes[$i], ",") If @error Then ExitLoop If UBound($tmp1) = 4 Then ; check if array has 4 elements (640, 480, 8, null), if so, obtain the highest color depth from the array If Number($tmp1[1]) = $XResHigh Then ; only query array objects that match the X resolution If Number($tmp1[2]) > $YResHigh Then $YResHigh = Number($tmp1[2]) EndIf EndIf EndIf Next ; ERROR! EndFuncI have several tabs in my GUI, and when I run it, the first tab doesn't show anything, until I click on another tab then click on that first tab. I tried using While 1 $GetMsg = GUIGetMsg (0) Switch $GetMsg Case $Tab[0] GUICtrlSetState ($CTRLID, $GUI_SHOW) EndSwitch WEndbut all that does is make it flash a lot. How do I fix that?Thanks for your help! =) Edited November 20, 2010 by pl123
BrewManNH Posted November 20, 2010 Posted November 20, 2010 You have an error in your If...Endif command loop Yours: For $i = 1 To 5000 $tmp1 = StringSplit($arrRes[$i], ",") If @error Then ExitLoop If UBound($tmp1) = 4 Then ; check if array has 4 elements (640, 480, 8, null), if so, obtain the highest color depth from the array If Number($tmp1[1]) = $XResHigh Then ; only query array objects that match the X resolution If Number($tmp1[2]) > $YResHigh Then $YResHigh = Number($tmp1[2]) EndIf EndIf EndIf Next ; ERROR! What it should look like: For $i = 1 To 5000 $tmp1 = StringSplit($arrRes[$i], ",") If @error Then = ExitLoop ; <<<<<<<<<<<<<<<<<<<<<<< error was here If UBound($tmp1) = 4 Then ; check if array has 4 elements (640, 480, 8, null), if so, obtain the highest color depth from the array If Number($tmp1[1]) = $XResHigh Then ; only query array objects that match the X resolution If Number($tmp1[2]) > $YResHigh Then $YResHigh = Number($tmp1[2]) EndIf EndIf EndIf Next ; ERROR! Another way, depending on what you're looking to do with them If @error Then ExitLoop Endif 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
pl123 Posted November 20, 2010 Author Posted November 20, 2010 (edited) Thanks for your reply, BrewManNH! I got it fixed. =) Now, can anyone help me with my second problem? Thanks! Edited November 20, 2010 by pl123
martin Posted November 20, 2010 Posted November 20, 2010 Thanks for your reply, BrewManNH! I got it fixed. =) Now, can anyone help me with my second problem? Thanks!What is your second problem? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
pl123 Posted November 20, 2010 Author Posted November 20, 2010 The second problem is in the first post, but my problem is making the first tab show when I run the GUI. When I use $GUI_SHOW, it the tab flash over and over really fast.
martin Posted November 22, 2010 Posted November 22, 2010 The second problem is in the first post, but my problem is making the first tab show when I run the GUI. When I use $GUI_SHOW, it the tab flash over and over really fast.I would need to see your code to see how you create the tab and to reproduce the problem, otherwise I can't know what's wrong. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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