LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sort 2d array of string

Solved!
Go to solution

Hello, please go easy on me since this is my first post here.  If I am "doing it wrong"  please let me know kindly.  I have the attached vi's for example of where I am at.  Hopefully, you can see the pic I inserted, if not it is in the attachments.

 

My problem:  I need to make Array In look like Array Example and place that data in Output Array.  So far, this is as far as I can get.  Array Example was parsed using "C" code and, then was read in using a CIN node.  We would like to replace all the dll code (CIN Nodes) with labview code.I can arrange the columns later, I just need to know how I can get all the formulas separated like the Array Example.  As you can see, I can get down to #7 row then can't seem to bet #8 row sorted out.  I can do either-or, depending on what tokens I am looking for first.  I see what is going on, when I find the first token, then pass the rest of the string, I am no longer looking at that column.  I just can't place my finger on a way to achive my goal.  Any suggestions? 

 

Thank You,

Sam

 

Example.png

Download All
0 Kudos
Message 1 of 12
(6,541 Views)

Sorry I forgot to make Array In current values default.  Sorry.

0 Kudos
Message 2 of 12
(6,520 Views)

Hello,

 

When searching for a specific characters, for example math operations in a string, you can use a regular expressions. For example in your case you can use the following expression, which will search either of included charachters (=, *, >, <, +, -, (, )).

 

[=>*/+-/()<]

 

Thanks,

Arev

 

CTO | RAFA Solutions

 

Certified-LabVIEW-Embedded-Systems-Developer_rgb.jpgCertified-LabVIEW-Architect_rgb.jpg

0 Kudos
Message 3 of 12
(6,505 Views)

Can you tell us the rules to be followed in doing the sorting?

I ask because your example output seems to have some contradictions in the patterns followed for various rows.

 

It looks like the 1st column is always supposed to contain the first numeric value (with or without the "#" symbol) after the equals sign that follows the first input numeric.

 

The equals sign following the 1st numeric always goes in the last column of the output.

 

The first input numeric always goes in the next-to-last column of the output.

 

The remain numeric values go in the intervening columns but they may or may not be interspersed with operators and this is where the ambiguities in the rules are felt.

0 Kudos
Message 4 of 12
(6,492 Views)

Thanks for your input guys.   WNM as far as I can tell about rules.in the end result it looks like the column on the furthes right will be the "=" always, then going left the next is the "solution"  then it gets confusing after that.  What I am basically after is just separating each component of each equation into their own columns then I can worry about ordering the columns afterwards.  It looks like they throw away any "(" and ")". 

0 Kudos
Message 5 of 12
(6,476 Views)

Hi,

 

I've tried to create some VI with exactly the same functionality. Maybe I've missed some operations, i.e. haven't included them in the regular expression, but you can add them, as required. I've also removed (), from the array.

 

Thanks,

Arev

 

CTO | RAFA Solutions

 

Certified-LabVIEW-Embedded-Systems-Developer_rgb.jpgCertified-LabVIEW-Architect_rgb.jpg

0 Kudos
Message 6 of 12
(6,466 Views)

That is great arevhamb.  My only question is how can I place the => and =< into one column like in example row 11?  I see your example put them in separate columns.

0 Kudos
Message 7 of 12
(6,459 Views)

Other than that, it looks great and I can work with the rest.  The only question I have left.  I tried adding \>=\<=\ to no avail.

0 Kudos
Message 8 of 12
(6,455 Views)
Solution
Accepted by topic author s_buckley

I think it is not possible, as in the code >, =, and < characters are being checked and separated from the string. But I have updated the code, with some workaround, which helps to escape from this issue.

 

I have replace <= and >= with some other characters, which are not used in the expressions. You can replace them, if you think you will use them. After searching for new characters, I'm replacing them back.

 

Thanks,

Arev

 

CTO | RAFA Solutions

 

Certified-LabVIEW-Embedded-Systems-Developer_rgb.jpgCertified-LabVIEW-Architect_rgb.jpg

Message 9 of 12
(6,435 Views)

Thank you so much.  That is great!!!

0 Kudos
Message 10 of 12
(6,432 Views)