10-14-2015 10:37 AM
Howdy,
First off this is a college work assignment and that it is mostly complete; looking for guidance and experience here. The assignment is to create a calculator with several functions for each arithmetic method. That was easy enough but the next step is to display a message to the user after each calculation. For example, if the problem was 4 + 2, the message should be "The result of the addition is: 6." Creating the message part using the Display Msg to User function is simple but it doesn't exactly hit home. I want to create a message that contains the problem result (e.g. 6). As it stands right now I can't do this with the Msg function, or if it is possible I can't quite figure it out. I want to have a separate message for each function, but I'm not sure if I can incorporate the answer into the message. That is the underlying goal; how to incorporate the answer into a dialogue message box to the user? If it is possible what should I be looking at?
The VI itself is pretty simple; case structure for each arithmetic function and a while loop for executing. X and Y are the inputs and a drop down menu for selecting necessary case structure. I've attached a screen below.
Thank you
Tha
Solved! Go to Solution.
10-14-2015 10:40 AM - edited 10-14-2015 10:42 AM
You can use the Display Message to User to display any string to the user. So the key is to use the string palette to manipulate strings to get the message you want.
A subpalette of the string palette is the Number/String Conversion palette. This can help you get your value (6) to a string format and then you can concatenate that string however you want with the message.
With popups, you need to be careful that you're not triggering that popup with every single loop, so make sure you put a case structure around the popup and put logic in there so it only runs the popup case when the value changes.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
10-14-2015 11:24 AM
You might also consider building your string for the operation in the same case structure you use for your math. This would simplify building the string to be concatenated since you already have your numbers available there, and a conversion with concatenation at that level would lead you to what you want without creating another case structure.
10-14-2015 11:30 AM - edited 10-14-2015 11:32 AM
You might want to look at your CPU usage when you run the VI too. You have no execution timing in the VI (unless it's in another case!) which means it will run as fast as the CPU will allow! Drop a Wait (ms) and wire something like 50ms to it and the CPU usage will drop to nearly nothing.
(If you wanted to get really clever, you might want to look at the event structure - instead of polling the values you can configure it so that it only calculates the result when any of the values change which means it will use no CPU at all!)
10-14-2015 01:16 PM
Gentlemen,
Thank you all. With your help I was able to make it function just as I was aiming for. I am just begingin with LabVIEW and little programming experience, so I get extremely thrilled when I can make these programs work! See below:
Thank you Gentlemen!
"I do not think there is any thrill that can go through the human heart like that felt by the inventor as he sees some creation of the brain unfolding to success... such emotions make a man forget food, sleep, friends, love, everything." - Nikola Tesla
10-14-2015 01:21 PM - edited 10-14-2015 01:22 PM
Glad to help.
What you've done here will only run a single loop and then be stopped when the user presses OK. If this is what you want, then have fun.
It could be improved by using the Enable input to the express VI and some other tweaks to allow the user to change input values during run-time.
Thanks are best given in the form of Kudos and Marked Solutions (Unofficial Forum Rules and Guidelines). You received assistance from some top-tier LabVIEW experts here, whom I'm sure would appreciate your gratitude. Marked Solutions help others find this post when they have the same issure and Kudos motivate us all to keep coming back to help!
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'