foggy101 Posted April 18, 2010 Share Posted April 18, 2010 Hey i was wondering how i can get this to work. I need to read a ini file, this is a sample of my ini file. i would like to only read the "0.036" and save it in a variable [CARDS] Ancestor's Chosen (10E)=0.025,0.030,0.036,0.054 Thx a lot for your help Simon Link to comment Share on other sites More sharing options...
GEOSoft Posted April 18, 2010 Share Posted April 18, 2010 $sIni = @ScriptDir & "\somefile.ini" $sVal = StringRegExpReplace(IniRead($sIni, "cards", "Ancestor's Chosen (10E)", ""), "^.+,([\d.]+),.*$", "$1") If @Extended Then MsgBox(0, "Result", $sVal EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
z0mgItsJohn Posted April 18, 2010 Share Posted April 18, 2010 (edited) Here's a example that should give you you're desired result. $Path = @ScriptDir & "\Ini_test.ini"; Path of the INI you want to read. $Read = IniRead ($Path, "CARDS","Ancestor's Chosen (10E)", ""); Read the value in the INI file. $Result = StringSplit ($Read, ","); Split the value we read by ",". If $Result[0] > 0 Then $Result = $Result[3]; If StringSplit () was successfully set $Result to $Result[3] ConsoleWrite ($Result & @CRLF) Hope it helps! =] - John Edited April 18, 2010 by John2010zz Latest Projects :- New & Improved TCP Chat Link to comment Share on other sites More sharing options...
foggy101 Posted April 18, 2010 Author Share Posted April 18, 2010 Here's a example that should give you you're desired result. $Path = @ScriptDir & "\Ini_test.ini"; Path of the INI you want to read. $Read = IniRead ($Path, "CARDS","Ancestor's Chosen (10E)", ""); Read the value in the INI file. $Result = StringSplit ($Read, ","); Split the value we read by ",". If $Result[0] > 0 Then $Result = $Result[3]; If StringSplit () was successfully set $Result to $Result[3] ConsoleWrite ($Result & @CRLF) Hope it helps! =] - John Thx a lot!!! this does exactly what i want!!! awesome!! 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