In Progranimate, a program may be constructed by interacting either with the flowchart or code views. Unlike in regular programming environments, users do not enter code directly. Programs are constructed from a palette of programming components and structures that the user can select from. Once selected, these component and structures are placed within the program and any associated parameters are defined. Once a component’s or structure’s parameters are defined, the flowchart is redrawn and the code is automatically generated to show the newly added component or structure. Progranimate can create programs in a variety of languages. However, in the examples in this section, we will use the Java and VisualBasic.Net programming languages. For a list of the languages supported by Progranimate, see section 6.1 entitled ‘The Languages Available’.
Clicking the toolbar (or file menu) option marked ‘New’ clears the current program to present the user with a fresh canvas with which to create a program. The user is then prompted to name the new program via a dialogue box that pops up.
Figure 2. Naming a Program
When creating a new program, Progranimate starts by displaying the default starter and termination icons and code. There should also be no data displayed in the variable inspector.
Figure 3. The Default Components and Java Code.
Any components added to the program will be placed between the starter and terminator components. Any variables or arrays declared will be displayed in the code view only, as variable declarations play no part in visualising the logical flow of a program. Progranimate minimises the work performed by the user by automatically managing the layout of flowcharts and code indentation as components are added. This means the user can focus purely on algorithm development rather than wasting valuable learning time fiddling with the intricacies of the visual representation.
-
Figure 4. The Variable Inspector.
Before any meaningful components can be defined, some variables need to be added for the programs to work with. Progranimate allows for the Integer, Double, Char, String and Boolean data types to be used within programs. Some languages may not support all these data types. For example, Visual Basic 6 does not support the Char data type. However, most languages such Java and Visual Basic.Net support all of Progranimate’s data types.
Any defined variables are held and displayed in the variable inspector. This allows variables to be referenced for error checking purposes when defining component or structure parameters. It also displays the changing state of variable data during animation by visualising the effect that program statements can have on the data it contains. Figure 4 shows the variable inspector when Progranimate is set to work with the Java programming language.
Adding Variables,
Figure 5. The variable definition window
To add a variable to the inspector, click on the variable button of the palette. This will cause the variable definition window to pop up where the variable can be defined. Figure 5 shows an example of the variable definition window.
Firstly, the variable’s name must be entered. The name must begin with a lowercase letter and contain only letters, numbers or the underscore character. Next, the variable’s data type must be selected. A drop down list allows the data type to be selected i.e. Int, Double, Char, String and Boolean in the case of Java. If direct value entry is permitted in the advanced settings, an initial value can be entered for the variable. If direct value entry is not permitted, the value field will not be shown and the variable will be set to its default value. See section 3.1.2 for the information on Progranimate’s default values. See section 8.1 for more information on enabling or disabling direct value entry. Once all the needed information has been entered, the ok button should be clicked (or enter key pressed). At this point, the name, data type and value will be validated. If there are problems, an error message will be displayed beneath the relevant field and the user can edit their entry. If all is ok, the definition window will close and the variable will appear in the inspector. Clicking cancel or pressing the escape key will close the definition window without adding a variable.
If desired, quotation marks can be placed around string and char data during entry (double quotes for stings, single quotes for chars). However, this is not mandatory. Whether or not quotes are added, the inspector will display the appropriate quotes around String and Char data in the value field of the inspector.
By default the maximum number of variables allowed is fifty. If a user attempts to add another variable once fifty variables have been defined, they will be presented with an error message. It is possible to increase the maximum number of variables permitted in the advanced settings; see section 8.1 for more information.
Default Variable Values
When no data is entered in the value field of the variable definition window, or direct value entry is turned off in the advanced settings, the value of a variable will be set to its default. The default values for the differing data types are as follows.
-
Data Type
|
Default Value
|
Integer
|
0
|
Double
|
0.0
|
Char
|
Char will contain ASCII char 0
|
String
|
String will contain ASCII char 0
|
Boolean
|
False
|
Table1. The default data types for variables
Deleting Variables
Removing variables from a program is easy; this can be achieved in a multitude of ways, depending on what program settings have been enabled. The main way of deleting a variable is to click the delete button on the palette and then select the variable to be removed either in the code or the inspector. Another way (settings permitting) is to select the variable in the code or inspector and then click the delete button of the palette. It is also possible to achieve this by right clicking the variables declaration in the code view (settings permitting). Doing so makes a popup menu appear where the user can select delete. If a variable is in use within a program, the use is unable to remove it and presented with an appropriate method. Do delete a variable the user must first remove all uses of it. This helps prevent mistakes that may lead to a program error and unnecessary confusion.
Depending on the advanced settings, some of the deletion methods described on this section may be inhibited. See section 8.3 for more details on adjusting the selection methods.
If a variable has been removed in error, the undo option of the edit menu will bring it back providing no other command has been performed in Progranimate.
Editing Variables
A user may want to edit a variable to change its initial value or data type. Editing variables of a program is simple. Like the deletion of variables, it can be achieved in various ways (advanced settings permitting). The simplest way to edit a variable is to double click it either in the code or in the inspector. Another way is to select the edit button from the palette and then the variable in the code or variable inspector. This can also be achieved the other way round by clicking the variable in the code or variable inspector and then the edit option from the palette (settings permitting). All of these methods will cause a pre-filled variable definition window to pop up where the user can edit the variable’s value and data type. When a variable is renamed all instances of the variable in the program (flowchart and code) are also updated.
Depending on the advanced settings, some of the editing methods described in this section may be inhibited. See section 8.3 for more details on adjusting the selection methods.
Share with your friends: |