Sign in to follow this  
Followers 0
gcue

determine bios setting

6 posts in this topic

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 =)

#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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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"

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

I'm not sure how much better this one is, but at least it matches what you're looking for.

#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 Gude
How 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

Share this post


Link to post
Share on other sites

awesome thanks guys =)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0