Jump to content

reading an ini files and assigning variables automatically


Recommended Posts

Surely this topic has already been discussed but, I'm sorrry, I was not able to find it.

Suppose I have a .ini file with a section like the following:

CheckDate=0
FlushMemory=1
LogFile=log.txt
InsertMedia=0

and depending on it I need to assign variables $CheckDate, $FlushMemory, $LogFile, $InsertMedia.

How can I do?

Many thanks for your help.

Link to comment
Share on other sites

Surely this topic has already been discussed but, I'm sorrry, I was not able to find it.

Suppose I have a .ini file with a section like the following:

CheckDate=0
FlushMemory=1
LogFile=log.txt
InsertMedia=0

and depending on it I need to assign variables $CheckDate, $FlushMemory, $LogFile, $InsertMedia.

How can I do?

Many thanks for your help.

Are you saying that you want to read the keys in that section and dynamically create variables based off what's found within, or you want to just do something like:

$CheckDate = IniRead ("C:\Path\To\File.ini", "Section", "CheckDate", "DefaultValueIfLookupFails")

If it's the former, I don't think you can dynamically name variables like that, if it's the latter, look up IniRead in the Helpfile.

Link to comment
Share on other sites

If it's the former, I don't think you can dynamically name variables like that, if it's the latter, look up IniRead in the Helpfile.

The former. Anyhow, you have given me the information I needed. Thanks. :)

Link to comment
Share on other sites

No problem, why do you need/want to declare your variables on the fly?

In my mind it seems just a question of speed and length of coding.

A loop similar to "for each ... next" is simpler that a set of single assigments, mostly if the variables are dozens and dozens.

Edited by Zomp
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...