LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help me fix my calculator

Hi, I recently made a calculator. It works perfectly as far as I'm aware. (it's called Calculator Logic.vi and it's attached below).
My teacher saw it and asked me to add parentheses.
So I started working on a component that breaks down any expression into a number of "parenthesized expressions", and solves every one of them individually. This component is a key step in adding parentheses functionality to my calculator.

Now the problem is: The calculator solves the parenthesized expressions incorrectly! It solves the first one correctly, and then it's clear it keeps past values in memory and they mess up the next calculations! I couldn't find the source of it.
I know it's probably a little complicated to fix, but you guys got a better chance at it than I do.

Download All
0 Kudos
Message 1 of 11
(3,681 Views)

There are missing subVIs. From the symptoms, one of your missing subVIs probably has uninitialized shift registers or feedback nodes.

 

LabVIEW includes formula parsing VIs and the code can be inspected. Maybe it can give you some ideas.

0 Kudos
Message 2 of 11
(3,655 Views)

On a side note, your while loop seems overly complicated. This does exactly the same thing:

 

ParseParenthesized.png

 

(Of course this is not quite bulletproof because it does not deal correctly with mismatched or stacked parenthesis).

 

 

 

0 Kudos
Message 3 of 11
(3,646 Views)

You could even use a conditional tunnel for even less code:

 

ParseParenthesizedConditional.png

0 Kudos
Message 4 of 11
(3,633 Views)

Okay thanks for the cleanup but I still can't solve my problem.
You said there were missing VIs so I uploaded all of them.

0 Kudos
Message 5 of 11
(3,628 Views)

(Sorry, I don't have time to look at it at the moment, but please next time when attaching more than one VI, put them in a zip file. This also prevents name collisions in case I already have an equally named subVI in the downloads folder.)

0 Kudos
Message 6 of 11
(3,596 Views)

For those who don't like messing around with a lot of sub-VIs, I uploaded the whole thing in one file below.
Basically, I want the user to input an array of expressions (Example: 2+3 , 4-1..) and I want the calculator to output an array of solutions, each solution corresponding to an expression (5 , 3..).
The problem is: It adds all the solutions up. (5 , 8..).
I'm stuck for days!

0 Kudos
Message 7 of 11
(3,531 Views)

@I_want_Bagels_In_Me wrote:

For those who don't like messing around with a lot of sub-VIs, I uploaded the whole thing in one file below.
Basically, I want the user to input an array of expressions (Example: 2+3 , 4-1..) and I want the calculator to output an array of solutions, each solution corresponding to an expression (5 , 3..).
The problem is: It adds all the solutions up. (5 , 8..).
I'm stuck for days!


It's not that no one wants to deal with a lot of subVIs - it's that people don't want to deal with LOOSE subVIs.  Pack them into a zip file along with the main VI.  Changing the structure by eliminating subVIs changes the dataflow dependencies and could very well change the solution.  Or maybe even mask the original problem!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 11
(3,526 Views)

@billko wrote:

It's not that no one wants to deal with a lot of subVIs - it's that people don't want to deal with LOOSE subVIs.  Pack them into a zip file along with the main VI.


Exactly.  Especially the way my corporate network works, I will be lucky to get 2 of those downloaded.  A single zip file is much more likely to work.  It is also a lot less clicking to download a zip file and unzip it than to click each individual file, accept it, and then move it to a better place.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 11
(3,515 Views)

My main problem with loose files is name collisions. In my "downloads" folder, I have dozens of file with names like subVI.vi, subVI(1).vi,, subVI(2).vi, etc. and my least favorite Untitled 1.vi, Untitled 1 (1).vi, Untitled 1 (2).vi, etc. You get he point. Now imagine I download two VIs where the subVI is called again subVI.vi. The browser will rename it to subVI (11).vi and the caller will open with a year old subVI that most likely has completely different functionality and connector pane. If everything is in a zip file and I unzip to a folder, everything will open with the correct subVIs (except for the small chance that something with the same name is already in memory, but then we get a warning).

 

So yes, please attach everything as a zip file. Flattening everything to a single VI just creates a mess. Don't do it!

 

(Sorry, I don't have time at the moment to look at your code)

0 Kudos
Message 10 of 11
(3,505 Views)