Progress
Language Reference


NUM-RESULTS Function

Interfaces
OS
SpeedScript
All
All
Yes

Returns the number of rows currently in the results list of a scrolling query. The results list is initialized when the query is opened. Depending on the query, the entire list is built immediately upon opening or it is gradually as needed.

SYNTAX

NUM-RESULTS ( query-name ) 

query-name

A character-string expression that evaluates to the name of a currently open, scrolling query. If query-name does not resolve to the name of a query, or if the query is not open or not scrolling, then the function returns the unknown value (?).

EXAMPLE

The following example uses the NUM-RESULTS function in a message to report on the number of rows in a browse. Note that the query is opened with the PRESELECT option so that the entire results list is built immediately. Otherwise, NUM-RESULTS might not return the total number of rows in the browse. When you run this procedure and choose a button, Progress selects certain rows within the browse and then reports on the number of rows selected and the total number of rows in the browse.

r-brownr.p
DEFINE VARIABLE curr-rec AS ROWID.
DEFINE VARIABLE status-ok AS LOGICAL.
DEFINE VARIABLE threshold LIKE customer.credit-limit INITIAL 25000.

DEFINE BUTTON no-orders-custs LABEL "No Orders".
DEFINE BUTTON hi-cred-custs LABEL "High Credit".

DEFINE QUERY qry FOR customer.
DEFINE BROWSE brws QUERY qry DISPLAY cust-num name country credit-limit
   WITH 10 DOWN MULTIPLE.

FORM
   brws SKIP(1)
   no-orders-custs hi-cred-custs
   WITH FRAME brws-frame.

FORM
   threshold
   WITH FRAME thresh-frame VIEW-AS DIALOG-BOX
        TITLE "Set Threshold" SIDE-LABELS.

ON CHOOSE OF no-orders-custs DO:
   /* Select those customers with no orders. */
   
   status-ok = brws:DESELECT-ROWS().
   HIDE MESSAGE.
   FOR EACH customer NO-LOCK WHERE NOT CAN-FIND(FIRST order OF customer):
      /* Position query to this record and then select row in browse. */
      curr-rec = ROWID(customer).
      REPOSITION qry TO ROWID curr-rec.
      status-ok = brws:SELECT-FOCUSED-ROW().
      IF NOT status-ok
      THEN MESSAGE "Could not select row.".
   END. 

   /* Report number of selected rows and position to first selected. */
  MESSAGE brws:NUM-SELECTED-ROWS "of" NUM-RESULTS("qry")
           "rows have been selected.".
           
   IF brws:NUM-SELECTED-ROWS > 0
   THEN status-ok = brws:SCROLL-TO-SELECTED-ROW(1).
END. 
ON CHOOSE OF hi-cred-custs DO:
   /* Select customers with high credit limits. */
   
   status-ok = brws:DESELECT-ROWS().
   HIDE MESSAGE.
   
   /* Get credit-limit threshold value. */
   UPDATE threshold WITH FRAME thresh-frame.
   FOR EACH customer NO-LOCK WHERE customer.credit-limit >= threshold:
      /* Position query to this record and then select row in browse. */
      curr-rec = ROWID(customer).
      REPOSITION qry TO ROWID curr-rec.
      status-ok = brws:SELECT-FOCUSED-ROW().
      IF NOT status-ok
      THEN MESSAGE "Could not select row.".
   END.

   /* Report number of selected rows and position to first selected. */
   MESSAGE brws:NUM-SELECTED-ROWS "of" NUM-RESULTS("qry")
           "rows have been selected.".
           
   IF brws:NUM-SELECTED-ROWS > 0
   THEN status-ok = brws:SCROLL-TO-SELECTED-ROW(1).
END.

OPEN QUERY qry PRESELECT EACH customer.

ENABLE ALL WITH FRAME brws-frame.

WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. 

NOTES

SEE ALSO

CLOSE QUERY Statement, CURRENT-RESULT-ROW Function, DEFINE BROWSE Statement, DEFINE QUERY Statement, GET Statement, OPEN QUERY Statement, QUERY-OFF-END Function, REPOSITION Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095