Zomp Posted April 5, 2008 Share Posted April 5, 2008 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 More sharing options...
exodius Posted April 5, 2008 Share Posted April 5, 2008 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 More sharing options...
Aassdd Posted April 5, 2008 Share Posted April 5, 2008 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. Link to comment Share on other sites More sharing options...
Zomp Posted April 5, 2008 Author Share Posted April 5, 2008 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 More sharing options...
exodius Posted April 5, 2008 Share Posted April 5, 2008 (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 April 5, 2008 by exodius Link to comment Share on other sites More sharing options...
Zomp Posted April 5, 2008 Author Share Posted April 5, 2008 (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 April 5, 2008 by Zomp 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