08-13-2017 10:09 AM
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.
08-13-2017 10:44 AM - edited 08-13-2017 11:56 AM
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.
08-13-2017 11:06 AM
On a side note, your while loop seems overly complicated. This does exactly the same thing:
(Of course this is not quite bulletproof because it does not deal correctly with mismatched or stacked parenthesis).
08-13-2017 11:57 AM
08-13-2017 12:29 PM
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.
08-13-2017 02:57 PM - edited 08-13-2017 02:58 PM
(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.)
08-14-2017 11:41 AM
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!
08-14-2017 12:22 PM
@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!
08-14-2017 12:44 PM
@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.
08-14-2017 01:08 PM
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)