OUTLN

Anything QL Software or Programming Related.
Post Reply
Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

OUTLN

Post by Martin_Head »

I am trying to convert a QDOS drawing program to work in QPC2. The original program used a machine code routine to copy part of the screen display to memory. It would then write to an already open channel as a menu, or whatever. And when finished, it would use the machine code routine to copy the display back again.

This is not practical in QPC2. So I have been trying to use OUTLN to do the same job. But I cannot figure it out how to make it work correctly.

I can get it to partly work, but it then things just go wrong.

So, what is correct method for using OUTLN to save and restore the display, or parts of the display.

In the program #1 is the full 512x256 screen. And there are two windows (#2 and #3) which are used for pop up messages, which overlap each other.


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: OUTLN

Post by pjw »

Did you try something like this? (Assumes it is run in the standard SBASIC 3-window arrangement, located at 0x0)

Code: Select all

100 REMark OUTLN [ #channel, ] xsize, ysize, xorg, yorg [ , xshad, yshad ] [ , move ]
110 OUTLN
120 ch = FOPEN('con')
130 OUTLN#ch; 100, 100, 200, 10, 4, 4
140 CLS#ch
150 PRINT#ch;'Hello World'
160 PAUSE#ch
170 OUTLN#ch; 0, 0, 200, 10
180 CLOSE#ch


Per
dont be happy. worry
- ?
User avatar
Artificer
Brittle Membrane
Posts: 120
Joined: Fri Nov 24, 2017 8:43 am

Re: OUTLN

Post by Artificer »

Hi,

I have used OUTLN and WREST keywords.

10 OPEN#1,"con_":OUTLN#1,xsize,ysize,xpos,ypos: CLS#1

20 REMark To restore the previous screen contents. This is simple. The QPTR keyword WREST does the job.

30 WREST#1 : REMARK restores the content overwritten by OUTLN.

Both keywords originally appeared in the QPTR toolkit. This puzzle is why only OUTLN became a standard SBASIC keyword. The QPTR toolkit is now freeware.

Cheers


Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: OUTLN

Post by Martin_Head »

pjw wrote:Did you try something like this? (Assumes it is run in the standard SBASIC 3-window arrangement, located at 0x0)

Code: Select all

100 REMark OUTLN [ #channel, ] xsize, ysize, xorg, yorg [ , xshad, yshad ] [ , move ]
110 OUTLN
120 ch = FOPEN('con')
130 OUTLN#ch; 100, 100, 200, 10, 4, 4
140 CLS#ch
150 PRINT#ch;'Hello World'
160 PAUSE#ch
170 OUTLN#ch; 0, 0, 200, 10
180 CLOSE#ch
This is pretty much what I was trying outside of the program to test OUTLN.

Line 110. I'm pretty sure I get an error with OUTLN and no parameters on my main PC. But on the PC I am typing this I don't (maybe something in my BOOT?). My documentation says that OUTLN without parameters is 'OUTLN#0, smallest area which outlines all windows currently open'. So bearing in mind I am working on an old SuperBASIC program running in a daughter SBASIC job. Should I have a OUTLN#0,512,256,0,0 somewhere near the start of the program. As #1 (the main drawing output window which I want to preserve) gets resized to 512,256,0,0

Line 130. Do I only need to do an OUTLN for the channels that will be 'pop up' windows, #2 and #3 in my case. and not #1 the main drawing window. Also you have set an outline smaller than the size of the default console channel.

Line 170. Why have you set the x and y size to 0? Is that important?

Line 180. Have you closed the channel just for neatness? Or is it important to close the channel after restoring the underlying window. I need to keep #2 and #3 open for further pop ups.

When does the area underneath the 'pop up' window get saved? In the above example what happens if the 'background' is changed between the two OUTLN's. Say line 135 printed something to #1 which is underneath the area covered by #ch. When line 170 is reached, does the background get restored correctly, or is it restored to the state it was in on line 130?


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: OUTLN

Post by pjw »

Martin_Head wrote: This is pretty much what I was trying outside of the program
to test OUTLN. This is pretty much what I was trying outside
of the program to test OUTLN.
First of all, did you try the code? It should be pretty self
explanatory in action. It simulates a popup menu: Display a
small menu. Disappear again on a key press. Sadly SMSQ/E only
has a very limited repertoire of PE commands, so without an
extra toolkit, such as QPTR or easyptr, you are restricted to
the cursor keys for movement and keystrokes for selection.
Line 110. I'm pretty sure I get an error with OUTLN
and no parameters on my main PC. But on the PC I am typing
this I don't (maybe something in my BOOT?).
There are different versions of OUTLN (not to be confused with
EasyPtr's OUTL) in various toolkits, so beware. The standard
SMSQ/E one used here must not have a channel number. If you
add a channel number you also have to open the channel and
specify the size and origin.
My documentation says that OUTLN without parameters
is 'OUTLN#0, smallest area which outlines all windows
currently open'.
I dont think this applies to SMSQ/E's OUTLN (see above)
So bearing in mind I am working on an old SuperBASIC
program running in a daughter SBASIC job. Should I have a
OUTLN#0,512,256,0,0 somewhere near the start of the program.
As #1 (the main drawing output window which I want to
preserve) gets resized to 512,256,0,0

Line 130. Do I only need to do an OUTLN for the channels
that will be 'pop up' windows, #2 and #3 in my case. and not
#1 the main drawing window. Also you have set an outline
smaller than the size of the default console
channel.
You can start an SBASIC daughter job without any open channels,
although any screen IO will always open at least one channel,
namely #0. (see this topic for more)
Line 170. Why have you set the x and y size to 0? Is
that important?
Try it and see! This is what restores the background.
Line 180. Have you closed the channel just for
neatness? Or is it important to close the channel after
restoring the underlying window. I need to keep #2 and #3
open for further pop ups.
Obviously, I dont understand where youre at exactly. This was
just a simple demonstration of how to do a simple popup menu
without the use of further toolkits. Perhaps the following
development will make it more clear, so you can apply it to
your own circumstances.

Code: Select all

100 JOB_NAME 'Popup'
110 :
120 xorg% = 100: yorg% = 20
130 OUTLN 512, 256, xorg%, yorg%
140 PAPER 7: INK 0: CLS
150 :
160 k% = Popup(xorg% + 200, yorg% + 10, 'Hello World')
170 PRINT 'Keypress ='! k%
180 PAUSE
190 QUIT
200 :
210 DEFine FuNction Popup(xo%, yo%, txt$)
220 LOCal ch, k%
230 ch = FOPEN('con')
240 OUTLN#ch; 100, 100, xo%, yo%, 4, 4
250 CLS#ch
260 PRINT#ch; txt$
270 k% = CODE(INKEY$(#ch; -1))
280 OUTLN#ch; 0, 0, xo%, yo%
290 CLOSE#ch
300 RETurn k%
310 END DEFine Popup
320 :
As it stands, it assumes your screen is larger than 512x256.
If it isnt, you need to set xorg% and yorg% to 0. The
"program" also expects to be EXECuted, not RUN.
When does the area underneath the 'pop up' window get
saved?
When you set the outline.
In the above example what happens if the 'background' is
changed between the two OUTLN's. Say line 135 printed
something to #1 which is underneath the area covered by #ch.
When line 170 is reached, does the background get restored
correctly, or is it restored to the state it was in on line 130?
In the given example, no changes can take place in the
background because the program is busy displaying the menu
;) If you intend your popup menu to be external to the main
program, thats a different ballgame. Just experiment until you
get the effect you want!


Per
dont be happy. worry
- ?
Martin_Head
Aurora
Posts: 847
Joined: Tue Dec 17, 2013 1:17 pm

Re: OUTLN

Post by Martin_Head »

Thanks for the advice. I think I may have to do some rewriting of the program I am working on. So that instead of it leaving channels open for the pop up messages all the time, The channels for the pop up messages are only opened when needed, and then closed afterwards.

I think this may be where my main problems arise, as OUTLN is getting called multiple times and is getting confused. I know I am.


Post Reply