<< Chapter < Page Chapter >> Page >

The selected diagram is highlighted as shown in [link]

An orange box labeled Fahrenheit, with the orange outside line labeled DBL, and containing the value 1.23, is connected to subtract, which is connected to multiply, which is connected to divide. Also connected to subtract is an orange box containing the number 32. Also connected to multiply is an orange box containing the number 5. Also connected to divide is an orange box containing the number 9. Divide is then connected at the end to an orange box labeled celsius, containing the value 1.23. The entire diagram is closely wrapped in a dashed border.
Selected G Block Diagram

From the Edit menu select Create SubVI to create a G function. The resulting diagram is shown in [link] .

A screen capture of a drop-down Edit window with the option, Create SubVI selected.
Creating a Function

From the File menu select Save All and save the Untitled function as Fahrenheit to Celsius.vi .

An orange box labeled Fahrenheit, with the orange outside line labeled DBL, and containing the value 1.23, is connected to a function, which is connected to an orange box labeled celsius, containing the value 1.23.
Diagram with Function

Open the Fahrenheit to Celsius.vi by double clicking on the icon. Right click on the icon editor (upper right corner) and select Edit Icon…

A drop-down menu from the function, with the option, edit icon… selected.
Edit Icon

This pops-up the Icon Editor . Edit the function’s icon.

The icon editor screen. There is a large white box with the large text, Fahr to Celsius. To the left is a palette with options to draw with different colors, fills, and shapes. To the right are smaller boxes replicating the large box, labeled, B and W, 16 colors, and 256 colors.
Icon Editor

After editing the icon, the function’s icon is shown in the upper right corner of the Front Panel window. Save the function, plug in various input values and run the function. Save the function.

A screenshot of a window titled, Fahrenheit to Celsius, with standard window options, and containing the input and output values for fahrenheit and celsius.
Edited Icon

Close the Fahrenheit to Celsius function and return to the Celsius Block Diagram windows. The Celsius diagram reflects the updated Fahrenheit to Celsius icon

An orange box labeled fahrenheit, with the orange outside line labeled DBL, and containing the number 1.23, is connected to a box labeled Fahr to Celsius, which is connected to an orange box labeled celsius, with the orange outside line labeled DBL, and containing the number 1.23.
Function Calling

Case selection

This program determines if a year is a leap year or not. A leap year is divisible by 4 but not by 100, except when it is divisible by 400. A number x is divisible by a number y if the remainder of x/y is identical to zero, i.e. Rem(x/y)=0 is true therefore

Leap Year = { Rem ( Year / 4 ) = 0 And Not ( Rem ( Year / 100 ) = 0 ) } Or Rem ( Year / 400 ) = 0

where And , Or and Not are Boolean operators.

For example:

1900 is not a leap year because it is divisible by 100

1970 is not a leap year because it is not divisible by 4

1980 is a leap year because it is divisible by 4 but not by 100

2000 is a leap year because it is divisible by 400

Start a new G program and right click on the Block Diagram window. Go to the Functions>>Programming>>Numeric menu in the Block Diagram window.

A screen capture of a hierarchical list, beginning with Programming, and continuing with Numeric. Below the list are six shapes containing operations.
Quotient&Remainder Function

Select three copies of the Quotient&Remainder function and three numeric constants. Type in 4, 100 and 400 for the numeric constants and wire these constants to the lower input terminal (corresponding to the dividend) of the Quotient&Remainder function.

A three-part diagram connecting numbers to operations. The first is the number 4 inside a blue box that is connected with a line segment to an operation named quotient and remainder. The second is the number 100 inside a blue box that is connected with a line segment to an operation named quotient and remainder. The third is the number 400 inside a blue box that is connected with a line segment to an operation named quotient and remainder.
Leap Year Numeric Constants

From the Functions>>Programming>>Comparison menu, select 2 copies of the Equal to Zero function and one copy of the Not Equal to Zero function.

A screen capture of a hierarchical list, beginning with Programming, and continuing with Numeric. Below the list are four yellow triangles containing operations, named equal, not equal, equal to 0, not equal to 0.
Comparison Functions

Organize the comparison operations as show in the diagram.

A three-part diagram connecting numbers to operations. The first is the number 4 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. The second is the number 100 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, not equal to 0. The third is the number 400 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. In between the first and second parts is the, and, operator. In between the second and third parts is the, or, operator.

From the Functions>>Programming>>Boolean menu select the AND and OR operators

A screen capture of a hierarchical list, beginning with programming, and continuing with  structures. Below the list are four objects, labeled, for loop, while loop, timed structure, case structure.
Boolean Operators

Place the Boolean operators as shown in [link] .

A three-part diagram connecting numbers to operations. The first is the number 4 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. The second is the number 100 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, not equal to 0. The third is the number 400 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. In between the first and second parts is the, and, operator. In between the second and third parts is the, or, operator.
Q&R, Comparison&Boolean Functions

From the Functions>>Programming>>Structures menu, click on the Case Structure .

A screen capture of a hierarchical list, beginning with programming, and continuing with  structures. Below the list are four objects, labeled, for loop, while loop, timed structure, case structure.
Case Structure

Click and drag on the Block Diagram window to create the Case Structure .

A three-part diagram connecting numbers to operations. The first is the number 4 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. The second is the number 100 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, not equal to 0. The third is the number 400 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. In between the first and second parts is the, and, operator. In between the second and third parts is the, or, operator. To the right of these diagrams is a large dashed rectangle.
Creating a Case Structure

The True diagram option is indicated at the top of the case structure.

A three-part diagram connecting numbers to operations. The first is the number 4 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. The second is the number 100 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, not equal to 0. The third is the number 400 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. In between the first and second parts is the, and, operator. In between the second and third parts is the, or, operator. To the right of these diagrams is a large rectangle, containing a drop-down menu labeled True.
Created Case Structure

Drop a string constant and type “Is a Leap Year”.

A three-part diagram connecting numbers to operations. The first is the number 4 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. The second is the number 100 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, not equal to 0. The third is the number 400 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. In between the first and second parts is the, and, operator. In between the second and third parts is the, or, operator. To the right of these diagrams is a large rectangle, containing a drop-down menu labeled True. Inside the box is a pink rectangle containing the text, Is a Leap Year.
True Case Editing

Click on the down arrowhead next to the True label and select the False option.

A three-part diagram connecting numbers to operations. The first is the number 4 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. The second is the number 100 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, not equal to 0. The third is the number 400 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. In between the first and second parts is the, and, operator. In between the second and third parts is the, or, operator. To the right of these diagrams is a large rectangle, containing a drop-down menu labeled True. The menu has been selected, and the option to select false is highlighted. Inside the box is a pink rectangle containing the text, Is a Leap Year.
Selecting the False Case

Drop another string constant and type “Is not a Leap Year”.

A three-part diagram connecting numbers to operations. The first is the number 4 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. The second is the number 100 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, not equal to 0. The third is the number 400 inside a blue box that is connected with a line segment to an operation named quotient and remainder. To the right of the object is the operator, equal to 0. In between the first and second parts is the, and, operator. In between the second and third parts is the, or, operator. To the right of these diagrams is a large rectangle, containing a drop-down menu labeled False. Inside the box is a pink rectangle containing the text, Is a Leap Year.
False Case Editing

Go to the Front Panel window and place a numeric input and an output string. Re-label the numeric input to Year and the output string to Message .

A screen capture of a window with a grey grid enclosing two input or output boxes, labeled year, and message.
Leap Year GUI

Right click on Year and select Representation>>I32 from the numeric pop-up menu.

Questions & Answers

what is defense mechanism
Chinaza Reply
what is defense mechanisms
Chinaza
I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Introduction to g programming. OpenStax CNX. Mar 15, 2010 Download for free at http://cnx.org/content/col11192/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Introduction to g programming' conversation and receive update notifications?

Ask