Including a variable value in a string sent with FullDuplexSerial?
coryco2
Posts: 107
I would like to replace this (working) block of code:
VAR
BYTE VariableValue
PUB SendTheseBytes
FullDuplexSerial.tx ($01)
FullDuplexSerial..tx ($02)
FullDuplexSerial..tx ($03)
FullDuplexSerial..tx ($04)
FullDuplexSerial..tx (VariableValue)
FullDuplexSerial..tx ($FF)
...with a string-sending version:
PUB SendThisString
serial.str (@Str1)
DAT
Str1 BYTE $01, $02, $03, $04, "VariableValue", $FF, 0
...but cannot for the life of me figure out how to format it get it to include the "VariableValue" value in the string transmitted. Surely there is some way to do this?
VAR
BYTE VariableValue
PUB SendTheseBytes
FullDuplexSerial.tx ($01)
FullDuplexSerial..tx ($02)
FullDuplexSerial..tx ($03)
FullDuplexSerial..tx ($04)
FullDuplexSerial..tx (VariableValue)
FullDuplexSerial..tx ($FF)
...with a string-sending version:
PUB SendThisString
serial.str (@Str1)
DAT
Str1 BYTE $01, $02, $03, $04, "VariableValue", $FF, 0
...but cannot for the life of me figure out how to format it get it to include the "VariableValue" value in the string transmitted. Surely there is some way to do this?
Comments
Or you could do it this way:
One problem with the second way, is that VariableValue can never equal zero; otherwise the string would terminate prematurely.
-Phil
-Phil
I come from the world of Basic, where strings are a fundamental part of the language.
mystring = "Hello" + "World"
So I took Kye's very rich string object and added a few more , eg .str to convert a number to a string. There are also hex to string and a method to add strings together. So - build up the string first from all your values, and then send it out.
In your "main" program, create a few generic string arrays
declare your object
and here are some examples of using Kye's methods
and this is the object