Trouble with "SET WINDOW OFF" command

I am working in Natural for Windows 6.2. I created subroutine 1 to executes a map. Subroutine 1 calls subroutine 2 that “DEFINE WINDOW”, “SET WINDOW”, and writes to the “popup” window. This works fine but now all processing stays in the pop-up window (i.e map in subroutine 1, now executes in the popup window).

When I’m done, I want to close the popup window created in subroutine 2 and execute the map in subroutine 1 again with no popup window.

So I used the “SET WINDOW OFF” command as the last line of code in subroutine 2 that created the popup window. However, now when subroutine 2 is called, it does not create the pop-up window at all. Its almost as if having the “SET WINDOW OFF” command in the same module as “DEFINE/SET WINDOW” nullifies the “DEFINE/SET WINDOW” commands.

Am I misunderstanding or incorrectly using the “SET WINDOW OFF” command. Based on what I’ve read the “SET WINDOW OFF” command deactivates the current window (i.e. the popup in subroutine 2) and re-activates the previously deactivated window (in this case, the map in subroutine 1).

Any feedback would be greatly appreciated

I think your idea should work.

Here’s my sample-code:

define window mybox
  size 5 * 30
  base 5 / 5
  control screen
  framed
*
set key all
repeat
perform sub1
if *PF-KEY ne 'ENTR'
  escape bottom
end-if
end-repeat
*
define subroutine sub1
input 'This is sub1 - Press any PF-Key to leave'
if *PF-KEY eq 'ENTR'
  perform sub2
end-if
end-subroutine
*
define subroutine sub2
set window "mybox"
input 'this is sub2'
set window off
end-subroutine
*
end

Interesting…

Your example code does show the SET WINDOW OFF command function as expected. It also exposed the problem I was having.

In your example you used an INPUT statement to display the text. I used the WRITE statement to display the text. Apparently with the WRITE statement the “SET WINDOW OFF” does not function as expected.

I took your example code and replaced the INPUT command with a WRITE command. You will notice that your sample code functions unexpectedly.

Thank you. You help solved my problem. I will use an INPUT statement instead of a WRITE

There’s an important difference between INPUT and WRITE:
INPUT does its output immediately.
WRITE waits until the page is full.

Your WINDOW-commands will work, if you do a NEWPAGE after the WRITE.

define window mybox
  size 5 * 30
  base 5 / 5
  control screen
  framed
*
perform sub1
write 'end'
*
define subroutine sub1
write 'This is sub1'
newpage
perform sub2
end-subroutine
*
define subroutine sub2
set window "mybox"
write 'this is sub2'
newpage
set window off
end-subroutine
*
end