LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

append

Hi there,

So my string has a data size(hex code) of 117824. Now I want to make it of size 118784 so that it is perfectly divisible by 4096. So basically what I want to do is add zero paddings to the empty strings until it reaches 118784. I tried using replace substring but couldn't get the expected results. Thanks!append.PNG

0 Kudos
Message 1 of 14
(4,071 Views)

weird.PNG

I tried using this approach instead but the output was 3030 3030 3030. What I wanted is 0000 0000 0000.

0 Kudos
Message 2 of 14
(4,057 Views)

Hi keatwk,

 

when you post images of your BD you should really use Ctrl-U before…

 

Padding a string can be quite easy:

check.png

 

I tried using this approach instead but the output was 3030 3030 3030. What I wanted is 0000 0000 0000.

That's because you don't know the difference between a byte with value zero and the ASCII char "0"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 14
(4,044 Views)

Hi GerdW,

 

May I know why are you using case structure? Also could I have the vi file (preferably in 8.5). Thanks!

0 Kudos
Message 4 of 14
(4,015 Views)

Hi keatwk,

 

why are you using case structure?

No need to add 4096 bytes in case the string already has a proper length…

 

Also could I have the vi file (preferably in 8.5).

Unfortunately I didn't save this little item. It's easy enough to recreate it from scratch - and a nice exercise for you to learn LabVIEW with…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 14
(4,001 Views)

@keatwk wrote:

Hi GerdW,

 

May I know why are you using case structure? Also could I have the vi file (preferably in 8.5). Thanks!


I'm assuming the case structure is for readability.  Initializing an array of "Remainder" number of elements and concatinationg that too string should work just as well without the case structure.

Capture.PNG

 

Backsaved to LabVIEW 8.5 attached 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 14
(3,992 Views)

My data are in ASCII formats, so inputting 00 doesnt give out 00 hex code. But when I tried inputting "NUL" it gives out something else too. How can I go about this?

0 Kudos
Message 7 of 14
(3,966 Views)

Hi keatwk,

 

did you notice the display mode of the string constants in my and Jeff's example image? There's a reason why we explicitely show this setting!

 

@Jeff: Is there a reason to add 4096 bytes to the string when it happens to have a length dividable by 4096?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 14
(3,960 Views)

Hi,

 

This looks like it is related to this thread here

 

http://forums.ni.com/t5/LabVIEW/split-hex-code-after-every-4096-bytes/td-p/3212543

 

If you look at my example that I posted you end up with 4096 bytes padded already in one operation...

 

string array.png

 

Craig

LabVIEW 2012
0 Kudos
Message 9 of 14
(3,951 Views)

Hi keatwk,

 

to make it more easy to understand the code and to get the zero bytes you need to pad your string try this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 14
(3,941 Views)