Read Ini file in two dimensional array?

J

Joost

Hi,

I've got the following Ini file example

[Company]
Person=Joost Verdaasdonk
Adress=Nieuwe Huizen 115
Postal=4813 TM Breda
Tel=076-567800

What I'm trying to achieve is to call a section by:
Declare Function GetPrivateProfileString
(or something like that)

This Call should fill a two dimensional array (option
Base 1) with all the Keywords (eg; Person) and Entries
(eg; Joost Verdaasdonk) of that Section.

I've achieved that by looping through the keywords and
getting out one entry at a time.
This seams a lot off work and is slowing down the
procedure.

A while a go I saw an API that could retrieve all the
Keywords in a one dimensional Array.
But I cannot find that one. And if there is one, is there
also one that can retrieve all the Entries in a simular
array? (Two one dimenisionals also would be faster but
Two dimenisonal is preffered)

Does anybody has the code to fill lets say the variable:
sAnwer (Variant) with values of the example Ini?

The Array has to feed my bookmarks in the document. (But
that part is covered)

Thank you very much.

Groetjes,
Joost Verdaasdonk
 
J

JB

Joost said:
Hi,

I've got the following Ini file example

[Company]
Person=Joost Verdaasdonk
Adress=Nieuwe Huizen 115
Postal=4813 TM Breda
Tel=076-567800

What I'm trying to achieve is to call a section by:
Declare Function GetPrivateProfileString
(or something like that)

This Call should fill a two dimensional array (option
Base 1) with all the Keywords (eg; Person) and Entries
(eg; Joost Verdaasdonk) of that Section.

I've achieved that by looping through the keywords and
getting out one entry at a time.
This seams a lot off work and is slowing down the
procedure.

A while a go I saw an API that could retrieve all the
Keywords in a one dimensional Array.
But I cannot find that one. And if there is one, is there
also one that can retrieve all the Entries in a simular
array? (Two one dimenisionals also would be faster but
Two dimenisonal is preffered)

Does anybody has the code to fill lets say the variable:
sAnwer (Variant) with values of the example Ini?

The Array has to feed my bookmarks in the document. (But
that part is covered)

Thank you very much.

Groetjes,
Joost Verdaasdonk

Hi Joost,
I think I'm right in saying that as long as you continue with
PrivateProfileString and .ini files (which are slow anyway), your speed
will not be what you want.

You could just open the file for input and do a readline for each of the
lines in the file, loop through the 1 dimensional array you create
looking for your header then do the rest from there.

This however might not be what your looking for as it's extra coding to
scroll the array to find your data then split it up (it's not that bad
really but I don't know your skill level) but I think ity's faster than
..ini files.

HTH

J
 
A

azis

Joost,

Let er wel op dat de .ini file slechts 64K groot kan worden en derhalve bij
veel kontaktpersonen snel deze limiet bereikt. Wij hebben dit opgesliptst in
meerdere inifiles en een verwijzing naar een "master"ini file voor de
bedrijven. Indien interesse in de code svp hier melden.
 
J

Jonathan West

Hi Joost

the following article describes how to use the GetPrivateProfileSection API
call to load an entire section of an INI file.

Using INI Files to Save Application Data - Saving Entire Sections
http://vbnet.mvps.org/code/file/pprofilesections.htm

The code in the article loads an INI file section into a VB6 listbox. You'll
need to adapt it to load it into an array instead.
 
J

Joost

Hai Azis,

Bedankt voor de Tip!
Ik wist dat INI's een begrenzing hadden, maar hoeveel
wist ik niet.

Ik heb zeker interesse in jou code.
Je mag hem ook mailen naar: joostverdaasdonk BIJ hotmail
PUNT com (het logische vervangen en aanelkaar)

Alvast bedankt,
Joost Verdaasdonk

-----Original Message-----
Joost,

Let er wel op dat de .ini file slechts 64K groot kan worden en derhalve bij
veel kontaktpersonen snel deze limiet bereikt. Wij hebben dit opgesliptst in
meerdere inifiles en een verwijzing naar een "master"ini file voor de
bedrijven. Indien interesse in de code svp hier melden.


"Joost" <[email protected]> schreef in bericht
Hi,

I've got the following Ini file example

[Company]
Person=Joost Verdaasdonk
Adress=Nieuwe Huizen 115
Postal=4813 TM Breda
Tel=076-567800

What I'm trying to achieve is to call a section by:
Declare Function GetPrivateProfileString
(or something like that)

This Call should fill a two dimensional array (option
Base 1) with all the Keywords (eg; Person) and Entries
(eg; Joost Verdaasdonk) of that Section.

I've achieved that by looping through the keywords and
getting out one entry at a time.
This seams a lot off work and is slowing down the
procedure.

A while a go I saw an API that could retrieve all the
Keywords in a one dimensional Array.
But I cannot find that one. And if there is one, is there
also one that can retrieve all the Entries in a simular
array? (Two one dimenisionals also would be faster but
Two dimenisonal is preffered)

Does anybody has the code to fill lets say the variable:
sAnwer (Variant) with values of the example Ini?

The Array has to feed my bookmarks in the document. (But
that part is covered)

Thank you very much.

Groetjes,
Joost Verdaasdonk


.
 
J

Joost

Hi JB,

Thank you for this tip.
Read as Textfile is an option I'll consider. (but as you
said this will turn my coding upside down) ;-)

Regards,
Joost
-----Original Message-----
Joost said:
Hi,

I've got the following Ini file example

[Company]
Person=Joost Verdaasdonk
Adress=Nieuwe Huizen 115
Postal=4813 TM Breda
Tel=076-567800

What I'm trying to achieve is to call a section by:
Declare Function GetPrivateProfileString
(or something like that)

This Call should fill a two dimensional array (option
Base 1) with all the Keywords (eg; Person) and Entries
(eg; Joost Verdaasdonk) of that Section.

I've achieved that by looping through the keywords and
getting out one entry at a time.
This seams a lot off work and is slowing down the
procedure.

A while a go I saw an API that could retrieve all the
Keywords in a one dimensional Array.
But I cannot find that one. And if there is one, is there
also one that can retrieve all the Entries in a simular
array? (Two one dimenisionals also would be faster but
Two dimenisonal is preffered)

Does anybody has the code to fill lets say the variable:
sAnwer (Variant) with values of the example Ini?

The Array has to feed my bookmarks in the document. (But
that part is covered)

Thank you very much.

Groetjes,
Joost Verdaasdonk

Hi Joost,
I think I'm right in saying that as long as you continue with
PrivateProfileString and .ini files (which are slow anyway), your speed
will not be what you want.

You could just open the file for input and do a readline for each of the
lines in the file, loop through the 1 dimensional array you create
looking for your header then do the rest from there.

This however might not be what your looking for as it's extra coding to
scroll the array to find your data then split it up (it's not that bad
really but I don't know your skill level) but I think ity's faster than
..ini files.

HTH

J


.
 
J

Joost

Hi Jonathan,

Most excellent stuff in the link you gave me!
This will come in hand at fase 2.

There I'll need to make a user interface (Form) to create
easy altering of the INI... (looks like I found how
now!) ;-)

Groetjes,
Joost Verdaasdonk
-----Original Message-----
Hi Joost

the following article describes how to use the GetPrivateProfileSection API
call to load an entire section of an INI file.

Using INI Files to Save Application Data - Saving Entire Sections
http://vbnet.mvps.org/code/file/pprofilesections.htm

The code in the article loads an INI file section into a VB6 listbox. You'll
need to adapt it to load it into an array instead.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup


Hi,

I've got the following Ini file example

[Company]
Person=Joost Verdaasdonk
Adress=Nieuwe Huizen 115
Postal=4813 TM Breda
Tel=076-567800

What I'm trying to achieve is to call a section by:
Declare Function GetPrivateProfileString
(or something like that)

This Call should fill a two dimensional array (option
Base 1) with all the Keywords (eg; Person) and Entries
(eg; Joost Verdaasdonk) of that Section.

I've achieved that by looping through the keywords and
getting out one entry at a time.
This seams a lot off work and is slowing down the
procedure.

A while a go I saw an API that could retrieve all the
Keywords in a one dimensional Array.
But I cannot find that one. And if there is one, is there
also one that can retrieve all the Entries in a simular
array? (Two one dimenisionals also would be faster but
Two dimenisonal is preffered)

Does anybody has the code to fill lets say the variable:
sAnwer (Variant) with values of the example Ini?

The Array has to feed my bookmarks in the document. (But
that part is covered)

Thank you very much.

Groetjes,
Joost Verdaasdonk

.
 
Top