Jump to content
Sign in to follow this  
anixon

ConsoleWrite

Recommended Posts

anixon

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.

CODE
While 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..

Share this post


Link to post
Share on other sites
Valuater

ConsoleWrite($data & @CRLF)

FileWrite($File, $data & @CRLF)

FileWriteLine().. maybe

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
anixon

ConsoleWrite($data & @CRLF)

FileWrite($File, $data & @CRLF)

FileWriteLine().. maybe

8)

Thanks for that FileWriteLine works perfectly

Help is always appreciated

Ant..

Share this post


Link to post
Share on other sites
anixon

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?

CODE
While 1

_GetData()

WEnd

Func _GetData()

If $NetComm.InBufferCount > 0 Then

FileWriteLine($file, $netcomm.inputdata)

Sleep(250)

EndIf

EndFunc

Ant..

Edited by anixon

Share this post


Link to post
Share on other sites
Valuater

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites
anixon

Thanks for that it was very helpful

Cheers

Ant..

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×