10-05-2012 10:00 AM
Hi All
I am trying to combine a Normal Display string indicator with hex
To do this I have formatted the hex into a format where it still looks like the starting hex but can go into the normal display string
e.g..
I start with 00040040
When I try to put this into my Normal display string I get 40040.
I have added a VI with an explanation and example - it'll be much easier to understand if you have a look at that.
Thanks for reading
Solved! Go to Solution.
10-05-2012 10:06 AM
Number to Hexadecimal string. There is a width input. Wire something to that such as a constant of 8.
10-05-2012 10:09 AM - edited 10-05-2012 10:10 AM
I couldn't look at your VI, but did you try the "Number To Hexadecimal String" with a width of 8?
[Edit] guess I'm a bit late. 😉
10-05-2012 10:09 AM
Will it always be 4 bytes (U32)? If so, set the width of the To Hex String to 8.
10-05-2012 10:17 AM
Its not that simple sadly - there is data before and after it
I am searching for part of the hex (say 2312) then trying to grab the next 6 bytes after it.
The problem is if the first X = 0, it chops them and adds whatever comes after those 6 bytes to the end
e.g.
23120004004012345678
So i find 2312
then try to grab the next 6 bytes
i get 4004 0123 5678
10-05-2012 10:20 AM
You are going to have to supply some code with this behavior. Sounds like you have a bug.
10-05-2012 10:23 AM
@NIcurious wrote:
Its not that simple sadly - there is data before and after it
I am searching for part of the hex (say 2312) then trying to grab the next 6 bytes after it.
The problem is if the first X = 0, it chops them and adds whatever comes after those 6 bytes to the end
e.g.
23120004004012345678
So i find 2312
then try to grab the next 6 bytesi get 4004 0123 5678
Show us your code, your description is not clear at all.
What are the display formats of the various strings?
I cannot find a string function called "grab".
10-05-2012 10:45 AM
1. I use the search node to find the index of 1256
2. I get use the unflatten from string to get the decimal followed by a number to hex function with a width of 6 (I want 48 bytes)
Here if my string begins with X number of zeroes those zeroes are not included
e.g.
Hex string 00041122334455667788 becomes
41122334455
Byte 1
4
Byte 2
11
byte 3
22
byte 4
33
byte 5
44
byte 6
55
It should be
byte 1
00
byte 2
04
etc
Can't post the code cause its huge and the string is past in from another VI
Hope you'ev got enough detail here
10-05-2012 10:48 AM - edited 10-05-2012 10:50 AM
@NIcurious wrote:
Can't post the code cause its huge and the string is past in from another VI
Then create a new VI containing only the relevant code. You can make the "string" a diagram constant containing exactly what is received from elsewhere.
10-05-2012 10:52 AM
Overall, I think you are making this far more complicated than it should be by taking some string data, unflattening it from a string (what did it originally look like coming in?) then turning it into a hex formatted string and manipulating characters.
You should be able to work with bytes more directly. Turn your strings into arrays of U8 integers and work with them. Then you shouldn't have to worry about leading zeroes in a hex formatted string and whether they should or shouldn't be there, and if they are there or not because you have undetermined lengths of data.
String to Byte Array, and Typecast are probably the functions you should be using rather than the ones you are.