Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

It's just IniRead. For example if you have an ini file:

[Vars]
Num=1

by using:

$Num = IniRead("path", "Vars", "Num", "")

you get 1.

Posted

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. :)

Posted (edited)

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

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

Edited by exodius
Posted (edited)

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

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
×
×
  • Create New...