Merchants Posted October 24, 2010 Share Posted October 24, 2010 FileWrite how to write a big text like this: $file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, [ test1 test3 hi yo man Line1]) FileClose($file) file results must be: test1 test3 hi yo man Line1But how do i make this happen ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 24, 2010 Moderators Share Posted October 24, 2010 Merchants,You use the concatenation operator & to make a single string: FileWrite($file, "test1" & @CRLF & "test3" & @CRLF & "hi" & @CRLF & "yo man" & @CRLF & "Line1")Just like it shows in the example in the Help file. 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 comment Share on other sites More sharing options...
Merchants Posted October 24, 2010 Author Share Posted October 24, 2010 (edited) well it is a VERY long text to make that happen is it not poseble what i say in post 1? Edited October 24, 2010 by Merchants Link to comment Share on other sites More sharing options...
Realm Posted October 24, 2010 Share Posted October 24, 2010 Hello Merchants, Try This: $file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "test1" & @CRLF _ & "test3" & @CRLF _ & "hi" & @CRLF _ & "yo man" & @CRLF _ & "Line1") FileClose($file) Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Realm Posted October 24, 2010 Share Posted October 24, 2010 well it is a VERY long text to make that happen is it not poseble what i say in post 1?Melba's Example will do what you ask Merchant, as will mine, our examples are different but will produce the same results, it all depends on how you want your code to look.Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 24, 2010 Moderators Share Posted October 24, 2010 Merchants. well it is a VERY long textThen break it up into smaller chunks and add the parts together using &= like this: $sText = "test1" & @CRLF $sText &= "test3" & @CRLF $sText &= "hi" & @CRLF $sText &= "yo man" & @CRLF $sText &= "Line1" FileWrite($file, $sText) Is that better? 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 comment Share on other sites More sharing options...
Merchants Posted October 24, 2010 Author Share Posted October 24, 2010 (edited) well that is still very long work i need to write a smal text like this function myReadLine(filename, linenumber) { var _tmpfile; var _line; _tmpfile = FileOpen(filename, 0); if(_tmpfile) { var _linenumber = 0; while(!_tmpfile.eof) { _line = _tmpfile.ReadLine(); if(_line) { _linenumber = _linenumber + 1; if (_linenumber == linenumber) { _tmpfile.Close(); return _line; } } } _tmpfile.Close(); } return ""; // empty string if can't read file, or can't find the line wanted. }to set all the @CRLF is very long work if this was a smal text then i was not here.. i need to write it whiteout the CRLF i hope that that is poseble.. Edited October 24, 2010 by Merchants Link to comment Share on other sites More sharing options...
JohnOne Posted October 24, 2010 Share Posted October 24, 2010 Perhaps if you can find a way to better explain yourself, you might get an answer closer to what you need. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Merchants Posted October 24, 2010 Author Share Posted October 24, 2010 (edited) if i just paste it like this expandcollapse popup$file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, [ function myReadLine(filename, linenumber) { var _tmpfile; var _line; _tmpfile = FileOpen(filename, 0); if(_tmpfile) { var _linenumber = 0; while(!_tmpfile.eof) { _line = _tmpfile.ReadLine(); if(_line) { _linenumber = _linenumber + 1; if (_linenumber == linenumber) { _tmpfile.Close(); return _line; } } } _tmpfile.Close(); } return ""; // empty string if can't read file, or can't find the line wanted. }]) FileClose($file) then the file results must be like this whit the spaces and enters and taps: function myReadLine(filename, linenumber) { var _tmpfile; var _line; _tmpfile = FileOpen(filename, 0); if(_tmpfile) { var _linenumber = 0; while(!_tmpfile.eof) { _line = _tmpfile.ReadLine(); if(_line) { _linenumber = _linenumber + 1; if (_linenumber == linenumber) { _tmpfile.Close(); return _line; } } } _tmpfile.Close(); } return ""; // empty string if can't read file, or can't find the line wanted. } Edited October 24, 2010 by Merchants Link to comment Share on other sites More sharing options...
JohnOne Posted October 24, 2010 Share Posted October 24, 2010 I still dont understand Try this select the data you want with your mouse, and right click, select copy. Run this script $sfile = "test.txt" $sData = ClipGet() FileWrite($sfile,$sData) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 24, 2010 Moderators Share Posted October 24, 2010 Merchants,If you do not want to add the @CRLFs within AutoIt, then I can only suggest that you type the lines into an editor and save the result as a file - the editor adding the line feeds automatically. Then you can read the file into AutoIt with FileRead - you will include the @CRLFs from the file - and you can finally write the result using FileWrite. By the way what is that strange mixture of code you are trying to write? 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 comment Share on other sites More sharing options...
Merchants Posted October 24, 2010 Author Share Posted October 24, 2010 (edited) .. well i al do it this way: expandcollapse popup$file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $sText = "function myReadLine(filename, linenumber)" & @CRLF $sText &= "{" & @CRLF $sText &= " var _tmpfile;" & @CRLF $sText &= " var _line;" & @CRLF $sText &= "" $sText &= " _tmpfile = FileOpen(filename, 0);" & @CRLF $sText &= "" $sText &= " if(_tmpfile)" & @CRLF $sText &= " {" & @CRLF $sText &= " var _linenumber = 0;" & @CRLF $sText &= " while(!_tmpfile.eof)" & @CRLF $sText &= " {" & @CRLF $sText &= " _line = _tmpfile.ReadLine();" & @CRLF $sText &= " if(_line)" & @CRLF $sText &= " {" & @CRLF $sText &= " _linenumber = _linenumber + 1;" & @CRLF $sText &= " if (_linenumber == linenumber)" & @CRLF $sText &= " {" & @CRLF $sText &= " _tmpfile.Close();" & @CRLF $sText &= " return _line;" & @CRLF $sText &= " }" & @CRLF $sText &= " }" & @CRLF $sText &= " }" & @CRLF $sText &= " _tmpfile.Close();" & @CRLF $sText &= " }" & @CRLF $sText &= " return ""; // empty string if can't read file, or can't find the line wanted." & @CRLF $sText &= "}" FileWrite($file, $sText) FileClose($file)it is meby the fastest way to do it Edited October 24, 2010 by Merchants Link to comment Share on other sites More sharing options...
Merchants Posted October 24, 2010 Author Share Posted October 24, 2010 Merchants,If you do not want to add the @CRLFs within AutoIt, then I can only suggest that you type the lines into an editor and save the result as a file - the editor adding the line feeds automatically. Then you can read the file into AutoIt with FileRead - you will include the @CRLFs from the file - and you can finally write the result using FileWrite. By the way what is that strange mixture of code you are trying to write? M23it is java script codes Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 24, 2010 Moderators Share Posted October 24, 2010 Merchants, Thank you for that answer. Glad you found a way to do what you want. 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 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