Showing results for 
Search instead for 
Did you mean: 

Problem sorting arrays and... Using case feature

Go to solution

Problem sorting arrays and... Using case feature

Ok, so im doing this little code that solves linear 3x3 equations, I have most of the code made just missing 2 small bits for ascetics value, Ail try to describe them as detailed as I can, any type of advice or guidance with any of them would be greatly appreciated


Some Details of the program:

Equation MUST be ingress into a String, and should (and probably must) be able to do some hard fixing

It will be limited to +'s and -'s signs



Problem 1.

I don't really know how to "sort" my equation according to their variables, example:

User input:  -2 y   +1 *x -1 z = 2

What I can make it look like: -2 y + 1 x -1 z = 2

What I want it to look like: 1 x -2 y -1 z = 2 


I can manage to sort the equation, IF I knew the order the user is going to add the variables, the only thing that comes to my mind is turning them into an array and making one case for each ( x,y,z -- x,z,y -- etc) and using some sort of elimination process to choose the "shorter  or longer" array, I really haven't put much though into this because it seems like a dumb idea, but its the only thing It comes to my mind.



Problem 2.

So as im fixing the spaces between the characters, in the case I find a "10", I don't want a "1 0", I very roughly managed to get around this problem using a "Search and replace String", but I have problems making a "Case" for it, as in, I cant figure out the "right" input for a case string, example:

User input:  1 x -2 y -1 z = 12 


The result inside the case is correct and looks like a "12", but as I don't know the correct input, obviously my default case is empty and it passes right through, so the result outside is a "1 2"


Any link for someone who fixed a similar problem or guides would be great, also Id like to announce that 3 weeks ago I did not even knew what was "LabVIEW", so if you can "dumb down" the explanations a bit would be greatly appreciated.

0 Kudos
Message 1 of 4

Re: Problem sorting arrays and... Using case feature

Managed to somewhat solve second problem, any advice on the first one would be appreciated.

0 Kudos
Message 2 of 4
Accepted by topic author Mikado86
08-27-2015 04:09 PM

Re: Problem sorting arrays and... Using case feature

You could try to use the tokenizer to help parse it. The attached was a quickly hacked together solution that makes several assumptions (a big one being that the input is correct and the equal to is the last thing). So it's not really a complete solution.


Sorry I didn't have time to comment it. If it looks funny I was using the silver controls which got lost when I saved it for the previous version.

Message 3 of 4

Re: Problem sorting arrays and... Using case feature

Thanks, after some minor tweaking this was exactly what I was looking for

0 Kudos
Message 4 of 4