From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

combine strings

Hi, I have a motor which needs three bytes to move, from low to high. through
some formula I get a number. Then I use TO hexdecimal in the abc to transfer
it to a string, which is the lowest byte, then combine it with two \00 to
produce three bytes.(\ code), but the lowest byte just doesn't follow the
"\ code". Like if I have a decimal 48, after transfer to string, it is 30.
30 is the lowest and I hope the final three-byte form will be like
\30\00\00
in Hex form, will be
3000 00
But my actual result will look like
3330 0000
which will be 4 bytes,
How can I directly or indirectly produce a \30 form from a decimal number
48? and then combine with \00 and \00 to produce \30\00\00?
Thank you advance
0 Kudos
Message 1 of 3
(2,457 Views)
lixia,

Starting with the number you compute (i.e. you used 48) do not use the 'to
hex' function. There is a function for taking a number and creating the
ascii equivalent version of this. Its in the sting pallette under the sub-palette
"array/string/path conversion". Its 'byte array to string'. problem is
you have only 1 number, not an array. so here is how you do it.

Take your computed number and wire it into a 1 input build array function.
take this output and wire it into the 'byte array to string' function.
this into a concatenate function with a string constant of '\00\00'. The
output (if viewed in a string indicator showing hex display) will show '3000
00'. This can go right to the serial port write function (or whatever you're
doing next).

Hope th
is helps. As always, email me if you don't understand and want a
code example.

Jared

"lixia" wrote:
>>Hi, I have a motor which needs three bytes to move, from low to high. through>some
formula I get a number. Then I use TO hexdecimal in the abc to transfer>it
to a string, which is the lowest byte, then combine it with two \00 to>produce
three bytes.(\ code), but the lowest byte just doesn't follow the>"\ code".
Like if I have a decimal 48, after transfer to string, it is 30.>30 is the
lowest and I hope the final three-byte form will be like > \30\00\00 > in
Hex form, will be> 3000 00>But my actual result will look like> 3330
0000>which will be 4 bytes, > How can I directly or indirectly produce a
\30 form from a decimal number>48? and then combine with \00 and \00 to produce
\30\00\00? >Thank you advance
0 Kudos
Message 2 of 3
(2,456 Views)
Hi,Jared, Thank you so much and much. You are so nice and I appreciate your
reply message. Also thank this newsgroup so I can get answer so quickly.
0 Kudos
Message 3 of 3
(2,456 Views)