Example Code

The 8-Ball Fortune Telling VI

Code and Documents

Attachment

Overview

Just for kicks... This VI will answer all your questions in the same fashion as the old 8-ball fortune teller.

Description

This VI uses a state machine with 3 cases to answer your question. Initially, the “Ask” button is visible. When a question is entered and the “Ask” button pressed, the “Ask” button is hidden with a property node. A Random Number (0-1).vi chooses a random index from an array of strings and is displayed as the answer. The “Try Again” button is then visible. When the “Try Again” button is clicked, the VI returns to the first case and you can enter another question.

Steps to Implement or Execute Code

  1. Run the VI
  2. Type a question
  3. Click “Ask.”
  4. Read your answer
  5. Click “Try Again” to ask again or “Stop” to end the VI

Requirements to Run

Software

LabVIEW 8.5 and later

Hardware

None

Additional Images

Front Panel

2013-01-23_143338.png

Block Diagram

2013-01-23_143408.png

Array of Strings that are used as the 8-Ball answers

2013-01-23_143450.png

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors