rinaldm Posted June 1, 2004 Share Posted June 1, 2004 i want to check if a key in an ini file has a certain value if it is i need to change it , if the key doesn't exist in need to write some new entries to the ini file. here is the code i have so far but all it does is write the entry after the then statement and skips everything else If IniRead("C:\WINNT\class.ini", "New Trainer", "DatabaseName", "class") = "class" Then Iniwrite("C:\WINNT\class.ini", "New Trainer", "DatabaseName", "trainer") Else IniWrite("C:\WINNT\class.ini", "Databases", "New Class", "") IniWrite("C:\WINNT\class.ini", "Databases", "New Trainer", "") EndIf any help would be appreciated Link to comment Share on other sites More sharing options...
SweatyOgre Posted June 1, 2004 Share Posted June 1, 2004 Wow, could you please reword your question? I have no idea what you're trying to say. Link to comment Share on other sites More sharing options...
rinaldm Posted June 1, 2004 Author Share Posted June 1, 2004 (edited) ok i'm trying to check a key in an ini file to see if it is set to class if it is i need to change it to trainer, if the key is set to trainer i dont need to do anything. if the key is not there i need to add it Edited June 1, 2004 by rinaldm Link to comment Share on other sites More sharing options...
Developers Jos Posted June 1, 2004 Developers Share Posted June 1, 2004 First time you run it the ini contains: [New Trainer]DatabaseName=trainerSecond and subsequent times it contains: [New Trainer]DatabaseName=trainer [Databases] New Class= New Trainer=So thats exactly what you have coded in the script. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rinaldm Posted June 1, 2004 Author Share Posted June 1, 2004 ok what i want it to do is thisIF [New Trainer] DatabaseName=Class Then change to [New Trainer] DatabaseName=Trainerelseadd [Databases] New Class= New Trainer= Link to comment Share on other sites More sharing options...
tutor2000 Posted June 1, 2004 Share Posted June 1, 2004 i want to check if a key in an ini file has a certain value if it is i need to change it , if the key doesn't exist in need to write some new entries to the ini file.here is the code i have so far but all it does is write the entry after the then statement and skips everything elseIf IniRead("C:\WINNT\class.ini", "New Trainer", "DatabaseName", "class") = "class" Then Iniwrite("C:\WINNT\class.ini", "New Trainer", "DatabaseName", "trainer")Else IniWrite("C:\WINNT\class.ini", "Databases", "New Class", "") IniWrite("C:\WINNT\class.ini", "Databases", "New Trainer", "")EndIf any help would be appreciatedI'm not quite getting it myself but here's a basic idea $var=iniread("path\my.ini,"Section","key","DefaultValue");now if it's does not exist it will give the defaultvalue. If it does exist but is blank it will be empty soif $var="defalutvalue" or $var="" theniniwrite("path\my.ini","Section","key","MyNewValue")endifHope that helpedRick Link to comment Share on other sites More sharing options...
Developers Jos Posted June 1, 2004 Developers Share Posted June 1, 2004 Like this ? : If IniRead("C:\WINNT\class.ini", "New Trainer", "DatabaseName", "") = "class" Then Iniwrite("C:\WINNT\class.ini", "New Trainer", "DatabaseName", "trainer") Else IniWrite("C:\WINNT\class.ini", "Databases", "New Class", "") IniWrite("C:\WINNT\class.ini", "Databases", "New Trainer", "") EndIf SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rinaldm Posted June 1, 2004 Author Share Posted June 1, 2004 Got it working thanks for the help JdeB 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