Progress
Language Reference


TO-ROWID Function

Interfaces
OS
SpeedScript
All
All
Yes

Converts a string representation of a ROWID to a valid ROWID value.

SYNTAX

TO-ROWID ( rowid-string ) 

rowid-string

A string representation of a ROWID. Since ROWID values are a variable sequence of hexadecimal digits, rowid-string must be in the form "0xhex-digits", where hex-digits is any string of characters from 0 through 9 and A through F.

EXAMPLES

The following procedure (r-torwid.p) selects customer balance and credit information and displays it in a browse. You can select any number of rows to store and display more information on the selected customers.

r-torwid.p
DEFINE QUERY custq FOR customer 
    FIELDS (cust-num name balance credit-limit).
DEFINE BUFFER cust2 FOR customer.

DEFINE TEMP-TABLE rowtab FIELD rowchar AS CHARACTER
    INDEX rowi IS UNIQUE PRIMARY rowchar ASCENDING.

DEFINE BROWSE custb QUERY custq
    DISPLAY cust-num name balance credit-limit
WITH 10 DOWN MULTIPLE.
DEFINE VARIABLE hcustb AS WIDGET-HANDLE NO-UNDO.
DEFINE VARIABLE irow AS INTEGER NO-UNDO.
DEFINE BUTTON bstore LABEL "Store Selections".
DEFINE BUTTON bdisplay LABEL "Display Call Selections".
DEFINE BUTTON bclear LABEL "Clear Storage". 
DEFINE FRAME brs-frame custb SKIP bstore bdisplay bclear.
DEFINE FRAME dsp-frame
    cust2.cust-num cust2.name cust2.phone
WITH 5 DOWN SCROLL 1. 
ON CHOOSE OF bstore DO:
    DO irow = 1 TO custb:NUM-SELECTED-ROWS:
        IF custb:FETCH-SELECTED-ROW(irow) AND 
           NOT CAN-FIND(rowtab WHERE STRING(ROWID(customer)) = rowchar)
        THEN DO:
            CREATE rowtab NO-ERROR.
            ASSIGN rowchar = STRING(ROWID(customer)) NO-ERROR.
        END.
    END.
END. 
ON CHOOSE OF bdisplay DO:
    CLEAR FRAME dsp-frame ALL.
    FOR EACH rowtab WITH FRAME dsp-frame:
        FIND cust2 WHERE ROWID(cust2) = TO-ROWID(rowchar).
        DISPLAY cust2.cust-num cust2.name cust2.phone.
        DOWN WITH FRAME dsp-frame.
    END.
END.

ON CHOOSE OF bclear DO:
    IF custb:DESELECT-ROWS() THEN FOR EACH rowtab:
        DELETE rowtab.
    END.
    FRAME dsp-frame:VISIBLE = FALSE.
END.

OPEN QUERY custq PRESELECT EACH customer.
ENABLE ALL WITH FRAME brs-frame.

WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. 

Thus, when you choose the bstore button, r-torwid.p stores the ROWID string values of all selected customer records in a temporary table. When you choose the bdisplay button, it displays the selected customer phone information in a down frame by converting each stored ROWID string to a ROWID value and finding the corresponding customer record. (The example also allows you to add selections and restart by deleting the existing selections.)

NOTE

Although TO-ROWID converts a properly formatted string to a ROWID value, there is no guarantee that this value corresponds to an existing record in your database.

SEE ALSO

DATE Function, DECIMAL Function, INTEGER Function, ROWID Function, STRING Function


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