Contents 0 Introduction 4



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

Arrays





Figure 6. The array inspector

It is possible to include arrays into user programs. The data types permitted by Progranimate’s arrays match those of the variables. All arrays in Progranimate are zero based, even when using languages such as Visual Basic 6, where zero based arrays are not mandatory. Allowing non-standard array element indexing may lead to unnecessary confusion when graduating to other languages.

Any defined arrays will be held and displayed in the array inspector. This allows array elements to be used by component parameters. It also displays the changing state of an array’s elements during animation, showing the effect that a program statement can have on the data it contains. Figure six shows the array inspector with Progranimate set to work in the Java programming language.

When no arrays have been defined, the array inspector will remain invisible; the variable inspector will then take up the entire right side portion of the screen. This means Progranimate is free of unnecessary complication for users who has yet to learn arrays. When one or more arrays have been defined the array inspector will appear, the right side will be split equally between the variable and array inspectors. By placing the mouse pointer between the two inspectors and performing a click and drag, it is possible to change the proportions of the screen devoted to each inspector.


      1. Adding Arrays


To add an array to the array inspector, simply click the button marked array on the component palette. Doing so will cause an array definition window to pop up where an array can be defined and added to the array inspector.

Firstly, the user must enter a name to be used by the array. This must begin with a lowercase letter and contain only alphanumeric characters or the underscore character. It must also be unique, a name not used by other arrays or variables. Secondly, the data type to be used must be selected. This is achieved via the drop down menu. If direct input has been enabled in the settings, the initial values must be entered for the array. Commas must separate values; this allows the size of the array to be automatically calculated. If direct input has been disabled, the value field will not be shown and the user must enter the size of the array instead. In this instance, the array elements are filled with the default values for the selected data type.

O


Figure 7. The array definition window.
nce all the data is entered, the ok button can be clicked or the enter key pressed. This causes the data to be validated. If the data is found to be valid, the definition window will close, and the array will appear in the inspector. Any errors found are presented via a dialog window in plain English; technical jargon has been limited where possible. It is possible to cancel the adding of an array at any time by pressing the cancel button or the escape key. Figure 7 shows the array definition window.

      1. Default Array Values


When no data is entered in the values field of the array definition window, or direct value entry is turned off in the advance settings, the value of an array’s elements will be set to the selected data type’s 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

Table 2. The default data types for Arrays
      1. Deleting Arrays


There are multiple ways a user can delete an array in Progranimate. One way of deleting an array is to select the delete option in the palette and then select the array to be removed, either in the code or on the array inspector. Another way is to select the array first (either in the code or the array inspector) and then to select the delete option from the palette. A third and final way of doing this is to right click the array’s code in the code view. This will cause a small pop up menu to appear, where a delete option is provided. Depending on the advanced settings, some of these deletion methods may be inhibited. See section 8.3 for more details on adjusting the selection methods for deleting.

If an array has been removed in error, an undo option is available in the edit menu.


      1. Editing Arrays


As with variables, there are multiple ways you can edit an array. The first way is to double click it. Another way is to select the edit button from the palette and then click on the array in the code view or the array inspector. A third way is to select the array in the code or the array inspector and then select the edit button from the palette. The final way is to right click edit the array’s declaration in the code view. This should cause a small popup menu to appear where the edit option is provided. When an array is renamed any references to it in the program are also updated.

Depending on the advanced settings, some of these editing methods may be inhibited. See section 8.3 for more details on adjusting the selection methods for editing.




    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