hot202 Posted April 9, 2010 Share Posted April 9, 2010 (edited) hi i need a lil help im sure its simple i have this switch case i want it to be able to check the ini file 1st then if its not in there use the case else i know im doing it wrong i just cant work it out. I wont know the case number thats why i added the iniread cos if i forget to add it to the script i can alwasy add it to the ini later how can i make it so that the case reads the ini "key" ? Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Case Else $Colour = IniRead("\Codes.ini", "L", StringRight(GUICtrlRead($CodeInput), 5), "") Case Else $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) Edited April 9, 2010 by hot202 Link to comment Share on other sites More sharing options...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 $var = IniReadSection("E:\Codes.ini", "L") Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Case $var[1][0] = StringRight(GUICtrlRead($PaintCodeInput), 5) $Colour = IniRead("\Codes.ini", "L", StringRight(GUICtrlRead($PaintCodeInput), 5), "") Case Else $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) that works but how would i get it to work if i have more "Keys" in my ini? How do i look at all the keys? Link to comment Share on other sites More sharing options...
JohnOne Posted April 9, 2010 Share Posted April 9, 2010 $var = IniReadSection("E:\Codes.ini", "L") Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Case $var[1][0] = StringRight(GUICtrlRead($PaintCodeInput), 5) $Colour = IniRead("\Codes.ini", "L", StringRight(GUICtrlRead($PaintCodeInput), 5), "") Case Else $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) that works but how would i get it to work if i have more "Keys" in my ini? How do i look at all the keys? Something about your code dose not look quite right, for example Switch or select missing ans it seems you are using both formats in the same block. First it looks like you are using switch, and half way through it seems as though you are using select. Im not certain you can/or its wise to do 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...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 i am only using switch i just didnt copy it all i just posted the bit thats needed as there is heaps and heaps of cases Link to comment Share on other sites More sharing options...
JohnOne Posted April 9, 2010 Share Posted April 9, 2010 This line suggests you are using select Case $var[1][0] = StringRight(GUICtrlRead($PaintCodeInput), 5) 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...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 I put that there cos thats what i need the help on. Link to comment Share on other sites More sharing options...
JohnOne Posted April 9, 2010 Share Posted April 9, 2010 Its very confusing trying to figure out what is wrong if you just pick and choose lines of code from around your script willy nilly and put them together. You should post in the same code box script that belongs together and another code box for parts that dont. Im not picking, this will get you help quicker than fannying around trying to decipher what you post. 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...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 Its not bits of code willy nilly whats the bit i have in my Switch case im not going to post it all cos it is heaps of lines in my switch. the code works how it is i just needed help to get it to work to search all the "keys" in the ini not just the 1st "key" Thats why i need help with the Case $var[1][0] = StringRight(GUICtrlRead($PaintCodeInput), 5) $Colour = IniRead("\Codes.ini", "L", StringRight(GUICtrlRead($PaintCodeInput), 5), "") part as its only getting the 1st key and dosnt search the other ones Link to comment Share on other sites More sharing options...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 is that better? there it has a switch and a endswitch $var = IniReadSection("E:\Codes.ini", "L") Switch StringRight(GUICtrlRead($CodeInput), 5) Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Case $var[1][0] = StringRight(GUICtrlRead($CodeInput), 5) $Colour = IniRead("E:\Codes.ini", "L", StringRight(GUICtrlRead($CodeInput), 5), "") Case Else $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) EndSwitch Link to comment Share on other sites More sharing options...
JohnOne Posted April 9, 2010 Share Posted April 9, 2010 Ok I'm just not understanding you correctly of you dont see the difference between Switch and select. Or I could be totally wrong myself. Either way, see if this makes sense to you. Its possibly what you need. $var = IniReadSection("E:\Codes.ini", "L") Switch $var[1][1] Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Select Case $var[1][0] = StringRight(GUICtrlRead($PaintCodeInput), 5) $Colour = IniRead("\Codes.ini", "L", StringRight(GUICtrlRead($PaintCodeInput), 5), "") Case $var[1][0] = ;Whatever EndSelect Case Else $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) EndSwitch 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...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 (edited) No i need it in the same Switch case cos in the input i type the codes it seaches the cases for them if there not in the cases it will look in the ini if its not in the ini it will use the case else and display the Unknown code. I have it in the right spot i just need ti to be able to search the ini for all the "keys" its only looking at the 1st "key" thats what $var[1][0] is doing is getting the 1st "key" i need it to be able to look at all the "keys" from the ini under the ini section. Edited April 9, 2010 by hot202 Link to comment Share on other sites More sharing options...
JohnOne Posted April 9, 2010 Share Posted April 9, 2010 $var = IniReadSection("E:\Codes.ini", "L") Switch StringRight(GUICtrlRead($CodeInput), 5) Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Case Else If $var[1][0] = StringRight(GUICtrlRead($CodeInput), 5) Then $Colour = IniRead("E:\Codes.ini", "L", StringRight(GUICtrlRead($CodeInput), 5), "") Else $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) EndIf EndSwitch 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...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 but that still gets the 1st "key" i need it to search all of the keys. Link to comment Share on other sites More sharing options...
JohnOne Posted April 9, 2010 Share Posted April 9, 2010 Try $var = IniReadSection("E:\Codes.ini", "L") Switch StringRight(GUICtrlRead($CodeInput), 5) Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Case Else For $i = 1 To UBound($var) - 1 If $var[$i][0] = StringRight(GUICtrlRead($CodeInput), 5) Then $Colour = IniRead("E:\Codes.ini", "L", StringRight(GUICtrlRead($CodeInput), 5), "") Else $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) EndIf Next EndSwitch 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...
z0mgItsJohn Posted April 9, 2010 Share Posted April 9, 2010 (edited) Something like this, maybe? $var = IniReadSection("E:\Codes.ini", "L") Global $found = 0 Switch StringRight(GUICtrlRead($CodeInput), 5) Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Case Else For $a = 1 To $var[0][0] If $var[$a][0] = StringRight(GUICtrlRead($CodeInput), 5) Then $Colour = IniRead("E:\Codes.ini", "L", StringRight(GUICtrlRead($CodeInput), 5), "") $found = 1 EndIf Next If $found = 0 Then $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) EndIf EndSwitch Hope this helps! - John Edit : I guess JohnOne and me posted at the same time, but JohnOne's code will show the $ErrorPic if a match is not found before it finishes checking. Edited April 9, 2010 by John2010zz Latest Projects :- New & Improved TCP Chat Link to comment Share on other sites More sharing options...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 Thanks John2010zz your way kind of works there is just one problem. when i type in a code that is in the ini it works but if i type in a unknown code after i type in a code that is in the ini the program just crashes and says this E:\CodesV1.0.au3 (496) : ==> Variable used without being declared.: GUICtrlSetData($CodeInput, $Colour) GUICtrlSetData($CodeInput, ^ ERROR Link to comment Share on other sites More sharing options...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 (edited) it seemed to work if i added $found = 0 at the end dont know if thats the best way to fix it? Just found another prob If there is no ini Section L it will crash how would i stop that? $var = IniReadSection("E:\Codes.ini", "L") Global $found = 0 Switch StringRight(GUICtrlRead($CodeInput), 5) Case "13130" $Colour = "Taormina Aqua Met" Case "13135" $Colour = "The Lone O'Ranger" Case Else For $a = 1 To $var[0][0] If $var[$a][0] = StringRight(GUICtrlRead($CodeInput), 5) Then $Colour = IniRead("E:\Codes.ini", "L", StringRight(GUICtrlRead($CodeInput), 5), "") $found = 1 EndIf Next If $found = 0 Then $Colour = "Unknown Code" GUICtrlSetState($ErrorPic, $GUI_SHOW) EndIf $found = 0 EndSwitch Edited April 9, 2010 by hot202 Link to comment Share on other sites More sharing options...
JohnOne Posted April 9, 2010 Share Posted April 9, 2010 IniReadSectionNames() to verify it exists. 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...
hot202 Posted April 9, 2010 Author Share Posted April 9, 2010 Thats what i thought i think i have it working now i will keep testing it to see if i have any other problems Thanks heaps guys for the help 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