gazeranco 0 Posted March 29, 2012 Share Posted March 29, 2012 I have a script which overwrites some text in a file. Curently, I edit the code to change the text it writes. However, I would like to save a text file that the user can edit, then run the exe and it writes to the file from the user.txt file. Can anyone provide an example of this? Thanks Link to post Share on other sites
Moderators Melba23 3,799 Posted March 29, 2012 Moderators Share Posted March 29, 2012 gazeranco, What code have you tried that has not worked correctly? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to post Share on other sites
gazeranco 0 Posted March 29, 2012 Author Share Posted March 29, 2012 None tbh, I can't find a way of doing it... I am a nooby to this stuff and thumbling my way through with the help examples I was looking in the help for like a WriteFromFile command but I couldn't find one. Link to post Share on other sites
gazeranco 0 Posted March 29, 2012 Author Share Posted March 29, 2012 hmm I guess I need to read it into memory somehow and then write it from there? Link to post Share on other sites
Moderators Melba23 3,799 Posted March 29, 2012 Moderators Share Posted March 29, 2012 gazeranco,I guess I need to read it into memoryQuite probably - and what function do you think might be useful there? Hint - it begins with "File". There is even a function to read the file into an array with each line in a separate element - you will find that a couple if places lower in the Help file index - which sounds as if it might be even more useful. Top Tip: If you were to post the script you are currently using to show you have made some effort rather than expecting us to write code for you, you might get more than just hints. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to post Share on other sites
gazeranco 0 Posted March 29, 2012 Author Share Posted March 29, 2012 (edited) yay i did it (well technically, the help file did it... but i was there...) While 1 Local $line = FileReadLine($filer) If @error = -1 Then ExitLoop FileWriteLine($file, $line) WEnd Edited March 29, 2012 by gazeranco Link to post Share on other sites
stormbreaker 27 Posted March 29, 2012 Share Posted March 29, 2012 So far, I believe you are looking for Find and Replace method. If so, heres it: $TextFileName = "TextFile.txt" $FindText = "dog" $ReplaceText = FileRead("userfile.txt") $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents,$FindText,$ReplaceText) FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 Link to post Share on other sites
kylomas 418 Posted March 29, 2012 Share Posted March 29, 2012 gazeranco,I this related to this topic kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to post Share on other sites
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