Android Question Textwriter Question

Steve_ES

Member
Licensed User
Longtime User
Hello All,

I have a couple of newbie questions, hoping there is a simple answer. I'm sending formatted text over a Bluetooth link and I found something I can't explain:

Method 1:
Textwriter1.Write("This is a Test" & CRLF)


That works, but it only gives me a LF, no CR

Method 2:
Textwriter1.Writeline("This is a Test")


This works, but same result as above, no LF

Method 3:
Textwriter1.Write("This is a Test" & CHR(10) & CHR(13))

This works nicely as intended, CRLF at the end of the line. Am I doing something wrong?

One more thing, I could not find any examples of how to use AsyncStreams with Serial connections (for example serial connected to Bluetooth). I found lots of examples with TCP connections binding to a socket, like Server.Initialize(port, "Server"), Server.Listen, then wait for the Server_NewConnection to get a new socket to connect to. What is the syntax to bind a Socket to a serial stream? Or are Sockets not even used, something direct like:

AStreams.InitializePrefix(Serial1.InputStream, False, Serial1.OutputStream, "AStreams")

Thank you!
Steve
 

Steve_ES

Member
Licensed User
Longtime User
Update, with success!

It heps to read the documentation. The correct syntax is:
AStreams.Initialize(serial1.InputStream,serial1.OutputStream, "AStreams")

And it works great
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Hello All,
I have a couple of newbie questions, hoping there is a simple answer. I'm sending formatted text over a Bluetooth link and I found something I can't explain:

Method 1:
Textwriter1.Write("This is a Test" & CRLF)

Steve

For your info , In recent posts it has been suggested to avoid using TextWriter / Reader ... the exact reason I am unsure.
Instead to use File.WriteList / ReadList.

See This ... https://www.b4x.com/android/forum/threads/text-files.6690/#content

Unsure whether this fits your needs though.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Textwriter1.Write("This is a Test" & CRLF)

From the help: New line character. The value of Chr(10).

In Android CRLF is only LF Chr(10) and executes like CRLF in Windows.
If you need the CR character you must add it as you did in Method 3.
 
Upvote 0
Top