Paradyme V4.0 - Manual |
Tutorial |
To reach this option, the user should select option 5 from the main menu. This option ties together everything that has been entered through the previous 4 options. It ties the required attributes to their required screen positions to their required logic processing. As can be seen this is the most complex part of the system and the user should acquaint themselves thoroughly with the way various parameters can be manipulated through this option.
Let's start with EXAMPLEA as this is the simpler program. This will gently lead the user into this section.
This routine updates the file F.ITEMS. Therefore, the first input on the screen is the shorthand code for this file i.e. EG2. The second prompt in this definition screen will allow the user to define the prompt at which the system will be able to access the record that we wish to process from the F.ITEMS file. Hence the value for PROMPT NO OF KEY will be 2.
The next section defines the prompts. There are 4 prompts in this routine. The first is the date, which is displayed in the top right hand corner. This is defined as a 'V' type variable as the date will be obtained by using the 'variable' DATE(). The next prompt is the key, let's call this ID. This is a 'S' type variable. It will have a check file of EG2 as we will check the input against the F.ITEMS file. We will be using a conversion of 'ZFI' which means the system will be expecting an integer input. If it gets one, it will then pad it out with zeros. If it does not get an integer input it will print an error message and ask the user to re-input the value.
The next prompt defines DESCRIPTION which again is a 'S' type prompt. This is because it is used to define a single value input that will be used to update the main file.
The final prompt is UNIT.COST. Again this is a 'S' type as it is a single value input that will be used to update the main file. Note that the conversion of 'MD2' is automatically defaulted from the EG2 file layout record. These are the only inputs required for this routine and at the end of the inputs, the screen should look as follows.

Once this screen has been setup you can now try setting up the EXAMPLE program which is somewhat more complicated.
EXAMPLE, the main demo program, consists of updating the main file F.BOOKINGS. This is declared by putting the file reference, EG1, in the first entry. After this the KEY PROMPT NO is required. This is calculated as follows :-
The user needs a definition for the date which will be prompt number 1. Next the user requires to display the mode. This will be number 2. Neither of these are connected to the file and are defined as 'V' (variable) types. Next the user must define the ROOM code. This is number 3. It is not until the DATE REQUIRED is entered that the user will have the information required to access the required record. This is prompt number 4 and so PROMPT NO OF KEY takes the value 4.
Note that PICK employs a random access file mechanism. As such it requires that EVERY record in a file MUST have a unique reference. This reference may be meaningful as in this case or it may just be a sequentially allocated number. Note that PARADYME provides the 'GN' conversions to automatically generate unique sequential numbers should this be required.
This takes us into the prompt definition window. The first line defines the DATE which is tied to display position 1. Following this is the display of the PARADYME variable MODE$ at position 2. Both of these are variables and therefore are defined as V type prompts.
Following this the user defines the prompt for ROOM.CODE which is tied to position 3. Then DATE.REQUIRED is defined. This is tied to position 4. Both are single values which refer to data contained in the update file key. Hence they are defined as 'S' types. Furthermore, DATE.REQUIRED also has EG1 defined for the CHECK FILE. This is validated by the system to ensure that the final key element is where the user has specified. At this point the system would access the record using the key defined by these 2 prompts.
The 5th prompt defines the PERSON'S NAME. Again this is a single value input and is therefore defined as a 'S' type.
At this stage we must define the window that will allow input of the item codes. On entering 'W', the user will be dropped into the multi value prompt definition screen. Before we go into this area the screen display should be as follows.

In the window definition, the first field defines the ITEM CODE. This is defined as an 'S' type. Although the field is multi-valued, implying that several values may be input for the field, only a SINGLE definition is required in the prompt definitions to specify this field and that is why the prompt is an 'S' type. ITEM CODE also has EG2 entered for CHECK FILE.
Next the user specifies a display of the DESCRIPTION and UNIT.COST from the record on the F.ITEMS file. These become prompts 2 and 3 in this window. They are both 'D' types as they are displayed off the check file. The result of these prompt entries is that the system will accept an input for ITEM.CODE and check it against the F.ITEMS file. If it is present it will then display DESCRIPTION and UNIT.COST next to ITEM.CODE and then proceed to the next prompt.
The next prompt allows input of UNITS, which is a field on the main record. This means that it is defined as a 'S' type prompt. Next, the system will display COST off the main record. This makes it an 'N' type prompt as NO input is required. Once all of these have been entered, the screen will look as follows.

The final prompt will total the COST values displaying the sum. This can be done by defining the special 'V' type expression SUM ABOVE$.
Because the system does not generate COST automatically, a little bit of code needs to be inserted to do this. This is handled in the INSERT ITEM section.
Go to the PROMPT SEQ input and enter 4. This is because we are associating the inserted code with the routine which handles the input of UNITS, which is the 4th prompt defined. In the next entry, type 'AV' for INSERT CODE. This will insert the code into that part of the generated routine AFTER it has been input and VALIDATED UNITS as correct. At INSERT ITEM hit the invert key and press [RETURN] to the item name prompt. You should now be in the system editor editing the item I1_EXAMPLE in the file BP.
The code that is inserted will be required to update the cost value associated with the current line being input, by multiplying the number of units just entered by the unit cost. Thus the code that is inserted must update the main record, R.BOOKINGS, which has already been accessed.
The attribute COST, which is already defined, will have the data value indexed by the number held in the PARADYME variable VMC$, updated with the COST amount. The COST amount is given by multiplying the value just entered, which is contained in the variable VALUE$, by the value of the attribute EG2.UNIT.COST. EG2.UNIT.COST is already defined and indicates the attribute in the record R.ITEMS, which has just been accessed as a result of the check file logic. This record contains the item UNIT.COST. The rest of the logic deals with rounding the resulting value to 2 decimal places.
The actual program logic to carry all this out is as follows:-
I
* Calculate cost
R.BOOKINGS<COST,VMC$>=INT( ( VALUE$*R.ITEMS<EG2.UNIT.COST> / 100 ) + 0.5 )
[Carriage Return]
FI
Note that the text in bold are editor commands and will not appear in the insert item. After typing the calculation line in, the system will prompt the user for more input. By entering [RETURN], they will be prompted for the next EDITOR command.
After entering 'FI', press [RETURN] at the next prompt. This should take you back to the prompt definition screen with the ITEM NAME filled in. This is all the extra code you need for this screen.
The only remaining bits to fill in are WINDOW LENGTH which should be set to 4 as there are 4 lines displayed at any one time in the window. Set WINDOW WIDTH to 5. After this is all done the screen should look as follows.

Enter Y at the O.K. prompt and the user will be taken back to the single field definition screen.
We are back in the single value input definition screen. We have two more single values to define. These are DISCOUNT.PCT, which is defined as a 'S' type and has a conversion of 'MD2' which is automatically inserted for the user from the defined file layout. The last prompt is a 'S' type which is PAYMENT.METHOD.
We will now add a bit of validation. This can be done in the window below the prompt definition window. Let us assume that a maximum discount of 25% is permitted and we wish to prevent the user entering a value higher than this. The test needs to be linked with the prompt definition for DISCOUNT.PCT which is the 7th prompt definition, so we enter 7 for PROMPT SEQ. Next is the validation code. The following should be entered.
VALUE$ GT 2500
Note that the value we test against is 2500 and not as might be supposed, 25. This is because VALUE$ will have already been converted to internal "MD2" format by the system and thus 25 becomes 2500.
For MSG NO, enter 1. We will be looking at the error message entry screen in the next chapter but note that it can be reached from this screen by hitting the invert key. There are no inputs required for insert items in this screen hence by the time the user is prompted by the O.K. the screen should look as follows.

While running through this option try using the various functions that are available at some of the prompts, usually called up by hitting the invert key.
Use the BACK BUTTON to return to the previous page