dcjohnston Posted September 30, 2004 Share Posted September 30, 2004 I am a right brained guy trying to do something that is way over my head. I have to edit 3 .ini files. they are called plat1.ini, plat2.ini and plat3.ini I created a "changes.ini" file that is the central data file that the compiled exe will go to for information. It looks like this: ;-------------------------platserve.ini files go here -------------------------- [platnames] PLATSERV = plat1.ini PLATSERV = plat2.ini PLATSERV = plat3.ini ;--------------------------plat*.ini changes go here-------------------------- [Defaults] DPPhoneNbr=55555555555555 [Training] DATABASE=YYYYYYYYYYYYYYY [ADO] DATABASE=XXXXXXXXXXXXXXXXXXXXX ;----------------------------------------------------------------------------------- I need to take this data under plat*.ini using the iniread function and iniwrite it to each of the 3 plat#.ini files. The files needing to be edited reside on a mapped f: drive. The challenge is to somehow loop reading this out of the "changes.ini" file and writing it to each of the 3 plat#.ini files. Any help is GREATLY appreciated. Dave Link to comment Share on other sites More sharing options...
SlimShady Posted September 30, 2004 Share Posted September 30, 2004 To get this straight:- You have a main script.- A main INI file that has the name: changes.iniEvery client has a script that updates the changes.ini when necessary.- When someone updates the changes.ini, all the other INI files will be updated by the main script.Will the main script run frequently?By one person or multiple users? Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted September 30, 2004 Share Posted September 30, 2004 A couple things here. First of all you cannot have mulitple values by the same name within the same section. This will ONLY ever return the first value in the file. Another thing, do you have control over the way the changes INI is formatted or is there any standard parameters you have to check for? You dont give enough information about the source of this information to be able to generate a good complete script. *** Matt @ MPCS Link to comment Share on other sites More sharing options...
dcjohnston Posted September 30, 2004 Author Share Posted September 30, 2004 To get this straight:- You have a main script.Correct. A Compiled autoit.exe file called platupgrade.exe. This exe goes to the c:\changes.ini file for upgrade information. This changes.ini file contains the information that will need to be placed in the plat1.ini file that exists on the mapped f: drive. This is from the changes.ini file.;--------------------------plat*.ini changes go here--------------------------[Defaults]DPPhoneNbr=55555555555555[Training]DATABASE=YYYYYYYYYYYYYYYDATABASE=ZZZZZZZZZZZZZZZ[ADO]DATABASE=XXXXXXXXXXXXXXXXXXXXX- When someone updates the changes.ini, all the other INI files will be updated by the main script. Correct. I make changes to the changes.ini file and the .exe goes and says:OK, I need to update the f:\pltrsm\platform.ini [Defaults] section with DPPhoneNbr=55555555555555Then go to the [Training] section and add DATABASE=YYYYYYYYYYYYYYYDATABASE=ZZZZZZZZZZZZZZZThen under the [ADO] section add this lineDATABASE=XXXXXXXXXXXXXXXXXXXXXWill the main script run frequently? Just once. It just needs to be able to read the data in the changes .ini file in a loopBy one person or multiple users? One personThanksDave Link to comment Share on other sites More sharing options...
dcjohnston Posted September 30, 2004 Author Share Posted September 30, 2004 Thanks Matt, good information. The changes .ini file would contain this instead. I put the original information in as an example. This would be a better example.[Defaults]DPPhoneNbr=55555555555555[Training]Users=YYYYYYYYYYYYYYY[ADO]DATABASE=XXXXXXXXXXXXXXXXXXXXXA couple things here. First of all you cannot have mulitple values by the same name within the same section. This will ONLY ever return the first value in the file. Another thing, do you have control over the way the changes INI is formatted or is there any standard parameters you have to check for? You dont give enough information about the source of this information to be able to generate a good complete script.*** Matt @ MPCS<{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted September 30, 2004 Share Posted September 30, 2004 [qoute];-------------------------platserve.ini files go here --------------------------[platnames]PLATSERV = plat1.iniPLATSERV = plat2.iniPLATSERV = plat3.ini Link to comment Share on other sites More sharing options...
dcjohnston Posted September 30, 2004 Author Share Posted September 30, 2004 Yes they will have a fixed name. So your change is good. The .exe would need to start at the top of the [platnames] section and say:I need to see if there is a plat1.ini file in the f:\pltrsm directory. If there is then I need to make changes to it.I will get that information from the changes.ini file[Defaults]DPPhoneNbr=55555555555555[Training]Users=YYYYYYYYYYYYYYY[ADO]DATABASE=XXXXXXXXXXXXXXXXXXXXXelse check to see if there is a plat2.ini and so on. THanks Dave[qoute];-------------------------platserve.ini files go here --------------------------[platnames]PLATSERV = plat1.iniPLATSERV = plat2.iniPLATSERV = plat3.iniAre these files always going to be the same? If not can I make a suggestion? Try this:[platnames] PLATSERV1=plat1.ini PLATSERV2=plat2.ini PLATSERV3=plat3.ini PLATSERV4=platN.ini*** Matt @ MPCS<{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted September 30, 2004 Share Posted September 30, 2004 (edited) Well I am completly spent on this... I will share the source I have typed but it won't do what you want yet. It still has quite the distance before it is complete. Hopefully it gives someone an idea somewhere. Dim $i, $j Dim $tmpINIValue, $tmpINIValue2 Dim $PLATSERVFILE Dim $arrMatchKeys Dim $CONFIGFILE = "config.ini" $PLATSERVFILE = IniRead( $CONFIGFILE, "Main", "PlatServFile", "platserv.ini" ) $tmpINIValue = IniRead( $CONFIGFILE, "Main", "MatchKeys", "" ) $arrMatchKeys = StringSplit( $tmpINIValue, "|" ) $i = 0 While 1 $i = $i + 1 $tmpINIValue = IniRead( $PLATSERVFILE, "[platnames]", "PLAT" & $i, "" ) If $tmpINIValue <> "" Then For $j = 1 to $arrMatchKeys[0] Next Else ExitLoop EndIf Wend Sorry I couldn't finish it. *** Matt @ MPCS Edited September 30, 2004 by Matt @ MPCS Link to comment Share on other sites More sharing options...
dcjohnston Posted October 4, 2004 Author Share Posted October 4, 2004 Matt, Excellent, I see what you are going. Man I owe you one. Thanks for your time. I will give you credit in my code.Thanks again for your assistance...DaveWell I am completly spent on this... I will share the source I have typed but it won't do what you want yet. It still has quite the distance before it is complete. Hopefully it gives someone an idea somewhere.Dim $i, $j Dim $tmpINIValue, $tmpINIValue2 Dim $PLATSERVFILE Dim $arrMatchKeys Dim $CONFIGFILE = "config.ini" $PLATSERVFILE = IniRead( $CONFIGFILE, "Main", "PlatServFile", "platserv.ini" ) $tmpINIValue = IniRead( $CONFIGFILE, "Main", "MatchKeys", "" ) $arrMatchKeys = StringSplit( $tmpINIValue, "|" ) $i = 0 While 1 $i = $i + 1 $tmpINIValue = IniRead( $PLATSERVFILE, "[platnames]", "PLAT" & $i, "" ) If $tmpINIValue <> "" Then For $j = 1 to $arrMatchKeys[0] Next Else ExitLoop EndIf WendSorry I couldn't finish it.*** Matt @ MPCS<{POST_SNAPBACK}> 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