toto22 Posted January 11, 2019 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
FrancescoDiMuro Posted January 11, 2019 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
toto22 Posted January 11, 2019 Author Posted January 11, 2019 So to prevent that, I should probably add my array to string. remove @CRLF and paste it to file
toto22 Posted January 11, 2019 Author Posted January 11, 2019 $String = _ArrayToString($OldSymbols,@CRLF) FileWrite ( @ScriptDir & '\WatchList.txt', $String )
Subz Posted January 11, 2019 Posted January 11, 2019 Something like: FileWrite($sFileName, StringStripWS(_ArrayToString($aOldSymbols, @CRLF), 3)) toto22 1
FrancescoDiMuro Posted January 11, 2019 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
toto22 Posted January 11, 2019 Author 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?
FrancescoDiMuro Posted January 11, 2019 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
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