From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect string constant to true/false boolean

Solved!
Go to solution

Hello.

 

I am having trouble trying to figure out how to connect a string constant to a result from a true/false function. I am creating a VI that creates a random number, then has the user enter a number in the numeric control . These 2 numbers are compared and if the user's number is smaller, I want a string constant to display "too small." If the user's number is equal I want the string constant to display "correct" and if the number is bigger, the constant will display "too large."

 

This is a picture of what I am doing, but notice I did not insert the string constants for "too large" and "too small" yet, as I am still trying to figure out how to connect the string constant to this.

 

Thanks for any help.

 

labview 11111.png

0 Kudos
Message 1 of 31
(6,774 Views)

Set up a boolean array from your three conditions.  Convert the array to a number and put that number in a case statement that will generate your text strings.

0 Kudos
Message 2 of 31
(6,764 Views)

I'm sorry I barely learned this software for a week. My class isn't even teaching this, we are supposed to watch a video at home and be expected to learn this already when we show up to class.

 

Are you saying to ditch the t/f functions and convert them from array to number and put these in a case structure?

0 Kudos
Message 3 of 31
(6,759 Views)

There's a lot of ways to do what you're looking to do.

 

Ultimately, I'm going to guess you want to allow the user to continue trying to guess.  Is that correct?  If so, you're going to want to have a while loop at some point.

 

You want to run two comparisons.  It must be either too small, too large, or equal.  If it's not the first two, it must be the third.

 

What are you hoping to do with the selects? That just selects one of the two inputs.

 

If you merge them all into a logical operation, you're going to get strange results.

 

Take a step back from the code.  Right now, you're going to confuse yourself a bit with the code.  You need an algorithm first.  Use real words to explain what you want to do.  As an example:

 

Create random number in the range of 1-10.

Accept user input

...

Output result to user.

 

Once you have that algorithm, it will be easier for everyone, yourself included, to help your code progress.

0 Kudos
Message 4 of 31
(6,735 Views)

Yes you are correct, I will be putting this in a while loop to have the user keep guessing.

 

I am sorry I do not know what to do clearly. The video shown just taught us what loops do, we were not introduced to multiple true/false things.

 

All I want to do is have the user guess the number, while this operation is held in a while loop. I will actually make 3 while loops I guess because the example I showed is only for 1 of them. I need to do 2 more just like that, but I'm sure if I can do one i can do multiple algorithms of this kind.

0 Kudos
Message 5 of 31
(6,716 Views)

This is my algorithm,

 

Create random number in the range of 1-6.

Accept user input

 

Output result

 

compare random number result to user's input

 

If user's input # is smaller, show string constant saying "too small."

 

If user's input # is bigger, show string constant saying "too big."

 

If user's input # is equal, show string constant saying "correct."

 

 

There will be one string constant shown to the user, where it says "too small" "too big" or "correct."

0 Kudos
Message 6 of 31
(6,711 Views)

My apologies as I have probably barely any knowledge on this software. I am very displeased by this class and I will be sure to write a complaint e-mail to the teacher assistant. I do not like doing an assignment on something I am not introduced to.

0 Kudos
Message 7 of 31
(6,710 Views)

There's a thousand ways to do this. Here's a simple way using local variables.student11 example.png

0 Kudos
Message 8 of 31
(6,672 Views)

@RRogers92 wrote:

There's a thousand ways to do this. Here's a simple way using local variables.student11 example.png


1000 ways except this one?  Isn't there going to be a race condition because all of those cases are going to execute and overwrite each other?  (Your assertion that "if false, nothing will happen" is not correct.  "If false, an empty string will be written (or whatever is in the string constant that looks like an empty string).)"

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 9 of 31
(6,659 Views)

You are correct Bill, I apologize for the error. I obviously didn't even look at the code twice. Please ignore my first post.

0 Kudos
Message 10 of 31
(6,647 Views)