scroll Statement--Perform a Table Field Scroll
This statement performs a table field scroll.
Syntax
scroll formname tablename to record | end
scroll formname tablename up | down
Description
The scroll statement executes a table field scroll. You can use this statement to scroll to a particular record in the data set, to the end of the data set, or simply to scroll up or down one record. Scrolling to a particular record (or the end) is known as a target scroll.
The formname identifies the form in which the table field tablename is displayed. Use quoted or unquoted character string literals or program variables to specify these parameters.
When you perform a target scroll using the to version of the syntax, you must specify either the end of the data set or a particular record in the data set. You can determine the record number of any row in the data set using the _record constant; see the getrow and unloadtable descriptions for more information about this. Record, which can be either a integer literal or integer variable, must evaluate to a positive integer. Consequently, deleted rows, which have negative record numbers, cannot be the target of a scroll.
The row scrolled to becomes the current row of the table field. Therefore, if a resume field statement is then issued for the table field, the cursor is positioned on that row.
Specifying up or down performs the same type of scrolling as do FRS commands. When used for a table field with a data set, it simply moves the data set rows up or down one line in the display. For instance, the scroll up version scrolls the top row of the table field out of sight. All other records in the table field's display are moved up one row, and the next record in the data set (if any) appears as the last row in the display. Because the FRS already provides this functionality this type of scroll is rarely used.
When a scroll occurs, not only do the values for each column scroll, the change variable associated with each value also scrolls, even into the data set if necessary.
Examples--scroll statement:
Example 1:
These operations perform target scrolls to the bottom, top, and middle of the data set.
exec frs activate menuitem 'Bottom';
exec frs begin;
exec frs scroll empform employee to end;
exec frs end;
exec frs activate menuitem 'Top';
exec frs begin;
exec frs scroll empform employee to 1;
exec frs end;
exec frs activate menuitem 'Middle';
exec frs begin;
inquire_frs table empform
(:rows = datarows(employee));
rows = rows/2;
if (rows > 0) then
exec frs scroll empform employee to :rows;
end if;
exec frs end;
Example 2:
Find a particular record in the data set.
exec frs activate menuitem 'Find';
exec frs begin;
/* Prompt for name to search for */
exec frs prompt ('Lastname to search for: ',
:searchname);
/*
** Loop through data set and stop when name is
** found.
*/
exec frs unloadtable empform employee
(:ename = ename, :record = _record);
exec frs begin;
if (ename = searchname) then
/* Scroll to record with specified name*/
exec frs scroll empform employee
to :record;
exec frs resume field employee;
end if;
exec frs end;
/*
** All rows in data set searched and name not
** found.
*/
exec frs message 'Cannot find named employee.';
exec frs sleep 2;
exec frs end;