Output to file seems to have more than 1 new page

Vaalen

Member
Hi,

I feel like a complete idiot. After many, many years of programming in Progress it still amazes me...

I am having a very simple program:
Code:
define stream sa.
output stream sa to t.t paged.
display stream sa "1".
page stream sa.
put stream sa unformatted skip(1).
output stream sa close.
run testje.p.

Program testje.p looks like this
Code:
def var cregel as char no-undo.
input from t.t.
repeat:
  import unformatted cregel.
  display cregel length(cregel).
end.
input close.

File t.t looks like this (HEX):
Code:
0A 31 0A 0C 0A 0C

Program testje.p then reads 0A, after that 31, after that 0A 0C and after that 0A 0C.

So what I see is carriage-return/linefeed twice.

This gives some trouble in processing file t.t.

Can anyone explain why 0A 0C is put twice to output instead of once followed by 0A?

OpenEdge 10.2A on Unix.
 

GregTomkins

Active Member
I may be the idiot, but isn't 0A 0C = CR LF, and you are getting one pair of them (in the usual Unixy way) for the PAGE and one for the SKIP? I don't see where that first 0A comes from, though.
 

TomBascom

Curmudgeon
Hex 0A is linefeed (character 10).

Hex 0C is form-feed (character 12).

Hex 0D is carriage return (character 13).

UNIX uses linefeed for newline. It does not use a CR-LF pair, that is what Windows does.

So your output is:

<newline>1<newline><formfeed><newline>formfeed>

Which looks to me like exactly what you asked for.
 

Vaalen

Member
So what you are saying is that page (resulting in newline + formfeed) is exactly the same as skip(1), which results in newline + formfeed?

What I would expect is newline + formfeed, followed by newline. That is what this coding is supposed to do.
 

TomBascom

Curmudgeon
No, I'm saying that:

1) You asked for paged output. So when you say "page stream sa." You get a form-feed.

2) And when you close a paged stream you also get a form-feed.

If the stream is not paged the only difference that you will see is that the form-feeds will go away.
 

Vaalen

Member
Right. Thanks.

What we do is:
1. Create a paged file (as if it goes directly to a printer, which it did previously). This file is fine.
2. The file is saved into one of the databases, so it can be found and (re)printed.
3. The file is then put directly to a matrix printer, using default output (not paged, since this was done while creating the file).
We lose the 0A 0C at the end doing this. The file is read using import unformatted, like testje.p.

There is no way we can use a different printer (works fine with a laser printer, btw).
Any suggestions would be highly appreciated.
 

TomBascom

Curmudgeon
If all you lose is the FF then just put control chr(12) at the end of the output.

If IMPORT isn't actually reading the whole file use COPY-LOB to read the file into a longchar rather than IMPORT, IMPORT has an attitude problem about line endings and end of file.
 

Vaalen

Member
That's exactly what the SKIP(1) is for :rolleyes:

COPY-LOB would be an option, but how do I get that to the printer?
 

TomBascom

Curmudgeon
PUT CONTROL.

It probably won't like a longchar -- you might have to STRING() it if it is small enough. Break it into pieces if it is too large.
 
Top