440LVB Posted May 19, 2005 Share Posted May 19, 2005 (edited) Hello I want to change one string in a script with another script, but I don't know part of the string (French sentences, but it's not important) $fichier = FileOpen("taille.au3",0) If ($fichier = -1) Then MsgBox ( 0, "Erreur", "Impossible de trouver le fichier de script") Else $lecture = FileRead($fichier, 1000) $error = StringReplace ($lecture,"$max = 100", "$max = 200") ; I want to put a joker or same kind of character instead of "100" ; because I don't know what number it will be... MsgBox( 0, "test",$lecture & "\n") FileClose($fichier) $fichier = FileOpen("taille.au3",2) FileWrite ($fichier,$lecture) FileClose($fichier) EndIf The MsgBox() is there to test the value Edited May 19, 2005 by 440LVB Link to comment Share on other sites More sharing options...
440LVB Posted May 19, 2005 Author Share Posted May 19, 2005 No idea? Link to comment Share on other sites More sharing options...
Nutster Posted May 19, 2005 Share Posted May 19, 2005 (edited) If you do not know what number will be included, use StringRegExpReplace in the beta version. Will the file always be smaller than 1000 bytes? If not, you should probably do the following:Read the entire file into a string or array.Use StringRegExpReplace to make the approprate replacements.Write the file.$fichier = FileOpen("taille.au3",0) If ($fichier = -1) Then MsgBox ( 0, "Erreur", "Impossible de trouver le fichier de script") Else ; Read entire file, not just first 1000 characters. $lecture = "" Do $lecture = $lecture & FileRead($fichier, 1000) Until @Error = -1 ; Perform the replacement. $lecture = StringRegExpReplace($lecture, "$max = \d+", "$max = 200", 0) MsgBox( 0, "test",$lecture & "\n") FileClose($fichier) $fichier = FileOpen("taille.au3",2) FileWrite ($fichier,$lecture) FileClose($fichier) EndIfEdit: Fix speeling errors Edited May 19, 2005 by Nutster David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
buzz44 Posted May 20, 2005 Share Posted May 20, 2005 Edit:Â Fix speeling errors<{POST_SNAPBACK}> *Spelling . Lol. qq Link to comment Share on other sites More sharing options...
kjactive Posted May 20, 2005 Share Posted May 20, 2005 (edited) I just finished a word manipulate UDF function library containing several functions you could use - these functions are all words related no matter what...Free to download...http://www.sitecenter.dk/latenight/nss-fol...pports/Word.zipkjactive Edited May 20, 2005 by kjactive Au3PP 4.1 - Autoit3 preprocessor, optimize speed, performance to scripts and do executes....[/url]Au3Calibur - Create libraries of commonly used code excerptsWords manipulate UDF, functions that is lent from the rexx language, topics and index file includedCustomDialog UDF to include custom made dialogs like a extended colorpick requester to scripts...[url="ftp://fritidshjemmet.com/Autoit3/SysColor.zip"]SysColor UDF a low level color library to manipulate RGB and Hex values...Shell32 UDF to Automate Windows® operating tasks from native dialog and Wizards browsers... Optimized the CodeWicard with options to generate browser code etc... 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