gcue Posted April 1, 2013 Share Posted April 1, 2013 hello. I am trying to determine the selected bios setting for SATA Emulation. The selected option is determined by a *. _arraysearch does not seem to support searching for that character. So I loop through each value to see which one has the asteris. This seems pretty inefficient - I'm sure there's a better way of doing this. Thanks in advance =) expandcollapse popup#include <array.au3> $msg_normal = 0 $string = "SATA Emulation: *IDE,--,RAID,AHCI" $data = StringRegExp($string, "SATA Emulation: ([\S]*)", 3) Debug($data) $values = StringSplit($data[0], ",") If @error Then EndIf Debug($values) $index = _ArraySearch($values, "'*'") If @error Then EndIf Debug($index, @error) for $x = 1 to UBound($values)-1 if StringInStr($values[$x], "*") <> 0 Then $selected_option = StringReplace($values[$x], "*", "") EndIf Next Debug($selected_option) Func Debug($variable1 = "", $variable2 = "", $variable3 = "") If IsArray($variable1) Then _ArrayDisplay($variable1) Else If $variable2 <> "" Then $variable1 &= @CRLF & $variable2 EndIf If $variable3 <> "" Then $variable1 &= @CRLF & $variable3 EndIf ClipPut($variable1) MsgBox($msg_normal, "Debug", $variable1) EndIf EndFunc ;==>Debug Link to comment Share on other sites More sharing options...
kylomas Posted April 1, 2013 Share Posted April 1, 2013 gcue, This return protocals preceeded by an asterisk $data = StringRegExp($string, "SATA Emulation: \*(.*?),", 3) _arraysearch matches the entire element only, therefore, this would work $index = _ArraySearch($values, "*IDE") kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
gcue Posted April 1, 2013 Author Share Posted April 1, 2013 gotcha thanks. that stringregexp pattern works if IDE is the one that has the asterisk but not if any of the others do... $string = "SATA Emulation: IDE,--,RAID,*AHCI" Link to comment Share on other sites More sharing options...
kylomas Posted April 1, 2013 Share Posted April 1, 2013 gcue, Yes, my SRE stinks, sorry. I'm sure one of the Klingons will be by shortly to correct this. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
BrewManNH Posted April 1, 2013 Share Posted April 1, 2013 I'm not sure how much better this one is, but at least it matches what you're looking for. expandcollapse popup#include <array.au3> $msg_normal = 0 $string = "SATA Emulation: IDE,--,*RAID,AHCI" ;~ $data = StringRegExp($string, "SATA Emulation: ([\S]*)", 3) $data = StringRegExp($string, "(\*(\b.*|.*))", 3) Debug($data) $values = StringSplit($data[0], ",") If @error Then EndIf Debug($values) $index = _ArraySearch($values, "*", 0, 0, 0, 1) If @error Then EndIf Debug($index, @error) $selected_option = StringReplace($values[$index], "*", "") Debug($selected_option) Func Debug($variable1 = "", $variable2 = "", $variable3 = "") If IsArray($variable1) Then _ArrayDisplay($variable1) Else If $variable2 <> "" Then $variable1 &= @CRLF & $variable2 EndIf If $variable3 <> "" Then $variable1 &= @CRLF & $variable3 EndIf ClipPut($variable1) MsgBox($msg_normal, "Debug", $variable1) EndIf EndFunc ;==>Debug 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...
gcue Posted April 1, 2013 Author Share Posted April 1, 2013 awesome thanks guys =) 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