bcording Posted March 22, 2004 Share Posted March 22, 2004 The first function will fill the passed array with all the section names of the given INI file. The second function will fill the passed array with all the entries of the given section of the given INI file. Both set @Error to 1 if they succeed. expandcollapse popupFunc GetSections(Byref $DataArray, $INIFile) Local $File, $Line Local $Sections $File = FileOpen($INIFile,0) If $File = -1 Then Return While 1 $Line = FileReadLine($File) If @error = -1 Then ExitLoop $Line = StringStripWS($Line,3) If StringLeft($Line,1) = "[" And StringRight($Line,1) = "]" then $Line = StringMid($Line,2,StringLen($Line)-2) $Sections = $Sections & $Line & @LF EndIF Wend FileClose($File) If StringLen($Sections) = 0 Then Return $DataArray = StringSplit(StringTrimRight($Sections,1),@LF) SetError(1) EndFunc Func GetSectionEntries(Byref $DataArray, $Section, $INIFile) Local $File, $Line Local $Entries $File = FileOpen($INIFile,0) If $File = -1 Then Return While 1 $Line = FileReadLine($File) If @error = -1 Then ExitLoop $Line = StringStripWS($Line,3) If $Line = "[" & $Section & "]" then While 1 $Line = FileReadLine($File) If @error = -1 Then ExitLoop $Line = StringStripWS($Line,3) If StringLeft($Line,1) = "[" then ExitLoop(2) If StringLeft($Line,1) <> ";" And StringLen($Line) <> 0 then $Entries = $Entries & $Line & @LF EndIF Wend EndIF Wend FileClose($File) If StringLen($Entries) = 0 Then Return $DataArray = StringSplit(StringTrimRight($Entries,1),@LF) SetError(1) EndFunc Link to comment Share on other sites More sharing options...
Nutster Posted April 11, 2004 Share Posted April 11, 2004 Shouldn't they set @Error to 1 if they fail? David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
ezzetabi Posted April 14, 2004 Share Posted April 14, 2004 it seens that Bcoding like writing If @error Then Link to comment Share on other sites More sharing options...
bcording Posted April 14, 2004 Author Share Posted April 14, 2004 That bastard! 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