zoub99 Posted February 14, 2007 Share Posted February 14, 2007 hi, i have a txt file (ipstation.txt) who contains this chain: 192.192.192.192;255.255.255.255;192.168.0.1 i want to replace the string "192.192.192.192" by "192.168.0.2" my script ;======================================================= ; creation du fichier ipstation.txt en ecriture $FICHIPSTATION = FileOpen("C:\temp\clone\ipstation.txt",2) If $FICHIPCONFIG = -1 Then MsgBox(0, "Erreur", "Il n'a pas été possible de créer le fichier!") Exit EndIf $IP="192.192.192.192" ReplaceStringInFile ($FICHIPSTATION,$IP,$IPPC) ;======================================================= $IPPC is the chain "192.168.0.2" but it doesn't work thanks for your help zoub99 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 14, 2007 Moderators Share Posted February 14, 2007 (edited) 1. FileOpen('FileName', 2) Deletes the current files content 2. You don't need to do that with ReplaceStringInFile. (Also the UDF needs an underscore in front of it) #include <File.au3> _ReplaceStringInFile ("C:\temp\clone\ipstation.txt", '192.192.192.192', '192.168.0.2')Is all you need. Edited February 14, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
therks Posted February 14, 2007 Share Posted February 14, 2007 Tsk tsk, Smoke, you need to heed your own advice. You forgot the underscore in your [code] example. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 14, 2007 Moderators Share Posted February 14, 2007 Tsk tsk, Smoke, you need to heed your own advice. You forgot the underscore in your [code] example. No doubt I did!! I had an error in posting ... the code came out jumbled so I "fixed" it (yeah... some fix!) Thanks Saunders - Editing it now. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
zoub99 Posted February 14, 2007 Author Share Posted February 14, 2007 thank's for your answers........but it doesn't work's my new script (is name is "recup adresse mac.au3") #include <File.au3> ReplaceStringInFile ("C:\temp\clone\ipstation.txt", '192.192.192.192', '192.168.0.2') is the line "#include <File.au3>" important for ReplaceStringInFile ? in that case can i put in the script "#include recup adress mac.au3" sorry for my stupid questions but i begin with autoit Link to comment Share on other sites More sharing options...
The Kandie Man Posted February 14, 2007 Share Posted February 14, 2007 (edited) thank's for your answers........but it doesn't work's my new script (is name is "recup adresse mac.au3") #include <File.au3> ReplaceStringInFile ("C:\temp\clone\ipstation.txt", '192.192.192.192', '192.168.0.2') is the line "#include <File.au3>" important for ReplaceStringInFile ? in that case can i put in the script "#include recup adress mac.au3" sorry for my stupid questions but i begin with autoit Yes, File.au3 is neceassey since the _ReplaceStringInFile() function is a user defined function that is stored in file.au3 The code above didn't work because you removed the underscore( "_" ) from be beginning of the function. A user defined function has an underscore in front of it to let the programmer know that the function is not a native autoit function. #include <File.au3> _ReplaceStringInFile ("C:\temp\clone\ipstation.txt", '192.192.192.192', '192.168.0.2') Try that to the character^. Edited February 14, 2007 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire 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