Syntax for ASCII format characters in Parallax Serial Terminal .str method
John Kauffman
Posts: 653
I'm adding some ASCII format characters (for example 9 = tab) to strings to be printed by the Parallax_Serial_Terminal object's .str method.
If the string is held in DAT there is not problem adding the format characters there:
But I have been unable to find a sample syntax for putting the format characters directly in the PST.str:
I have several more attempts in the attached file. Some don't compile, others create an odd result.
Thanks.
If the string is held in DAT there is not problem adding the format characters there:
PUB Main pst.Start(57600) pst.str(@MyStringInDat1) DAT MyStringInDat1 byte 9,"A string w/tab held in the data block",0
But I have been unable to find a sample syntax for putting the format characters directly in the PST.str:
PUB Main pst.Start(57600) ' Attempt[1], but it does not compile: pst.str(9,@MyStringInDat1)
I have several more attempts in the attached file. Some don't compile, others create an odd result.
Thanks.
Comments
pst.Str(string(pst#TB))
pst.Str(@MyStringInDat1)
Alternatively, you should be able to do this:
pst.Str(string(pst#TB, "Some test string", pst#TB, "more string", pst#NL))
Your suggestion #1 works on two lines (but I'm am trying for one line)
Your suggestion #2 works with literal string (but i am trying for source in DAT):
I am shooting for something like the following:
It is not that I am adverse to two lines of code (your suggestion #1), I am mostly interested in learning if there is a syntax to do the job on one line and then learning how that syntax might apply to other places..
THanks.
Well, okay, there is one more way, but it's not elegant:
The output method is empty and does nothing. It's arguments are evaluated in order before being called, and that's the sole purpose it serves.
-Phil
EDIT: I insert a tab by using the octal representation \011 (9 decimal). \t should work, but I just relized that this generates a backspace (decimal 8) instead. I'll fix this in a future update to CLIB.