Consultor Eletrônico



Kbase P18234: How to poulate a browse from Comma Separated Values file (CS
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   02/02/2003
Status: Unverified

GOAL:

How to populate a browse from a CSV (Comma Separated Values) file?

FACT(s) (Environment):

Windows

FACT(s) (Environment):

Progress 9.1x

FIX:

Following is a step-by-step solution that populates a BROWSE widget from a TEMP-TABLE loaded from a CSV file:

1. Create a new regular (not smart) window:

2. Drop a Freeform Query browse widget on the window.

3. In the Definition Section define a TEMP-TABLE and a STREAM:

DEFINE STREAM myStream.
DEFINE TEMP-TABLE myTempTable
FIELD Field1 AS CHARACTER FORMAT "X(20)"
FIELD Field2 AS CHARACTER FORMAT "X(20)"
FIELD Field3 AS CHARACTER FORMAT "X(20)"
FIELD Field4 AS CHARACTER FORMAT "X(20)"
FIELD Field5 AS CHARACTER FORMAT "X(20)"
FIELD Field6 AS CHARACTER FORMAT "X(20)"
FIELD Field7 AS CHARACTER FORMAT "X(20)"
FIELD Field8 AS CHARACTER FORMAT "X(20)"
FIELD Field9 AS CHARACTER FORMAT "X(20)"
NDEX myindex Field1.

4. In the Procedure Section define a "PopulateTempTable" internal procedure:

INPUT STREAM myStream FROM "myFile.CSV".
REPEAT:
CREATE myTempTable.
IMPORT STREAM myStream DELIMITER ","
Field1
Field2
Field3
Field4
Field5
Field6
Field7
Field8
Field9.
END.
INPUT STREAM myStream CLOSE.

5. In the browse DISPLAY trigger of the browse, list displayed / enabled fields:

Field1
Field2
Field3
Field4
Field5
Field6
Field7
Field8
Field9

ENABLE

Field1 Field 2 Field 5

***NOTE: Do NOT put a period at the end of the browse DISPLAY trigger!

6. Modify the browse OPEN QUERY trigger specifying the TEMP-TABLE myTempTable:

OPEN QUERY {&SELF-NAME} FOR EACH myTempTable

7. In the Main Block Section, add

RUN PopulateTempTable.

before the

RUN enable_UI.

statement

8. Save and Run the window.