LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculator help

Hi folks,

 

I have a basic calculator function set up using a case structure. I have 5 settings on my slider. 0=Off, 1=add, 2= subtract, 3=multiply and 4=divide.

 

The 0 setting has an error message that requires the operator to select "OK".

 

Everything works fine until I throw a while loop around this so I can run it continuously. When 0 is selected it gets stuck in a loop with the prompt!

 

I am trying to insert another case structure that will use 0 as the default and then enable me to select the other four options.

Any hints or help would be appreciated.

0 Kudos
Message 1 of 7
(4,012 Views)

Hi!

 

The problem i think you have without have seen the code, is that if you select 0=Off the while loop will use 0 fore the next iteration and you have no chance to change the value. Pic 1 is how i from your description imagine you code

pic1.jpg

 

You need to halt the execution in some whay or change the value from 0 to any other so you end up in a case with no dialog, see pic2 for some examples

pic2.jpg

 

Hope this helps.

 

BR

 

/Thomas

0 Kudos
Message 2 of 7
(3,993 Views)

Thanks, thats pretty much the problem I had.

 

I will try and work with your suggestion. Looks good.

 

Thanks again for the help, as you may have guessed I relatively new to this.

0 Kudos
Message 3 of 7
(3,986 Views)

Hey Sionach,

 

Besides the well considerred solution, I think that Thomas has raised an excellent point here!! Why did you decide to use a slider control, to control the functionality of your calculator? Enumerated controls are often more useable (from a front panel point of view) - as they provide users with a list of items from which to select. If you use the "enum" here, you wouldnt need to rely on the user remembering which numbers represent which functions.

 

FP.jpg

 

But, moreover, they are excellent from a developers point of view too. Because the enum data type is a combination of numeric and string, when you wire an enumerated type control to the selector terminal of a Case structure, you can right-click the structure and select Add Case for Every Value to create a case for the string value of each item in the control. Once you have done this, each case will be aptly titled, making the block diagram become significantly more "Readable" and self documenting. Check out the image below. Which method would you rather work with?

 

BD.jpg

I hope this has been useful myfriend. Good luck with your future LabVIEW developements,

Best wishes,


Rich

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 4 of 7
(3,951 Views)

This was my program:

 

It was an assignment for college which was submiited a few months ago. I can get it to run when I remove the case containing the prompt. For my own benifit I have been trying to enable the prompt. I have tried using case and while loops.

 

 

 

0 Kudos
Message 5 of 7
(3,927 Views)

It's been 11 years now since I posted my LabView Scientific Calculator (Casio) back in 2003 without sample VI. Shame! I just found the VI's I wrote 11 years ago and now would like to share this to all who will find this VI usefull. If you have any question please feel free to email me at muligo@hotmail.com. You are free to share, modify and add more functions, formulas, conversions or anything you may think to make this application usefull.

Message 6 of 7
(3,557 Views)

Hey Joel,

 

Dispite being 11 years old, that is a great looking application! If you want to make it more visible/accessible to follow developers, you could condier posting it as a community example.

 

NI Developer Community

https://decibel.ni.com/content/community/zone

 

Head to the above URL, select the "documents tab" and then click the "Create a Document" link

 

Capture.JPG

 

Thanks for sharing!

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 7 of 7
(3,533 Views)