LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing values out after each iteration of for loop

Highlighted

hey every one,

i want to know the method to output the converted data from string to hex (byte by byte) after each iteration of for loop

please see the attached picture

thanks in advance

0 Kudos
Message 1 of 8
(935 Views)
Highlighted

The output of the for loop is configured as last value. So, you'll get (wait for it...) the last value.

 

Change it to indexing. That will give you an array. Use Concatenate Strings to convert the array to string.

 

Number to Hexadecimal String does the same as the Format Into Sting, but it works on arrays. So you don't need the for loop. You'd still need the Concatenate Strings.

 

You can lose the array size, the auto indexing on the input array will automatically loop over all elements.

0 Kudos
Message 2 of 8
(922 Views)
Highlighted

Basically this is the small part of my program, basically i am transmitting a string from one com port and receive it on another com port, then i provide the selection buttons to get the transmitted string in hex,binary,decimal or Ascii. I use the same string indicator for all data formats and case structure for selection. when i select the tunnel for indexing mode the connection error occurred... whats the solution for that ??the picture of VI is attached

0 Kudos
Message 3 of 8
(900 Views)
Highlighted

You removed the String to Byte Array.

 

Now you're casting a string to a single byte, so only the first byte will be converted.

 

Either go back to String to Byte Array, or cast to an array of bytes.

0 Kudos
Message 4 of 8
(895 Views)
Highlighted

And just a hint:

 

Handling those Booleans, ASCII, Hex, Decimal, Binary, will be a hole lot easier if you refactored them to a radio button (Raw, ASCII Hex, .ASCII Decimal, ASCII binary).  Raw, Hex, Decimal and Binary are mutually exclusive. The radio button will be an enum, so you only need to implement 4 cases in one case structure. That will make 80% of that code redundant.

0 Kudos
Message 5 of 8
(894 Views)
Highlighted

@Arslan125 wrote:

the picture of VI is attached


And that's a big problem.  Pictures of VIs omit a lot of information, not the least of which is "What Version of LabVIEW is the Poster using?".  If you are using LabVIEW 2016 or higher, there is a "solution" to your Post Title, passing values out after each iteration of For loop.  So either Post your Code (attach a VI) or reply saying "I'm using LabVIEW xxxx".

 

Bob Schor

0 Kudos
Message 6 of 8
(873 Views)
Highlighted

To answer the question that Arslan125 asked:  You can output the data from each iteration of a for loop using a Queue.  See the attached example snippet. 

0 Kudos
Message 7 of 8
(857 Views)
Highlighted

@EndigitBryan wrote:

To answer the question that Arslan125 asked:  You can output the data from each iteration of a for loop using a Queue.  See the attached example snippet. 


I'm not sure what question that answers?

0 Kudos
Message 8 of 8
(831 Views)