anixon Posted May 15, 2007 Share Posted May 15, 2007 How do you get what you can display in a console to be written to the next line in a txt file. The data in the ini file is comma delimited Looks like 'agff,12345,6556,122,98765' is continuously changing and when read can be of any length. Basically I want to create a txt file that looks like agff,12345,6556,122,98765 agff,54321,6556,122,98765,23,4567 'agff,99876,6556,122,98765,12 Etc I can get it to display with this. CODEWhile 1 _DisplayData() WEnd Func _GetData() $data = IniRead(@ScriptDir & "\inifiles\my.ini", "section1", "value1", "0") If $data > 0 Then ConsoleWrite($data) Sleep(50) EndIf EndFunc how do I write the data to a file? Ant.. Link to comment Share on other sites More sharing options...
Valuater Posted May 15, 2007 Share Posted May 15, 2007 (edited) ConsoleWrite($data & @CRLF) FileWrite($File, $data & @CRLF) FileWriteLine().. maybe 8) Edited May 15, 2007 by Valuater Link to comment Share on other sites More sharing options...
anixon Posted May 15, 2007 Author Share Posted May 15, 2007 ConsoleWrite($data & @CRLF)FileWrite($File, $data & @CRLF)FileWriteLine().. maybe8)Thanks for that FileWriteLine works perfectlyHelp is always appreciatedAnt.. Link to comment Share on other sites More sharing options...
anixon Posted May 15, 2007 Author Share Posted May 15, 2007 (edited) Well after some testing it almost works but on occasions each string which starts with "$" is not written to its own line. Each string displayed using Consolewrite does appear on its own line. The data is being streamed from a COM port. Is there a way of fixing this so that the streamed data starting with $ starts on its own line? CODEWhile 1 _GetData() WEnd Func _GetData() If $NetComm.InBufferCount > 0 Then FileWriteLine($file, $netcomm.inputdata) Sleep(250) EndIf EndFunc Ant.. Edited May 15, 2007 by anixon Link to comment Share on other sites More sharing options...
Valuater Posted May 15, 2007 Share Posted May 15, 2007 NOT TESTED************** While 1 _GetData() WEnd Func _GetData() If $NetComm.InBufferCount > 0 Then $Split = StringSplit($NetComm.inputdata, "$") If IsArray($Split) Then For $x = 1 To $Split[0] FileWriteLine($file, $Split[$x]) Next Else FileWriteLine($file, $NetComm.inputdata) Sleep(250) EndIf EndIf EndFunc ;==>_GetData 8) Link to comment Share on other sites More sharing options...
anixon Posted May 19, 2007 Author Share Posted May 19, 2007 Thanks for that it was very helpful Cheers Ant.. 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