home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TCE Demo 2
/
TCE_DEMO_CD2.iso
/
demo_cd_.2
/
mags
/
stosser
/
stoser05.arj
/
stoser05.msa
/
A
/
36.PNE
< prev
next >
Wrap
Text File
|
1987-04-22
|
9KB
|
305 lines
UNDERSTANDING STOS BASIC
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
STOS WINDOWS EXPLAINED
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Copied By Julie Worden
from the STOS Magazine
Issue 6 June 91
Thanks to the kind permission of
Dion Guy
Who retains the Copyright
This month we discuss the STOS window
commands. The STOS window system
provides an easy way to get
professional looking presentation in
your programs.
WINDOWS
¯¯¯¯¯¯¯¯¯
STOS windows, like menus, are
especially useful because they work in
all resolutions.Windows are also the
only easy way to get an alternative
character set into your programs. You
can have a maximum of 13 windows on
the screen at once and the minimum
size of a window is 3x3 characters.
Over the next few pages we will
discuss each of the window commands in
detail.
OPENING A WINDOW
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
The syntax of the window command is
as follows:
WINDOPEN n,x,y,w,h,b,c
N=the window number (1-13).
X=x text coordinate of the top left
hand corner of the window.
Y=y text coordinate of the top left
hand corner of the window.
W=the width (in characters) of the
window.
H=the height (in characters)of the
window.
B=the border style of the window.
C=the character set number of the
window
This can be a number from 1-16
(assuming you have the appropriate
character set in memory). Three
character sets(1-3) are already
present in STOS. These are the default
low, medium and high resolutuon
character sets.
Note that the border and character set
parameters are optional.however if you
omit the border number,a default of 1
will be assumed. To overcome this use
a border number of 0 and no border
will appear.
Now for an example. Let's say that we
wanted to open a window 20x20
characters in size,beginning at the
top left hand corner of the screen
(coordinates 0,0), and with a border
number of 4.Enter the following small
program:
10 mode 0:key off
20 windopen 1,0,0,20,20,4
Once you run this you will see that a
fairly large window has been created.
Notice that we have used window number
1 for this window.To get STOS back to
normal press UNDO twice.
Once a window has been opened,you have
to be aware of the limitations of the
width and height etc when
displaying text in it. For example if
you add the following line to the
program:
30 locate 30,30:print "Hello"
and run it,then the program will crash
with a 'illegal function call' error.
This is because the window size is
only 20x20, and we tried to print
something at 30,30 - which is outside
of the windows border. If you ammend
line 30 to:
30 locate 6,6:print "Hello"
you will see it works fine.
We will now tackle a program which
uses more than one window.
When using more than one window , you
have to bear in mind that STOS always
stays with the last window to be
created. STOS has two commands which
can be used to access different
windows. These are 'WINDOW' and
'QWINDOW'. We will see how to use
these commands with an example
program,type in this small program to
see two windows in action:
10 mode 0:key off
20 windopen 1,0,0,40,10,4
30 windopen 2,0,11,40,10,4
If you run this you will see that STOS
has stayed in the last window created.
In order to select another window you
can either use the 'WINDOW' or
'QWINDOW' commands. Add the following
line to the program and run it:
40 window 1
Now STOS is in window 1.Replace line
40 with the following, then run it:
40 qwindow 1
After you have run the program you
will see that QWINDOW has the same
effect as WINDOW.
The main difference between 'WINDOW'
and 'QWINDOW' is the following:
When you access a window using the
'WINDOW' command,STOS redraws the
window and all it's contents before
selecting it. However, if you use the
'QWINDOW' command,STOS will just
select the window without bothering to
redraw it. If STOS doesn't have to
redraw the window it is much quicker,
Therefore 'QWINDOW' stands for 'quick
window'. Sometimes you have to redraw
the window though, so you cannot use
'QWINDOW' all the time.
Character sets
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
You can use the three character sets
that are already in STOS with your
windows,but to add a bit of uniqueness
to your program it is good to design
your own set. You can do this using
'FONTS.ACB' program free with STOS. We
havent the space here to discuss this
at length but you will find the
relevant information on pages 169-173
of the STOS manual.
One tip (for television and colour
monitors only!) - if you want to use
big characters in windows,try using
character set 3 from a window. These
characters are intended for a high
resolution monitor,but if you use them
in modes 0+1 they come out as big
characters!.
Other window commands
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
If you want to have a title for your
window then you can use the command
'TITLE'(pretty obvious really!). Enter
this small program:
10 mode 0:key off
20 windopen 1,0,0,40,24,4
30 title "A WINDOW"
You will see that the title 'A WINDOW'
will appear in the top border line of
the window.A title will always appear
at the top of a window in the border.
Note you cannot use the 'title'
command if your window has no border -
STOS will crash.
If you want to change the border of a
window after it has been drawn,you can
use the 'BORDER' command. Replace line
30 of the above program with the
following to see this in effect:
30 wait key: border 1
Bear in mind that using the 'BORDER'
command will erase any title specified
for that window.
To find which window number is
currently being used,there is a
special variable 'WINDON' which
contains that info. Replace line 30 of
the above program with the following
to see 'WINDON' in use :
30 print WINDON
After you have displayed a window, if
you want to move it you can use the
command 'WINDMOVE'. The syntax of this
command is - WINDMOVE x,y. X=the new x
text coordinate of the window and
Y=the new y text coordinate. Enter
this small program to see 'WINDMOVE'
in effect:
10 mode 0:key off
20 windopen 1,0,0,10,10,4
30 wait key
40 windmove 4,4
After you have run this,press a key
and you will see the window move.
If you want to delete a window after
it has been created it is really
simple. Just use the command WINDEL.
The syntax is:
WINDEL w
W=the number of the window you wish to
be deleted.To see 'WINDEL' in action
just replace line 40 of the last
program with:
40 windel 1
After you have run it,press a key and
the window will be deleted.
To clear a window of its contents
there is a special command. Just use
CLW. Enter this small program to see
CLW in use:
10 mode 0:key off
20 windopen 1,0,0,10,10,4
30 for A=0 to 9:for B=0 to 9
40 locate A,B:print "W"
50 next B:next A
60 wait key:clw
After you run this program press a
key and the contents of the window
will be erased.
Window Scrolling
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally, when you print text at the
bottom of a window, the window will
scroll up by a line. Alternatively,you
can use the cursor keys to scroll the
window. However, if for some reason
you didn't want the window to scroll
you can use the command SCROLL OFF.
Try entering SCROLL OFF and then
try using the cursor keys to scroll
the screen.You will see that the
cursor now wraps around (that is, the
cursor goes past the bottom of the
screen it will appear at the top and
vice versa). To enable the window
scrolling , just use the command
SCROLL ON.
If you want to scroll the screen up
or down by hand, you can use the
commands SCROLL UP and SCROLL DOWN.
SCROLL UP will move anything above the
text cursor one line up and SCROLL
DOWN will move anything below the text
cursor one line down.Try this small
program:
10 mode 0:key off
20 locate 0,11:print"Hello":wait key
30 for A=0 to 3:scroll up:next A
This concludes our article on windows.