Understanding the Scrolling System [ HP ALLBASE/4GL Developer Self-Paced Training Guide ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Self-Paced Training Guide
Understanding the Scrolling System
The product_scrn data screen has a scroll area on it. This lesson shows
you how to scroll data in this area.
The scrolling system for this application operates as follows. The first
time the user presses the Scroll Options function key, the scroll area is
cleared and the first option record for the current product is read and
displayed in the scroll area. As the user continues to press the Scroll
Options function key, subsequent option records for the current product
are scrolled onto the screen. To do this, the application must maintain
a file pointer to the current scroll record so the next record to be
scrolled can be easily obtained.
Task 1 - Creating Seconday File Record Layouts
The application scrolls records from a file which is also being used for
the creation or modification of specific records. This requires the
maintenance of a work buffer as well as the buffer being used to read
records from the file. For KSAM based applications and HP TurboIMAGE/iX
based applications, this is achieved by defining a second record layout
for the file.
For HP ALLBASE/SQL based applications, tables do not permit multiple
record layouts, so the same scrolling system cannot be used. However,
you can use a select list to perform the same function as a secondary
record layout for a file or table. Using a select list allows you to
open a second cursor to retrieve option records without affecting any
currently open cursors.
If you are developing the KSAM based or HP TurboIMAGE/iX based
application, read on. If you are developing the HP ALLBASE/SQL based
application, turn to the section HP ALLBASE/SQL Select Lists.
Using two record layouts for the one data file allows you to use two
separate file record buffers. This means the application can read and
use two different records from the same data file. Using a second record
layout with a file does not make any change to the structure of the
records in the physical file. The structure of the records in the
physical file is always determined by the structure of the default record
layout for the file. Secondary record layouts simply provide a means of
reading or writing records through different file record buffers.
The structure of a secondary record layout for a file does not need to be
identical to the default record layout. If required, you can obtain a
different "view" of a file record by reading it through a secondary
record layout defined with different field specifications.
In this application, both record layouts for the option file have exactly
the same structure.
To create a secondary record layout:
1. Use the utilities copying function to copy the existing option
record layout to a new layout called option_scroll.
2. Remember to generate the record layout after you have copied it.
3. Modify the existing option file definition by adding the new
option_scroll record layout to the list of record layouts as the
second layout, using the file/SQL table definition screen.
The default record layout is still the option record layout.
All references to the option file so far have named only the file, with
no record layout specifier. In this form the default record layout is
always used, so the existing code remains unchanged.
The next section describes the system HP ALLBASE/SQL based applications
use to maintain multiple buffers. Skip this section, and turn to "Task 2
- Creating the Scrolling Functions."
Creating HP ALLBASE/SQL Select Lists
You can think of a select list as being a "virtual" file. A select list
consists of columns, just like an HP ALLBASE/SQL table. The columns of a
select list can be derived from one or more base tables or views. The
values in a select list column can be taken directly from a column in an
existing table or view, or can be values derived in any of the following
ways:
* Values computed from a base table column using an arithmetic
expression.
* Values computed from the values in various base table columns
using an arithmetic expression.
* Values computed from a group of base table column values with an
aggregate function (AVG, MAX, MIN, SUM, and COUNT).
* Constants, or values computed from an expression involving
constants.
Defining a Select List.
Defining a select list is similar to defining many other items. You must
define a select list header, then complete the details for the select
list, and finally generate the select list.
Each entry in a select list definition has the following format:
field_specification [ = column_definition]
The field_specification must be the name of a dictionary field
specification. The term column_definition means any valid SQL column
definition. You can use SQL aggregate functions and expressions in the
column definitions for SQL select lists. Note that you must terminate
each column definition except the last with a comma (,). Each column
definition does not necessarily need to be on a separate line of the
screen. You can put more than one column definition on the same line.
To abbreviate the entry of select lists, you can omit the right hand side
of each entry if the column definition is exactly the same as the field
specification name, and no ambiguity results from the omission.
This part of the application uses a select list called optscrol. It uses
the option_no, description, cost, quantity, and unit_measure fields from
the option table. These fields contain the information necessary to
scroll the option details on the screen.
The screens you use to define select lists are accessible from the
database items menu in the dictionary menu.
To access the Select List Screen:
1. From the main menu, select the Dictionary option.
2. Select the Database Items option.
3. Choose SQL Select List Header.
This screen is similar in appearance and operation to the other header
screens.
To define a select list:
1. Go to the Select List Header screen and define a header for the
optscrol select list.
2. When you have defined the select list header, go to the Select
List Details screen to define the details for the select list, as
shown below.
This screen contains a free-format data entry area that allows you
to enter the details for a select list.
3. Define the select list as follows:
option_no,
description,
cost,
quantity,
unit_measure
This select list is equivalent to the following expanded
expression.
option_no = option_no,
description = description,
cost = cost,
quantity = quantity,
unit_measure = unit_measure
In this example, the column definitions for the select list are
exactly the same as the field specification names, so you can omit
the right hand side of each item.
SQL Select List Details
Generating a Select List.
You must generate a select list to convert the definition to an
executable run-time format.
To generate the select list:
1. When you have completed the select list details, press the Commit
Data function key.
2. Then press the Generate List function key to generate the select
list.
During generation, HP ALLBASE/4GL uses the field specification names on
the left hand side of each select list column definition to create and
generate a record layout for the select list.
Since generating a select list builds a record layout, a select list
cannot have the same name as an existing record layout. It also cannot
have the same name as an existing file or base table.
Task 2 - Creating The Scrolling Functions
You can now create the functions that scroll data on the screen. You do
this by defining the logic commands for the function.
Function - scroll_options
Pressing the Scroll Options function key executes the scroll_options
function. This function calls two further functions to retrieve the
first and subsequent option records for the current product.
The function is almost the same for all three data managers. The only
difference is the first line, which defines the name of the file.
To define the scrolling function logic:
1. To define the first line of logic for KSAM based and HP
TurboIMAGE/iX based applications, enter the following:
1 DEFINE %FILE% option.option_scroll
or
2. To define the first line of logic for HP ALLBASE/SQL based
applications, enter the following:
1 DEFINE %FILE% optscrol
Independent of the data manager you are using, the rest of the
function is as shown below.
3. To create the rest of the function, enter the lines below:
1 ...
2 IF V-product_status <> C-record THEN
MESSAGE no_product; EXIT
3 IF 1 *ON THEN VISIT get_1st_option; ENTER 7
ELSE VISIT get_next_option
4 IF 1 *OFF THEN ENTER 7
5 SCROLL 9 "***** End of Options for Product #"
S-product_no.product_scrn "*****"
6 EXIT
7 SCROLL 6 F-option_no.%FILE% 4 F-description.%FILE%
5 F-cost.%FILE% 6 F-quantity.%FILE% 1 F-unit_measure.%FILE%
8 EXIT
The scroll_options function operates as follows.
Line 1 This step introduces the DEFINE command. The
DEFINE command creates an identifier that is
expanded whenever it is referenced in the logic
block. The identifier in this case is %FILE%.
It is expanded to option.option_scroll every time
it is referenced, for KSAM based and HP
TurboIMAGE/iX based applications.
For HP ALLBASE/SQL based applications, it is
expanded to optscrol every time it is referenced.
As the file specifier is quite long, using the
identifier simplifies the entry of commands. Any
DEFINE commands must precede the other commands in
a logic block. You can have more than one DEFINE
command at the start of a logic block.
Line 2 This step checks to ensure that a product record is
current. If there is no current product record,
this step displays a message and the function
exits.
Line 3 An earlier function (for example, product_key_read)
may set user switch number 1 on. This step checks
the status of the switch. If the switch is on, no
previous option has been read for this product so
it is necessary to retrieve the first option for
the product. The function get_1st_option reads the
first option record. When the get_1st_option
function exits, control passes to step 7 of this
function. Steps 4 to 6 are not executed if an
option has not yet been retrieved.
If user switch 1 is off, an option has already been
read for this product and the next one must be
retrieved. The function get_next_option reads the
next option record.
A clue to entering this command in the IF window:
enter *ON in the IF Test field, and leave the Data
Name 2 field blank.
Line 4 This step is only executed after a previous option
has been read for this product. The function
get_next_option sets user switch 1 on if no more
options for the product are found. If the switch
is off, a record has been found and control passes
to step 7 where the data is scrolled on the screen.
Line 5 This SCROLL command is executed when the last of
the options has been found. The SCROLL command
takes the specified parameters and concatenates
them to form a line of text that is displayed in
the scroll area. Any lines already displayed in
the scroll area are moved one line in the defined
scroll direction and the new line of text is
displayed on the first line of the scroll area.
The first SCROLL parameter is 9. This is displayed
as a string of nine spaces so the second SCROLL
parameter, a text literal, is preceded by nine
spaces. The third SCROLL parameter is a screen
field and the last SCROLL parameter is a concluding
literal. Separate the parameters with spaces when
you enter the command.
Line 6 The function exits at this point if all the options
have been scrolled.
Line 7 This is the step that actually scrolls the option
data on the screen.
This step shows the use of the identifier %FILE%
that was defined in step 1. For example, the
parameter:
F-option_no.%FILE%
is expanded to read:
F-option_no.option.option_scroll
for KSAM based applications and HP TurboIMAGE/iX
based applications,
or
F-option_no.optscrol
for HP ALLBASE/SQL based applications.
In the SCROLL command, each of the file fields is
separated by a number of spaces so they are aligned
with the column headings painted on the screen.
Line 8 The function exits at this point after scrolling
the details of an option record.
Creating the Functions Called from the scroll_options function.
The next step is to create the two functions that are called from the
scroll_options function. These functions differ slightly between data
managers.
* If you are developing the KSAM based application, continue reading
below.
* If you are developing the HP ALLBASE/SQL based application, turn
to HP ALLBASE/SQL Based Applications for details about the
get_1st_option and get_next_option functions.
* If you are developing the HP TurboIMAGE/iX based application, turn
to HP TurboIMAGE/iX Based Applications for details about the
get_1st_option and get_next_option functions.
KSAM Based Applications
Function - get_1st_option
The next function that you need to create is the get_1st_option function.
This function is called by the scroll_options function to retrieve the
first option record for the current product. Since the processing rules
for this application require that each product must have at least one
option (number 000), this function should always retrieve an option
record. Failure to find a record indicates a serious file problem.
To create the get_1st_option function:
1. Create the function, using the logic commands shown here.
2. When finished, generate the function.
1 DEFINE %FILE% option.option_scroll
2 DISPLAY *RESET=S ""
3 FILE *FIND %FILE% *KEY= F-product_no.product ; ENTER 9
4 FILE *NEXT %FILE%
5 IF F-product_no.%FILE% <> F-product_no.product
THEN ENTER 9
6 SCROLL 9 "***** Start of Options for Product #"
S-product_no.product_scrn "*****"
7 OFF 1
8 EXIT
9 MESSAGE prod_corrupt
10 PROCEED main; NOTE Product/option record corrupted
because option 000 does not exist. Clear buffers and display
the main menu so the user can delete the product.
The get_1st_option function operates as follows:
Line 1 This step uses the DEFINE command to create an
identifier that is expanded whenever it is
referenced in the logic block.
Line 2 The DISPLAY command is another command used to
manipulate the scroll area on a screen. It
displays a line of data on a specific line in the
scroll area. The *RESET=S option clears the scroll
area. The empty parameter ("") specifies that
nothing is displayed on the first line of the
scroll area.
Lines 3, 4 and 5 These steps search for a record with a key matching
or greater than the value specified, retrieve the
record, and test to check whether the record
retrieved has the correct product number.
The FILE *FIND command searches a file for a record
with a key greater than or equal to the value
specified. As the option_key field in this
application is the concatenation of the product_no
and the option_no fields, a search with the key
equal to the product number finds the first option
for that product. If no suitable record is found,
control passes to step 9.
The FIND command does not read the record contents
into the file buffer. It simply positions a file
pointer to the record. You must use a FILE *NEXT
command to read the record into the file record
buffer.
Since the FILE *FIND command searches for a key
value equal to or greater than the specified key,
it may find a record with a greater product number
than the one specified in step 3.
Step 5 checks to see if the record retrieved by
step 4 has the correct value in the product number
field. If the value in the product number field
does not match the current product number, control
passes to step 9.
Line 6 The SCROLL command scrolls a heading line in the
scroll area.
Line 7 This command sets user switch number 1 to off. The
calling function (scroll_options) tests the status
of this switch when the user next presses the
Scroll Options function key. If this switch is
off, the next option is retrieved.
Line 8 The function exits.
Line 9 Control only passes to this step if an option
record for the product has not been found. Failure
to find an option record means that the record for
option 000 does not exist, suggesting that the
product or option file is corrupted. This
condition is detected if an error occurs in step 3,
or the product number in the record retrieved from
the file is not the current product number. This
step displays a message telling the user that
records may be corrupted.
Line 10 This step demonstrates a method for recovering from
a potentially serious problem. The PROCEED command
in this step immediately terminates any current
activity in the application, clears the file and
screen buffers, and closes all data files.
The NOTE command allows you to describe individual
lines within a logic block. HP ALLBASE/4GL ignores
all the text following a NOTE command.
The process main displays the menu main to allow
the user to delete or correct the corrupted record.
Once you have defined and generated the function, create the message and
the process required by the function. These are described below.
To create the messages:
1. Make the entries shown for each message.
a. Message - prod_corrupt
Name prod_corrupt
Type WARN
Contents "Product record may be corrupted. "
"Delete and enter again."
b. Process - main
The get_1st_option function calls the main process if the
product record is corrupted. This process clears all file
and screen buffers and then displays the main menu. The
user can then select another operation from the menu to
delete the product or correct the problem. The process is
a simple one. The SCREEN command calls the main menu.
1 SCREEN main
Creating the last Function.
Function - get_next_option
The last function to create is the get_next_option function. This
function is called by the scroll_options function to retrieve the second
and subsequent options for the current product.
To create the get_next_option function:
1. Enter the logic commands shown below.
1 DEFINE %FILE% option.option_scroll
2 FILE *READ %FILE% ; ENTER 7
3 FILE *NEXT %FILE% ; ENTER 5
4 IF F-product_no.%FILE% = F-product_no.product THEN EXIT
5 ON 1
6 EXIT
7 ON 1
8 VISIT get_1st_option
9 EXIT
2. Generate the function.
This function operates as shown below.
Line 1 This defines an abbreviation for the
option.option_scroll reference.
Line 2 Between the time of the scrolling of the last
record and the current scroll request, the user may
have read the option file via the default buffer.
This will not directly affect the data in the
second buffer but it may affect the file pointer.
This step relocates the file pointer by reading the
file for the contents of the current scroll record
buffer. However, this step will fail if the last
scrolled record has been deleted. Control passes
to step 7 if this situation occurs.
Line 3 This next record is retrieved from the file.
Line 4 This step tests the new record to ensure that it
refers to the correct product by testing the value
in the product_no field. If the retrieved value is
correct, the function exits with the next option
details in the correct buffer.
Line 5 This step sets user switch number 1 on if the end
of the file is reached in step 3, or the product
number changes as determined in step 4. This
indicates to the calling function that the last
option for the product has been found.
Line 6 The function exits.
Line 7 This step and the next step are only executed if
the original record is not found again in step 2.
This step sets switch number 1 on.
Line 8 This step attempts to locate the first option for
the product by visiting the function get_1st_option
again. The return from this step is the same as if
the calling function visited get_1st_option
directly.
Line 9 The function exits.
These functions complete the processing required for a fail safe
scrolling mechanism.
You cannot test any of your screens or functions yet. At the end of the
next chapter all the logic for the application will exist, and you can
then see the scrolling functions in action.
Turn to the summary of this lesson.
Creating HP ALLBASE/SQL Functions.
Function - get_1st_option
The next function that you need to create is the get_1st_option function.
This function is called by the scroll_options function to retrieve the
first option record for the current product. Since the processing rules
for this application require that each product must have at least one
option (number 000) this function should always retrieve an option
record. Failure to find a record indicates a serious file problem.
To create the get_1st_option function:
1. Enter the logic commands shown below.
1 DEFINE %FILE% optscrol
2 DISPLAY *RESET=S ""
3 SQL get_optscrol
4 FILE *NEXT %FILE% ; ENTER 9
5 IF F-option_no.%FILE% <> N-zero THEN ENTER 9
6 SCROLL 9 "***** Start of Options for Product #
" S-product_no.product_scrn " *****"
7 OFF 1
8 EXIT
9 MESSAGE prod_corrupt
10 PROCEED main ; NOTE Product/option records corrupted
since option 000 does not exist. Clear buffers and display
main menu so user can delete the product.
2. Generate the function.
The get_1st_option function operates as follows:
Line 1 This step uses the DEFINE command to create an
identifier that is expanded whenever it is
referenced in the logic block.
Line 2 The DISPLAY command is another command used to
manipulate the scroll area on a screen. It
displays a line of data on a specific line in the
scroll area. The *RESET=S option clears the scroll
area. The empty parameter ("") specifies that
nothing is displayed on the first line of the
scroll area.
Lines 3, 4 and 5 These steps search for a record with a key matching
or greater than the value specified, retrieve the
record, and test to check whether the record
retrieved has the correct product number.
This function calls the SQL logic block
get_optscrol, which you will create soon. This SQL
logic block retrieves the options for the current
product. This select command declares and opens a
cursor on the optscrol select list. The active set
for this cursor consists of all the option records
for the current product. The records are ordered
by option number. The FILE *NEXT command positions
the cursor on the first record in the active set,
and retrieves the record into the select list
buffer.
Step 5 checks to see if the record retrieved by
step 4 has the correct value in the option number
field. If the value in the option number field
does not match '000', the contents of the zero
numeric constant, (the first record), control
passes to step 9.
Line 6 The SCROLL command scrolls a heading line in the
scroll area.
Line 7 This command sets user switch number 1 to off. The
calling function (scroll_options) tests the status
of this switch when the user next presses the
Scroll Options function key. If this switch is
off, the next option is retrieved.
Line 8 The function exits.
Line 9 Control only passes to this step if an option
record for the product has not been found. This
condition is detected if an error occurs in step 4,
or the option number in the record retrieved from
the file does not equal "000" in step 5. Failure
to find an option record means that the record for
option 000 does not exist, suggesting that the
product or option file is corrupted. This step
displays a message telling the user that records
may be corrupted.
Line 10 Control only passes to this step if the record for
option number 000 cannot be found. It demonstrates
a method for recovering from a potentially serious
problem. The PROCEED command in this step
immediately terminates any current activity in the
application, clears the file and screen buffers,
and closes all data files.
The NOTE command allows you to describe individual
lines within a logic block. HP ALLBASE/4GL ignores
all the text following a NOTE command.
The process main displays the menu main to allow
the user to delete or correct the corrupted record.
Once you have defined and generated the function, create the SQL logic
block, the message, and the process required by the function. These are
described below.
To create the get_optscrol logic block:
This is the SQL logic block that is called from the get_1st_option
function.
1. Create the logic block using the block details listed below.
SELECT :optscrol FROM sqlgrp.option
WHERE product_no = F-product_no.product
ORDER BY option_no;
2. Generate the logic block.
This SQL logic block demonstrates the use of a select list in a SELECT
command. Note that you must precede the select list name with a
colon(:). This SELECT command also includes an ORDER BY clause to
retrieve the options for a product in option number order.
This select command declares and opens a cursor on the optscrol select
list. The active set for this cursor consists of all the option records
for the current product. The records are ordered by option number. The
FILE *NEXT command in the function get_1st_option positions the cursor on
the first record in the active set, and retrieves the record into the
select list buffer.
To create the prod_corrupt message:
The get_1st_option function requires this message.
1. Create the message now, using the information shown below.
Name prod_corrupt
Type WARN
Contents "Product record may be corrupted. "
"Delete and enter again."
Process - main
The get_1st_option function calls the main process if the product record
is corrupted. This process clears all file and screen buffers and then
displays the main menu. The user can then select another operation from
the menu to delete the product or correct the problem. The process is a
simple one. The SCREEN command calls the main menu.
To create the main process:
1. Create this process, using the information below.
1 SCREEN main
2. Generate the process.
Function - get_next_option
The last function to create is the get_next_option function. This
function is called by the scroll_options function to retrieve the second
and subsequent options for the current product.
To create the get_next_option function:
1. Create this function using the logic commands shown here.
1 FILE *NEXT optscrol ; ENTER 3
2 EXIT
3 ON 1
4 EXIT
2. Generate the function.
This function reads the next record for the active set for the optscrol
select list. If a record is retrieved successfully the function exits.
If a record is not found (indicating an end-of-file condition and no
further option records exist) the function sets switch number 1 on, and
then exits. When set on, switch number 1 resets the scrolling system.
When you modify the product_key_read function in the next chapter, you
will add a step to set switch number 1 on. This is necessary to force
execution of the function get_1st_option if the user has pressed the
Scroll Options function key after pressing the Commit Data function
key.
Executing the function get_1st_option declares and opens a cursor on the
optscrol select list. This is necessary because the COMMIT WORK command
called by the product process closes all open cursors. Attempting to
execute the function get_next_option without first declaring and opening
a cursor generates an error condition.
These functions complete the processing required for a fail safe
scrolling mechanism.
You cannot test any of your screens or functions yet. At the end of the
next chapter all the logic for the application will exist, and you can
then see the scrolling functions in action.
Turn to the summary of this lesson.
Creating HP TurboIMAGE/iX Functions.
Function - get_1st_option
The next function that you need to create is the get_1st_option function.
This function is called by the scroll_options function to retrieve the
first option record for the current product. Since the processing rules
for this application require that each product must have at least one
option (number 000) this function should always retrieve an option
record. Failure to find a record indicates a serious file problem.
To create the scroll_options function:
1. Use the logic commands shown here to create the function.
1 DEFINE %FILE% option.option_scroll
2 DISPLAY *RESET=S ""
3 FILE *FIND %FILE% *INDEX=product_no *KEY= F-product_no.product ;
ENTER 8
4 FILE *NEXT %FILE%
5 SCROLL 9 "***** Start of Options for Product #"
S-product_no.product_scrn " *****"
6 OFF 1
7 EXIT
8 MESSAGE prod_corrupt
9 PROCEED main; NOTE Product/option record corrupted
because option 000 does not exist. Clear buffers and display
the main menu so the user can delete the product.
2. Generate the function.
The get_1st_option function operates as follows:
Line 1 This step uses the DEFINE command to create an
identifier that is expanded whenever it is
referenced in the logic block.
Line 2 The DISPLAY command is another command used to
manipulate the scroll area on a screen. It
displays a line of data on a specific line in the
scroll area. The *RESET=S option clears the scroll
area. The empty parameter ("") specifies that
nothing is displayed on the first line of the
scroll area.
Lines 3 and 4 These steps search for a record that matches the
value specified, and retrieve the record.
The FILE *FIND command searches a file for a record
with the product key field equal to the value
specified. As the option_key field in this
application is the concatenation of the product_no
and the option_no fields, a search with the key
equal to the product number finds the first option
for that product. If no suitable record is found,
control passes to step 8.
The FIND command does not read the record contents
into the file buffer. It simply positions a file
pointer to the record. You must use a FILE *NEXT
command to read the record into the file record
buffer.
Line 5 The SCROLL command scrolls a heading line in the
scroll area.
Line 6 This command sets user switch number 1 to off. The
calling function (scroll_options) tests the status
of this switch when the user next presses the
Scroll Options function key. If this switch is
off, the next option is retrieved.
Line 7 The function exits.
Line 8 Control only passes to this step if an option
record for the product has not been found. Failure
to find an option record means that the record for
option 000 does not exist, suggesting that the
product or option file is corrupted. This
condition is detected if an error occurs in step 3,
or the product number in the record retrieved from
the file is not the current product number. This
step displays a message telling the user that
records may be corrupted.
Line 9 This step demonstrates a method for recovering from
a potentially serious problem. The PROCEED command
in this step immediately terminates any current
activity in the application, clears the file and
screen buffers, and closes all data files.
The NOTE command allows you to describe individual
lines within a logic block. HP ALLBASE/4GL ignores
all the text following a NOTE command.
The process main displays the menu main to allow
the user to delete or correct the corrupted record.
Once you have defined and generated the function, create the message and
the process required by the function. These are described below.
To create the prod_corrupt message:
1. Make the entries shown below.
Message - prod_corrupt
Name prod_corrupt
Type WARN
Contents "Product record may be corrupted. "
"Delete and enter again."
Process - main
The get_1st_option function calls the main process if the product record
is corrupted. This process clears all file and screen buffers and then
displays the main menu. The user can then select another operation from
the menu to delete the product or correct the problem. The process is a
simple one. The SCREEN command calls the main menu.
To create the main process:
1. Make the entries shown here.
1 SCREEN main
2. Generate the process.
Function - get_next_option
The last function to create is the get_next_option function. This
function is called by the scroll_options function to retrieve the second
and subsequent options for the current product.
To create the get_next_option function:
1. Make the entries shown below.
1 DEFINE %FILE% option.option_scroll
2 FILE *NEXT %FILE% ; ENTER 4
3 IF F-product_no.%FILE% = F-product_no.product THEN EXIT
4 ON 1
5 EXIT
2. Generate the function.
This function operates as shown below.
Line 1 This defines an abbreviation for the
option.option_scroll reference.
Line 2 This next record is retrieved from the file.
Line 3 This step tests the new record to ensure that it
refers to the correct product by testing the value
in the product_no field. If the retrieved value is
correct, the function exits with the next option
details in the correct buffer.
Line 4 This step sets user switch number 1 on if the end
of the file is reached in step 2, or the product
number changes as determined in step 3. This
indicates to the calling function that the last
option for the product has been found.
Line 5 The function exits.
If a file manipulation function is executed, the scrolling functions will
start from the first function again.
These functions complete the processing required for a fail safe
scrolling mechanism.
You cannot test any of your screens or functions yet. At the end of the
next chapter all the logic for the application will exist, and you can
then see the scrolling functions in action.
MPE/iX 5.0 Documentation