toto22 Posted January 11, 2019 Share Posted January 11, 2019 (edited) Guys, my script adds new line to the text file after inserting an array. How can I prevent that? _FileWriteFromArray(@ScriptDir & '\WatchList.txt', $OldSymbols) Or the only way to fix that is to remove the "@CRLF" afterwards? Thank you Edited January 11, 2019 by toto22 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 11, 2019 Share Posted January 11, 2019 (edited) @toto22 Taking a look at the _FileWriteFromArray() function, seems that the @CRLF is always added at the end of the file, both for one dimensional and two dimensional array: FileWrite($hFile, $a_Array[$x] & @CRLF) FileWrite($hFile, $s_Temp & @CRLF) Edited January 11, 2019 by FrancescoDiMuro toto22 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
toto22 Posted January 11, 2019 Author Share Posted January 11, 2019 So to prevent that, I should probably add my array to string. remove @CRLF and paste it to file Link to comment Share on other sites More sharing options...
toto22 Posted January 11, 2019 Author Share Posted January 11, 2019 $String = _ArrayToString($OldSymbols,@CRLF) FileWrite ( @ScriptDir & '\WatchList.txt', $String ) Link to comment Share on other sites More sharing options...
Subz Posted January 11, 2019 Share Posted January 11, 2019 Something like: FileWrite($sFileName, StringStripWS(_ArrayToString($aOldSymbols, @CRLF), 3)) toto22 1 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 11, 2019 Share Posted January 11, 2019 @toto22 Pay attention The @CRLF is not added to your array, but it is added during the process of writing your array in the file by the _FileWriteFromArray() function; so, regardless your prior "managing" of the array, the @CRLF would be added indipendently. You could remove the @CRLF after using _FileWriteFromArray(), or use another function like FileWrite() in a loop, using @CRLF for each line except the last one. You can find for both the two "ways" to do that, a tons of examples on the Forum Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
toto22 Posted January 11, 2019 Author Share Posted January 11, 2019 Yea I got it it, thank you. I posted the solution that works for me. Is there a button that marks it solved? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 11, 2019 Share Posted January 11, 2019 @toto22 Just edit the first post and add "Solved" to the title toto22 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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