Hi Matthias;
First, here is a program and output which shows the timing of NEWPAGE
- THIS PROGRAM DEMONSTRATES THAT NEWPAGE DOES NOT IMMEDIATELY
- START A NEWPAGE. IT MERELY SETS A FLAG WHICH IS CHECKED BEFORE
- NATURAL WRITES ANYTHING. IN THE EXAMPLE BELOW SEE IF YOU CAN
- FIGURE OUT WHAT THE VALUE OF #A WILL BE AT THE TOP OF THE
- SECOND PAGE
-
- SURPRISED? EVEN THOUGH THE XYZ WAS MOVED TO #A AFTER THE
- NEWPAGE, THE NEWPAGE COMMAND MERELY SET A FLAG WHICH
- DID NOT CAUSE A NEWPAGE UNTIL THE WRITE STATEMENT TO PAGE TWO
-
DEFINE DATA LOCAL
1 #A (A3) INIT <‘ABC’>
END-DEFINE
*
AT TOP OF PAGE
IF *PAGE-NUMBER = 1
WRITE NOTITLE ‘=’ (25) ’ OUTPUT ’ ‘=’ (25) /
5T ‘PAGE #’ *PAGE-NUMBER (NL=2)
35T 'DATE: ’ *DATV /
5T ‘PROGRAM:’ *PROGRAM
35T ‘LIBRARY:’ *LIBRARY-ID //
10T ‘#A IS’ #A
ELSE
WRITE ‘-’ (60) /
5T ‘PAGE #’ *PAGE-NUMBER (NL=2)
35T 'DATE: ’ *DATV /
5T ‘PROGRAM:’ *PROGRAM
35T ‘LIBRARY:’ *LIBRARY-ID //
10T ‘#A IS’ #A
END-IF
END-TOPPAGE
*
WRITE 5/10 ‘THIS IS PAGE ONE OUTPUT’
NEWPAGE
MOVE ‘XYZ’ TO #A
WRITE 5/10 ‘THIS IS PAGE TWO OUTPUT’
*
END
========================= OUTPUT =========================
PAGE # 1 DATE: 16-SEP-2007
PROGRAM: NEWPAG02 LIBRARY: SNDEMO
#A IS ABC
THIS IS PAGE ONE OUTPUT
PAGE # 2 DATE: 16-SEP-2007
PROGRAM: NEWPAG02 LIBRARY: SNDEMO
#A IS XYZ
THIS IS PAGE TWO OUTPUT
Now to your code: Lets start with
set control ‘N’
write ‘write’
set control ‘N’
input ‘input’
end
You can issue as many %N as you want while you are on one page; Natural still only has one %N applied to the WRITE. There is no %N available for the INPUT.
I must confess I am guessing about what follows. Here is the code:
set control ‘N’
write ‘write’
newpage
set control ‘N’
input ‘input’
end
If I am Natural, when I see the NEWPAGE, I know I must perform an AT END OF PAGE clause (there is none in your code). I am guessing that this is when Natural “applies” the %N, rather than waiting for the next WRITE.
If that is not the case, my second guess would be that the NEWPAGE tells Natural that the second %N must be applied to the second page that is sent to the screen.
I will play a bit when I get a chance and report back.
steve