Consultor Eletrônico



Kbase 15823: Sample showing 2 input streams in a repeat loop
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Sample showing 2 input streams in a repeat loop


When you read input from an input stream in a repeat loop,
the end-of-file condition is interpreted as an endkey
condition. If you are getting input from 2 streams, this
can cause the loop to terminate at the end-of-file of the
shorter file. The following code sample shows how to
get around this problem. The 2 data files, a6.dat and
b3.dat follow the code.

/* Beginning of sample code */
def var x as char format "x(02)".
def var y as char format "x(02)".
def stream a.
def stream b.
input stream a from "a6.dat".
input stream b from "b3.dat".
def var a-still-available as logical no-undo init true.
def var b-still-available as logical no-undo init true.

repeat while a-still-available or b-still-available:

if a-still-available then do:
a-block:
do on error undo a-block, leave a-block
on endkey undo a-block, leave a-block:
a-still-available = false.
prompt-for stream a x.
a-still-available = true.
display input x.
end.
end.

if b-still-available then do:
b-block:
do on error undo b-block, leave b-block
on endkey undo b-block, leave b-block:
b-still-available = false.
prompt-for stream b y.
display input y.
b-still-available = true.

end.
end.
end.

/* end of sample code */

Data files:

a6.dat
a1
a2
a3
a4
a5
a6


b3.dat
b1
b2
b3

/* end of data files */


Progress Software Technical Support Note # 15823