set_count()

set_count() takes an integer expression as its argument and specifies the number of records that contain data in a program array.

Before you use an INPUT ARRAY WITHOUT DEFAULTS statement or a DISPLAY ARRAY statement, you must call set_count() with an integer argument to specify the total number of records in the program array.  Most often, these records contain the values in the retrieved rows that a SELECT statement returned from a database and are associated with a database cursor.

The SET_COUNT( ) built-in function sets an initial value from which the ARR_COUNT( ) function determines the total number of members in an array.  If you do not explicitly call SET_COUNT( ), a default value of zero is assigned.

Use set_count() only if you use DISPLAY ARRAY or INPUT ARRAY with static array data types. If you use set_count() with dynamic array, it will be ignored, and the array size will be set automatically.

In this program, the variable i is an array index that received its value in an earlier FOREACH loop.  The index was initialized with a value of 1, so the expression (n_rows -1) represents the number of rows that were fetched from a database table in the FOREACH loop.  The expression set_count(i- 1) tells DISPLAY ARRAY how many program records containing row values from the database are in the program array, so it can determine how to control the screen array.

FOREACH c_contact INTO cont_arr[i]

  LET i = i + 1

END FOREACH

CALL SET_COUNT(i - 1)

DISPLAY ARRAY cont_arr

TO sc_cont.*

If no INPUT ARRAY statement has been executed, and you do not call set_count(), DISPLAY ARRAY or INPUT ARRAY WITHOUT DEFAULTS displays no records.

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.