CST115 Introduction to Computer Programming Lecture 3 Lab

CST-115 Introduction to Computer Programming Lecture 3 - Lab. VIEW Data Types and Constants (Numeric, String, and Boolean) Prof. M. Higazi

What are Data Types? Data Types indicate what objects, inputs, and outputs you can wire together. • You cannot wire together objects with incompatible data types. • For example, you cannot wire a Boolean switch to a numeric indicator. •

Data Types • Lab. VIEW utilizes many common Data Types. • In Lab. VIEW, Data Types are signified by the color of the wiring • The most common Data Types used in Lab. VIEW are: – Numeric (Floating Point) example: 2. 53 – Numeric (Integer) example: 2 – Boolean example: – String example: Hello World

Review of Data Types Found in Lab. VIEW

Numeric Constants • Numeric constants are formed with combinations of the numeric digits (0 -9) and an optional decimal point. • An operational sign (+ or -) may precede the number, but it is optional for positive numbers. • No other characters are allowed in constants, which rules out the use of commas, dollar signs, or percent signs. • Examples of valid numeric constants are: 25 -. 0025 2500. 25 +47 -47. 5 +47. 00

Numeric Constants Cont… • Examples of invalid numeric constants are: 25% (no special symbols are allowed) 1, 250. 50 (no commas are allowed) $1. 25 (no special symbols) 15 (the sign must precede the number)

String Constants • Valid string constants combinations of alphabetic characters, special characters, blank spaces, and numeric digits, some examples are:

Boolean Constants • Boolean is a data type with only two possible values: True or False

In-Class Exercise 1. 2. 3. 4. 5. On the block-diagram, right-click to open the Functions Palette Go to Programming Numeric Select Numeric Constant and drop it on the block diagram Right-click on the Numeric Constant and go to Create Indicator Connect the Numeric Constant to the Indicator as shown below: 6. 7. Observe the Front Panel to verify that 0 is displayed on the Indictor Change the value of the Numeric Constant to 1 and observe on the Front Panel to verify that the change took place Repeats Steps 1 thru 7 using a String Constant (change from Yes to No instead of 0 to 1) Repeats Steps 1 thru 7 using a Boolean Constant (change from T to F instead of 0 to 1) 8. 9.
- Slides: 9