scr_line()

The SCR_LINE( ) function returns a positive integer that corresponds to the number of the current screen record in its screen array during a DISPLAY ARRAY or INPUT ARRAY statement.

If this function is used to get the current line of a screen grid the number of the current screen record may be greater than the number of lines visible on the screen, because screen grid creates as many screen records as many records there are in the program array. In the case with a screen array the program records are moved up and down the visible screen records thus the number of the current program record and screen record may not coincide. If a screen grid each program record is assigned to an individual screen record and when you scroll the screen records are also moved.

The current screen record is the line of a screen array that contains the screen cursor at the beginning of a BEFORE ROW or AFTER ROW clause.

The first record of the program array and of the screen array are both numbered 1. scr_line() and arr_curr() can return different values if the program array is larger than the screen array.

This program dynamically updates the screen line to a form field as the user moves between rows of a DISPLAY ARRAY.

MAIN

  DEFINE arr1 ARRAY[20] OF RECORD

    f1 CHAR(10),

    f2 CHAR(10),

    f3 CHAR(10)

    END RECORD

  DEFINE i, j INTEGER

 

  OPEN WINDOW w_test

    AT 2, 2

    WITH FORM "scr_line_function"

 

  FOR i = 1 TO 20

    LET arr1[i].f1 = "Row ", i USING "<&"

    LET arr1[i].f2 = "Column 2"

    LET arr1[i].f3 = "Column 3"

  END FOR

 

  CALL set_count(20)

 

  DISPLAY ARRAY arr1 TO sc_rec.*

    BEFORE ROW

      LET i = arr_curr()

      LET j = scr_line()

      DISPLAY i TO f_arr_curr

      DISPLAY j TO f_scr_line

  END DISPLAY

 

  CLOSE WINDOW w_test

END MAIN

This example also makes use of the related ARR_CURR( ) built-in function to assign values to variables within the BEFORE ROW clause of a DISPLAY ARRAY statement. Because these functions are invoked in the BEFORE ROW control block, the respective i and  variables are evaluated each time that the cursor moves to a new line and are available within other clauses of the DISPLAY ARRAY statement.

DATABASE formonly

SCREEN

{

                                                                              

  [f1      ] [f2         ] [f3         ]                                      

  [f1      ] [f2         ] [f3         ]                                      

  [f1      ] [f2         ] [f3         ]                                      

  [f1      ] [f2         ] [f3         ]                                      

  [f1      ] [f2         ] [f3         ]                                      

                                                                               

     Program\g \gArray\g \gLine   [f16 ]                                              

     Form\g \gArray\g \gLine      [f17 ]                                              

                                                                                                                                                             

}

 

ATTRIBUTES

f1=formonly.f1;

f2=formonly.f2;

f3=formonly.f3;

f16=formonly.f_arr_curr;

f17=formonly.f_scr_line;

 

INSTRUCTIONS

SCREEN RECORD sc_rec[5]  (

      formonly.f1,

      formonly.f2,

      formonly.f3

      )

 

DELIMITERS "[]"

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.