Consultor Eletrônico



Kbase P16488: how to read all the last columns of a file
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Unverified

GOAL:

how to read just the last column of the file

FIX:

/* DEFINE THE LOCATION WHERE YOU WILL INPUT THE TEXT FROM*/

INPUT FROM C:\PROGRESS\WRK_91D\pilha.txt.

DEFINE VARIABLE myvar AS CHARACTER NO-UNDO.
DEFINE VARIABLE myvar2 AS CHARACTER NO-UNDO.
DEFINE VARIABLE myvar3 AS CHARACTER.


/* While loop to read through the lines*/
REPEAT WHILE TRUE:
IMPORT UNFORMATTED myvar.

/* Use the SUSTRING function to get characters
from position 33 up to 8 characters to the right of 33th*/
ASSIGN myvar2 = SUBSTRING(myvar,33,8,"CHARACTER").
/* Concatenate all substring results*/
myvar3 = myvar3 + myvar2.
END.

INPUT CLOSE.
/* Specify output location and file name*/
OUTPUT TO C:\PROGRESS\WRK_91D\pilha_output.txt.
PUT myvar3 FORMAT "X(2000)".

OUTPUT CLOSE.