987learner Posted December 22, 2008 Posted December 22, 2008 I have a ini file, Launcherslite.ini with the following: [2xExplorer] FileName=Q:\2xExplorer.exe StartIn= Params= WindowStyle=1 [Centura Group Folder] FileName=Q:\OpenCentura.cmd StartIn= Params= WindowStyle=1 I'm using a script to change the drive letter to @homedrive, leaving the rest of lines intact. (Drive may not necessary be Q:\) However, my script can only output 1 single line, that is FileName=C:\2xExplorer.exe How do I retain the rest of the code + change all occurance of the drive letter to C? Opt("TrayIconDebug", 1) $Homedrive=StringMid ( @homedrive, 1, 1 ); change C: to C $file = FileOpen("Launcherslite.ini", 0);READ MODE If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $i=1 to 11 If StringInStr(FileReadLine($file, $i), "FileName=") Then $Resonstruct1=StringRegExpReplace(FileReadLine($file, $i), "(FileName=)([A-Z])(\D.*|\d.*|)", "$1") $Resonstruct3=StringRegExpReplace(FileReadLine($file, $i), "(FileName=)([A-Z])(\D.*|\d.*|)", "$3") FileClose($file);close read mode $file = FileOpen("Launcherslite.ini", 2);write mode FileWriteLine ($file, $Resonstruct1&$Homedrive&$Resonstruct3) EndIf Next FileClose($file)
Developers Jos Posted December 22, 2008 Developers Posted December 22, 2008 Why not use the INIWrite() function? Jos 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.
987learner Posted December 22, 2008 Author Posted December 22, 2008 B'cause I'm still learning & haven't learn this iniwrite function yet. I thought it might be better to start with some standard file format (so that in future I'm not restrict to .ini type only) Learning how to overwrite a standard file type (although I'm actually modifying .ini) seems more partical at the moment...
Andreik Posted December 22, 2008 Posted December 22, 2008 B'cause I'm still learning & haven't learn this iniwrite function yet. I thought it might be better to start with some standard file format (so that in future I'm not restrict to .ini type only) Learning how to overwrite a standard file type (although I'm actually modifying .ini) seems more partical at the moment...Read all the content of file and use StringReplace(). Somethign like this: StringReplace($DATA,"C:\","Q:\")
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