myspacee Posted April 21, 2009 Share Posted April 21, 2009 hello, I work on an application with a .ini like this: 1001=a 1002=b 1003=c 1004=d 1005=e 1006=f 1007=g 1008=h 1009=i 2001=l .... 9001=z not many lines (81) but can't use it as normal ini. My user can manipulate text file values but only to optimize script usability. So I want to start script, and : - read '.ini', and insert its value in an array - when user do something var is valorized (eg: 1001) - script take this value, read array, search for 1001 and return letter 'a' to user. Hope to have explained my need thank you all, m. Link to comment Share on other sites More sharing options...
Valuater Posted April 21, 2009 Share Posted April 21, 2009 Maybe... #include <file.au3> Dim $aRecords, $File = @ScriptDir & "Text.ini" If Not _FileReadToArray($File, $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf ; create your user GUI $Find = InputBox("Ini Reader", "Please input a line #") ; for testing ; $aRecords = StringSplit("1001=a,1002=b,1003=c", ",") For $x = 1 To $aRecords[0] If StringInStr($aRecords[$x], $Find) Then MsgBox(-1, 'Record:' & $x, StringRight($aRecords[$x], 1)) ExitLoop EndIf Next 8) Link to comment Share on other sites More sharing options...
Valuater Posted April 21, 2009 Share Posted April 21, 2009 For a user changed ini #include <file.au3> Dim $aRecords, $File = @ScriptDir & "Text.ini" If Not _FileReadToArray($File, $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf ; create your user GUI $Find = InputBox("Ini Reader", "Please input a line #") ; for testing ; $aRecords = StringSplit("1001=a,1002=b,1003=c", ",") For $x = 1 To $aRecords[0] If StringInStr($aRecords[$x], $Find) Then $split = StringSplit($aRecords[$x], "=") MsgBox(-1, 'Record:' & $x, $split[2]) ExitLoop EndIf Next 8) Link to comment Share on other sites More sharing options...
lordicast Posted April 21, 2009 Share Posted April 21, 2009 Problem with that second one valuter seems 4 returns the same value as 1004. [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
Valuater Posted April 21, 2009 Share Posted April 21, 2009 (edited) Problem with that second one valuter seems 4 returns the same value as 1004.There should never be a "4". As I understand it is from 1001 to 9009 ( or similar). The second script is for the text after the equal sign to be changed.8)EDIT:I only created the manipulation as the OP asked, not the GUI or the filtering. My "InputBox" was for example only... thx 8) Edited April 21, 2009 by Valuater Link to comment Share on other sites More sharing options...
lordicast Posted April 21, 2009 Share Posted April 21, 2009 (edited) ooOOooo @ Val I know I know for giggles I added a length measure LOL. EDIT: Wow im bored #include <file.au3> Dim $aRecords, $File = @ScriptDir & "Text.ini" If Not _FileReadToArray($File, $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exitloop EndIf ; create your user GUI $Find = InputBox("Ini Reader", "Please input a line #") ; for testing ; $aRecords = StringSplit("1001=a,1002=b,1003=c", ",") $Len = StringLen($Find) if $Len < 4 Then Exit Else For $x = 1 To $aRecords[0] If StringInStr($aRecords[$x], $Find) Then $split = StringSplit($aRecords[$x], "=") MsgBox(-1, 'Record:' & $x, $split[2]) ExitLoop EndIf EndIf Next Edited April 21, 2009 by lordicast [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
myspacee Posted April 22, 2009 Author Share Posted April 22, 2009 thank you all, i rwead reply only now (in office ) m. 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