trunc.ate Posted January 30, 2007 Share Posted January 30, 2007 I'd like to do a search and replace in a text file dependent on what's in the first line of this file. This works nicely with FileReadLine($SourceFile, 1). But at the end of the operation I want to update the first line of the text file. FileWriteLine works different as it only appends a line at the end of the file; is there a way to write the first line? Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 30, 2007 Share Posted January 30, 2007 HI, _ReplaceStringInFile in the helpfile. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
trunc.ate Posted January 30, 2007 Author Share Posted January 30, 2007 But when I get this right, _ReplaceStringInFile can't especially write the first line if it doesn't know what's in it at first? Link to comment Share on other sites More sharing options...
BrettF Posted January 30, 2007 Share Posted January 30, 2007 _FileWriteToLine should do wat u want Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 30, 2007 Moderators Share Posted January 30, 2007 (edited) _FileWriteToLine should do wat u wantThat or: $hFile = 'FileName and Location' $sRead = FileReadLine($hFile, 1) $sReplacement = $sRead & 'Something I want to add' _ReplaceStringInFile($hFile, $sRead, $sReplacement, 0, 0) Edited January 30, 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...
trunc.ate Posted January 30, 2007 Author Share Posted January 30, 2007 Brilliant, works like a charm. Thanks guys! 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