Contents 0 Introduction 4


Adding Components or Structures



Download 383.54 Kb.
Page5/9
Date05.08.2017
Size383.54 Kb.
#26674
1   2   3   4   5   6   7   8   9

Adding Components or Structures


To add a component to the program, the user must first select a component from the palette. To select the intended location of the new component, mouse click on an existing flowchart component, a valid vertical line of flow, or a line of code in the code view. A definition window then pops up; this is where the expression to be used with the component is defined. See section 3.4 for more information on defining component and structures. Once defined, the component is automatically inserted into the flowchart and code below the selected component or code line, or on the selected vertical line of flow. The code and the flowchart views are synchronised; adding a component to the flowchart view will cause the code view to update appropriately and visa versa. Figure 4 below demonstrates a program being constructed from the default components of a blank program. The highlighted components show where the mouse clicks were made.



Figure 8. Adding Components

Below is a description of how a user may transition from the initial to the final state of figure 8. This process was achieved in three simple steps described below.



Stage 1: An integer called x with the value 1 is added to the inspector. The Print option is then selected in the palette. The start component is selected, causing a definition window to pop up. In the definition window, the value x is entered. This will cause the value of variable x to be printed at run time. The OK button is clicked, and the Print component is then added to the program in both the code and flowchart views.

Stage 2: The If option of the palette is selected; then the print component is clicked on in either the code or flowchart view. The Boolean expression to be associated with the IF structure is then defined, in this case X > 1. Once ‘OK’ is clicked on, the definition window disappears, and the IF structure is added to the program in both code and flowchart views.

Stage 3: The assign option is selected in the palette. The If component is then clicked on in either the code or flowchart views. This causes the definition window to pop up, where the expression to be associated with an assign statement is entered. In this case, the assignment expression X = 1 is entered. Once ‘OK’ is clicked, the assignment statement is added to the code, and an assignment component is added to the flowchart. The final state of the program is shown in image 4 of figure eight.

For more information on defining components, see sections 3.5 ‘Defining Structures and Components’ and 3.9 ‘The Components and Structures in Detail’.


    1. Nesting Structures





Figure 9. An example of the nesting possibilities.

In Progranimate it is possible to nest the If, If_Else, While and For control structures to infinitesimal levels, in any valid combination. The method for adding structures within structures is no different from the method for adding a standard component within a structure. It is also possible to cut an entire structure, including its components and sub-structures for pasting within another structure. This ability makes Progranimate capable of handling a very large number of programming problems, increasing the complexity of the programs it can model and thus its educational scope. Figure 9 demonstrates the structure nesting abilities of Progranimate using the VisualBasic.Net language.



    1. Defining Components and Structures


W


Figure 10. The assignment definition window.
hen a component or structure is selected from the palette and its location is selected within the flowchart or code views, a component definition window pops up. This definition window is where the expression to be associated with the component or structure to be added is defined. Each component has its own dedicated definition window. All definition windows look similar, except for subtle differences in the descriptive text contained within them.

Figure 10 shows the definition window associated with the assignment component. In this example an incremental statement has been entered. If the user is defining a structure such as an If or While loop then they only need enter the argument to be associated with that structure i.e. x <= 100. Once ok is clicked the rest is taken care of. Once definition window that does vary on the standard is the definition window for a For loop, this will be discussed further in section 3.9. The syntax of parameters entered into the definition window depends on the language selected. For information relating to the definition of each component or structure, see section 3.9 ‘The Components and Structures in Detail’, where this is discussed in detail.

If an error is encountered during the definition of a component the an error message will appear in read beneath the textbox where the error exists.

Each definition window comes with two short cut buttons for adding variables and arrays. These perform the same function as the Variable and Array buttons of the palette. They allow variables or arrays to be added without the need to close the definition window.


    1. Deleting Components and Structures


There are multiple ways to remove a component or structure from a program. One way is to select ‘delete’ from the palette and then select the component or structure to be removed in either the code or flowchart view. Another way is to do this in reverse by first selecting the component or structure and then the delete option of the palette (advance settings permitting). A component or structure can also be removed by right clicking it in either of the two program views. A popup menu will appear, and the delete option can be selected from it. This will remove the component that clicked upon. Depending on the advanced setting, some of these methods may be disabled. For more information on setting the selection methods, see section 8.3.

When a component is removed, both the flowchart and the code representations of a program are updated in a tidy manner with no adjustment needed by the user. When a structure such as an If, If_Else or While is removed, all internal components and sub structures are also removed. The diagram and code is then redrawn tidily with no adjustment needed by the user. If a component or structure has been removed in error, an undo option is available in the edit menu.




    1. Download 383.54 Kb.

      Share with your friends:
1   2   3   4   5   6   7   8   9




The database is protected by copyright ©ininet.org 2024
send message

    Main page