Was this helpful?
Scroll
Performs a table-field scroll.
Syntax
Target Scroll:
scroll [formnametablefieldname to [record | end]
Single-Line Scroll:
scroll [formnametablefieldname up | down
formname
Specifies the name of the form in which the table field tablename is displayed.
Formname is optional in the code for a 4GL frame, because the scroll command applies only to the current form in this context.
Formname is required in a 4GL procedure. It can be expressed as a character string, with or without quotes, or as a program string variable.
tablefieldname
(Required) Specifies the name of the table field to scroll
record
Specifies the number of the record within the data set to which the cursor is to scroll. record has a value from 1 up to the number of nondeleted records in the data set.
Description
The scroll statement executes a table-field scroll. The two types of scroll statements are target and single-line scrolls.
A target scroll scrolls the cursor to a specified record in the table field data set, not a row on the table field displayed in the window. It brings the target record into the table field display and places the cursor on it. It requires the first syntax line shown above.
A single-line scroll performs the same sort of scroll as the upline and downline FRS commands. It scrolls up or down a single row of the table field. The single-line scroll requires the second syntax line.
When used for a table field with a data set, the single-line scroll simply moves the data set rows up or down one line in the display.
The scroll down version scrolls the data set record displayed in the bottom row of the table field out of sight. All other records in the table-field display move down one row, and the previous, heretofore invisible, record in the data set (if any) appears as the first row in the display.
The scroll up version scrolls the top row of the table field out of sight. All other records in the table-field display move up one row, and the next, heretofore invisible, record in the data set (if any) appears as the last row in the display.
When a scroll occurs first, not only do the values for each column scroll, but the change variable associated with each value also scrolls, even out of the display window if necessary.
A row's record number can be determined by means of the _record constant, as described in the unloadtable section in this chapter. A deleted row has a negative record number and cannot be the target of a scroll.
To scroll to the last non‑deleted record in the data set, use the keyword end in place of the record number. The row to which the program scrolls becomes the current row of the table field. Therefore, if you issue a resume field statement at this point for the table field, the cursor is positioned on that row.
Examples
These operations perform target scrolls to the bottom, top, and middle of the data set on the form Empform:
'Bottom'=
begin
  scroll empform employee to end;
end

'Top'=
begin
  scroll empform employee to 1;
end

'Middle'=
begin
  inquire_forms table empform
    (:rows = datarows(employee));
  rows := rows/2;
 
  if (rows>0) then
    scroll empform employee to :rows;
  endif;
end
Note that the form name is not required to scroll the current form. For example, to perform the first target scroll on the current form:
scroll employee to end;
Find a particular record in the data set:
'Find'=
begin
  /* Prompt for name to search for */
  searchname := prompt 
    'Lastname to search for: ';
  /* Loop through data set and */ 
  /* stop when name is found   */
  unloadtable employee (record = _RECORD)
  begin
    if (employee.ename = searchname) then
      /* Scroll to specified record name */
      scroll empform employee to :record;
      resume field employee;
    endif;
  end
  /* All rows in data set searched   */
  /* and name not found.        */
  message 'Cannot find named employee.';
  sleep 2;
end
Last modified date: 04/03/2024