Previously, we have seen how to use a Sequence and activities. We shall now learn how to use a Flowchart. A Flowchart is a container. It can contain activities inside it.
Let us drag and drop a Message box activity inside the Flowchart. Double click on the Message box and type "Hello World!" in the area where the text is to be quoted. Press F5 to see the result):
So, when the program has only a few steps, we can use activities directly inside the Flowchart. However, it becomes more complex when we have a large number of steps. That is why it is necessary to arrange the related activities into Sequences and then group the Sequences into a Flowchart.
Let us take an example to see how to use Sequences in the Flowchart.
Perform the following steps:
- Drag and drop two Flowchart activities on the main Flowchart. Rename them as Send Mail and Message.
We have two different workflows. The Send Mail workflow will send the mail to an email address. The Message workflow has the message body of that email and will ask the user for a name, message, sender, and receiver.
- We have to implement the desired steps in both workflows.
For that, we are using a Sequence inside the Flowchart. Double click on the Flowchart. Drag and drop a Sequence activity inside both Flowcharts. Connect the Sequence to the Start node by right-clicking on the Sequence and selecting the Set as Start node option.
-
Double click on the Sequence in the Message Flowchart. Drag and drop four Input dialog activities for the name, message, sender, and receiver (in this Sequence, we are not going to set any property of the Message box since the purpose of this lesson is to clearly understand where and how we use workflows and Sequences):
- Double click on the Send Mail Flowchart. Double click on the Sequence. You can drag and drop the email activities here. (We are not going to drag any mail activity although you are free to do so. There is another chapter for that).
- That's it. Now, go to the main Flowchart. Connect the Message Flowchart to the Start node. Also, connect the Send Mail activity to the Message Flowchart:
- Run the program and visualize it.