Pseudocode flow charts

Visustin creates flow charts from pseudocode. Pseudo-code is a sort of a "natural language". It looks like English to humans and like a programming language to the computer. It can be used to write plans and describe functionality before actually writing them.

Any programming language can be used for pseudocoding. You can write pseudocode in your usual programming language. As long as you follow the fundamental syntax of the language, especially punctuation, Visustin will flowchart it. Try it! It's easy. Visustin is really flexible in what it accepts as pseudocode. If it remotely looks like the programming language in question, you will get a flow chart.

BASIC as pseudolanguage

The BASIC programming language is particularly well-suited for pseudocoding. It is quite close to English and there are not too many syntax rules to follow. With the help of a few keywords you can write pseudocode that is easily read by both programmers and non-programmers.

The BASIC pseudocode keywords are: If, Then, Else, End If and Do, While, Until, Loop. The following examples work in the Visual Basic mode of Visustin.

Sample recipe

If you are hungry Then eat

If you want tea Then
  Drink tea
Else
  If you want coffee Then
    Drink coffee
  Else
    No drink
  End If
End If

Decisions

Decisions are the heart of flow charts. When a condition is met, you execute an action. The condition is between the keywords If and Then and the action follows. A simple decision looks like this:

If condition Then do this
If you are hungry Then eat

In this example the condition is "you are hungry" and the action is "eat".

At times, you need another action to take place when the condition is not met. You can have this with the Else keyword. The alternative action comes after it. In the example below, "go shopping" is the alternative action.

If condition Then do this Else do that
If you are hungry Then eat Else go shopping

To write more complex recipes, you need to write them on several lines. Instead of writing everything on one line, split the recipe so that each action is on its own line. Use End If to mark where a decision block ends (the end of the area the condition affects). In the below example, you either eat or go shopping depending on whether you're hungry or not. After eating or shopping, you sleep.

If you are hungry Then
  Eat.
Else
  Go shopping.
End If
Sleep.

You can also nest conditions. This means you have more than just one condition before an action takes place. Take a look at the following recipe:

If you are hungry Then
  If you have food Then
    Eat.        <-- Happens when you're hungry AND have food
  Else
    Get food.   <-- Happens when you're hungry BUT have no food
    Eat.
  End If
Else
  Go shopping.  <-- Happens when you're not hungry.
                    Having food makes no difference.
End If
Sleep.          <-- After eating or shopping, you sleep

Repeating things until something happens

Making tea
Boil water
Do Until water is boiling
  Sit and wait
Loop
Put teabag into water
Do While tea is too hot 
  wait until it cools down
Loop
Drink
If tea tastes bad Then make coffee

The Do Until keywords repeat the actions on the followings lines until the given condition is met. You put the condition immediately after the Until keyword. The Loop keyword marks the end of what should be repeated.

Do While works exactly the same, but it repeats while the the given condition is met.

Miscellaneous

To make a stop, use either End or Stop.

Note that some markup has a specific meaning in the BASIC programming language, and Visustin will respect that. Avoid using the apostrophe (') in text as it starts a comment. Keywords are not case sensitive. Then, THEN and then are all equal.

©Aivosto OyVisustin Help