Jump to content

Questinon about INI files


 Share

Recommended Posts

hello all,

i have a few INI files holding information like this.

file 1

[title01]

........

.......

[title02]

......

......

file 2

[info01]

.......

.......

[info02]

......

......

my question is how can i search throw all these files for sertion bits of information.

so if i want to load all of [title01] and [info01] at the same time to a gui

and then lator load [title88] and [info88].

i have looked in the help file and i cant work it out so if any one knows please help me many thanks.

Link to comment
Share on other sites

  • Moderators

madmorgan,

If you want read a whole section at a time, then IniReadSection is the command to use. You get all of the key=value pairs into an array which you can then search or display as you wish in your GUI. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

http://dundats.mvps.org/help/html/libfunctions/_ArraySearch.htm

Carefuly study the parameters paying particular attention to $iPartial and $iSubItem

Edited by GEOSoft

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

  • Moderators

madmorgan,

IniReadSection will only read the section you specify.

i want to load all of [title01] and [info01]

To read these sections you would do something like this:

$a_title01 = IniReadSection ( "file1", "title01" )
$a_info01 = IniReadSection ( "file2", "info01" )

You will now have 2 arrays holding all of the key-value pairs from those 2 sections. You can use _ArraySearch to look for the specific key or value you want within them. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

It would help even more if you gave us at least one example of the data structure used in the ini files.

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

ok here are two files i have so far.

if titleo1 is clicked then i want the information from info01 to link to it.

Title.ini

[title01]

Borderlands

[title02]

avatar

[title03]

pandorum

Dec.ini

[dec01]

infomation comming soon

[info02]

information comming soon

[info03]

information comming soon

Link to comment
Share on other sites

ok here are two files i have so far.

if titleo1 is clicked then i want the information from info01 to link to it.

Title.ini

[title01]

Borderlands

[title02]

avatar

[title03]

pandorum

Dec.ini

[dec01]

infomation comming soon

[info02]

information comming soon

[info03]

information comming soon

Therein lies the problem with using ini functions. That is not a properly structured Ini file. This could really all be written in a single file or use a single Ini file and a flat text file (as you have now for the Dec.ini file) in which case prudent use of StringRegExp() will work nicely.

For Title.ini

[Titles]

title1=Borderlands

title2=avatar

title3=pandorum

Then you could use IniReadSection($sIni, "titles")

$sIni = "Title.ini"
$aResults = IniReadSection($sIni, "Titles")

Dec.txt

[borderlands]

infomation comming soon

[avatar]

information comming soon

[pandorum]

information comming soon

To bring it all together

$sIni = "Title.ini"
$sText = FileRead("dec.txt")
$aResults = IniReadSection($sIni, "Titles")

$sStr = FileRead($
;; All of the following can be replaced depending on what you want to do with the data.  I'm using a loop to demonstrate it
For $i = 1 To Ubound($aResults) -1
    $sResult = StringRegExpReplace($sText, "(?i)(?s).*\[" & $aResults[$i][1] & "\v+(.*?)(?:\[|\z).*", "$1")
    MsgBox(0, "result", $sResult)
Next

Note: I don't have time to test that RegExReplace but I think it's close and probably works as is

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

any one got any idears?

Please don't bump threads. Sometrimes you just have to wait patiently for a reply. Read my signature in respect to bumping

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

it was one of my own comments i removed.

Did you try creating the files as I suggested and then running the code?

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...