The basic SBASIC Thing will always open a "ghost" window if any attempt is
made to access channels #0, #1 or #2 and those channels are not open. Any
IO going to either of them will end up in that window; they are treated as
one.
So if you EXecute the "program" 10 PRINT "Hello World!": PAUSE, said window
will open and display the text without a fuss. PRINT defaults to channel
#1. PAUSE on the other hand defaults to channel #0, so EXecuting the
program: 10 BEEP 2000, 2: PAUSE will also open that window, with no text,
just the beep.
You could also try the program: 10 LIST: PAUSE. Same result.
However, if you specify a channel number, such as PRINT#1, or PAUSE#0, or
LIST#2 you will get an error if those channels arent open!
All this was done to make life easier, not to complicate things!
Home grown toolkit keywords, however, wont behave like this. Only all(?)
the built-in system keywords that default to the three basic channels. Thus
SCR_XLIM etc will open a "ghost" window, unless you take precautions.
Now I already demonstrated (at least once) on the forum how this could be
done without using channels at all. I'll repeat it again for slow learners:
Code: Select all
110 sys_clnk = $C4: pt_xscrs = $F2: pt_yscrs = $F4
112 scrx% = PEEK_W(!sys_clnk! pt_xscrs): REMark Get screen size without
114 scry% = PEEK_W(!sys_clnk! pt_yscrs): REMark a channel (PE only!)
116 :
but this is specific for SMSQ/E or Qdos with PE (+ a little extra leg work).
A more general approach, for even slower learners is:
Code: Select all
ch = fopen('con_'): rem This will be your main window at some point
scx% = SCR_XLIM(#ch): scy% = SCR_YLIM(#ch): rem Get the screen size
do whatever other initialisation you desire here..
...
window#ch; xs, ys, xo, yo: cls#ch: rem Now reveal your window
Remember what was recently said about invisible windows? As long as you dont
CLS it doesnt matter what size the window is!