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 >
Text File  |  1987-04-22  |  9KB  |  305 lines

  1.        
  2.  
  3.         UNDERSTANDING STOS BASIC
  4.        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  5.  
  6.          STOS WINDOWS EXPLAINED
  7.         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  8.          Copied By Julie Worden 
  9.          from the STOS Magazine
  10.             Issue 6  June 91
  11.     Thanks to the kind permission of
  12.                 Dion Guy
  13.        Who retains the Copyright
  14.  
  15.  This month we discuss the STOS window 
  16. commands.   The  STOS  window   system 
  17. provides   an   easy   way   to    get 
  18. professional  looking presentation  in 
  19. your programs.
  20.  
  21.               WINDOWS
  22.              ¯¯¯¯¯¯¯¯¯
  23.   STOS  windows,   like   menus,   are 
  24. especially useful because they work in 
  25. all  resolutions.Windows are also  the 
  26. only  easy way to get  an  alternative 
  27. character set into your programs.  You 
  28. can  have a maximum of 13  windows  on 
  29. the  screen  at once and  the  minimum 
  30. size  of a window is  3x3  characters. 
  31. Over  the  next  few  pages  we   will 
  32. discuss each of the window commands in 
  33. detail.
  34.  
  35.          OPENING A WINDOW
  36.         ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  37.   The syntax of the window command  is 
  38. as follows:
  39.  
  40. WINDOPEN n,x,y,w,h,b,c
  41.  
  42. N=the window number (1-13). 
  43. X=x  text coordinate of the  top  left 
  44. hand corner of the window.
  45. Y=y  text coordinate of the  top  left 
  46. hand corner of the window.
  47.  
  48.  W=the  width  (in  characters) of the 
  49. window.
  50. H=the  height  (in  characters)of  the 
  51. window.
  52. B=the border style of the window.
  53. C=the  character  set  number  of  the 
  54. window
  55. This   can  be  a  number  from   1-16 
  56. (assuming  you  have  the  appropriate 
  57. character   set  in   memory).   Three 
  58. character   sets(1-3)   are    already 
  59. present in STOS. These are the default 
  60. low,   medium   and  high   resolutuon 
  61. character sets.
  62.  
  63. Note that the border and character set 
  64. parameters are optional.however if you 
  65. omit the border number,a default of  1 
  66. will be assumed.  To overcome this use 
  67. a  border  number of 0 and  no  border 
  68. will appear.
  69.  
  70. Now for an example.  Let's say that we 
  71. wanted   to   open  a   window   20x20 
  72. characters  in size,beginning  at  the 
  73. top  left  hand corner of  the  screen 
  74. (coordinates 0,0),  and with a  border 
  75. number of 4.Enter the following  small 
  76. program:
  77.  
  78. 10 mode 0:key off
  79. 20 windopen 1,0,0,20,20,4
  80.  
  81. Once you run this you will see that  a 
  82. fairly large window has been  created. 
  83. Notice that we have used window number 
  84. 1 for this window.To get STOS back  to 
  85. normal press UNDO twice.
  86.  
  87. Once a window has been opened,you have 
  88. to be aware of the limitations of  the 
  89. width    and    height    etc     when 
  90. displaying text in it.  For example if 
  91. you  add  the following  line  to  the 
  92. program:
  93.  
  94. 30 locate 30,30:print "Hello"
  95.  
  96. and run it,then the program will crash 
  97. with a 'illegal function call'  error. 
  98. This  is  because the window  size  is 
  99. only  20x20,  and  we tried  to  print 
  100. something at 30,30 - which is  outside 
  101. of the windows border.  If you  ammend 
  102. line 30 to:
  103.  
  104. 30 locate 6,6:print "Hello"
  105.  
  106. you will see it works fine.
  107.  
  108. We  will  now tackle a  program  which 
  109. uses more than one window.
  110.  
  111. When using more than one window ,  you 
  112. have to bear in mind that STOS  always 
  113. stays  with  the  last  window  to  be 
  114. created.  STOS has two commands  which 
  115. can   be  used  to  access   different 
  116. windows.   These   are  'WINDOW'   and 
  117. 'QWINDOW'.  We  will  see how  to  use 
  118. these   commands   with   an   example 
  119. program,type in this small program  to 
  120. see two windows in action:
  121.  
  122. 10 mode 0:key off
  123. 20 windopen 1,0,0,40,10,4
  124. 30 windopen 2,0,11,40,10,4
  125.  
  126. If you run this you will see that STOS 
  127. has stayed in the last window created. 
  128. In order to select another window  you 
  129. can   either  use  the   'WINDOW'   or 
  130. 'QWINDOW' commands.  Add the following 
  131. line to the program and run it:
  132.  
  133. 40 window 1
  134.  
  135. Now  STOS is in window 1.Replace  line 
  136. 40 with the following, then run it:
  137.  
  138. 40 qwindow 1
  139.  
  140. After  you  have run the  program  you 
  141. will  see  that QWINDOW has  the  same 
  142. effect as WINDOW.
  143. The  main difference between  'WINDOW' 
  144. and 'QWINDOW' is the following:
  145. When  you  access a window  using  the 
  146. 'WINDOW'   command,STOS  redraws   the 
  147. window  and all it's  contents  before 
  148. selecting it.  However, if you use the 
  149. 'QWINDOW'   command,STOS   will   just 
  150. select the window without bothering to 
  151. redraw  it.  If STOS doesn't  have  to 
  152. redraw the window it is much  quicker, 
  153. Therefore 'QWINDOW' stands for  'quick 
  154. window'.  Sometimes you have to redraw 
  155. the window though,  so you cannot  use 
  156. 'QWINDOW' all the time.
  157.  
  158.           Character sets
  159.          ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  160.   You can use the three character sets 
  161. that  are  already in STOS  with  your 
  162. windows,but to add a bit of uniqueness 
  163. to  your program it is good to  design 
  164. your  own set.  You can do this  using 
  165. 'FONTS.ACB' program free with STOS. We 
  166. havent the space here to discuss  this 
  167. at  length  but  you  will  find   the 
  168. relevant information on pages  169-173 
  169. of the STOS manual.
  170.   One tip (for television  and  colour 
  171. monitors  only!) - if you want to  use 
  172. big  characters in  windows,try  using 
  173. character set 3 from a  window.  These 
  174. characters  are  intended for  a  high 
  175. resolution monitor,but if you use them 
  176. in  modes  0+1 they come  out  as  big 
  177. characters!.
  178.  
  179.         Other window commands
  180.        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  181.  If you want to have a title for  your 
  182. window  then you can use  the  command 
  183. 'TITLE'(pretty obvious really!). Enter 
  184. this small program:
  185.  
  186. 10 mode 0:key off
  187. 20 windopen 1,0,0,40,24,4
  188. 30 title "A WINDOW"
  189.  
  190. You will see that the title 'A WINDOW'
  191. will appear in the top border line  of 
  192. the window.A title will always  appear 
  193. at the top of a window in the  border. 
  194. Note   you  cannot  use  the   'title' 
  195. command if your window has no border - 
  196. STOS will crash.
  197.  
  198.  If you want to change the border of a 
  199. window after it has been drawn,you can 
  200. use the 'BORDER' command. Replace line 
  201. 30  of  the  above  program  with  the 
  202. following to see this in effect:
  203.  
  204. 30 wait key: border 1
  205.  
  206.  Bear in mind that using the  'BORDER' 
  207. command will erase any title specified 
  208. for that window.
  209.  
  210.   To  find  which  window  number   is 
  211. currently   being  used,there   is   a 
  212. special   variable   'WINDON'    which 
  213. contains that info. Replace line 30 of 
  214. the  above program with the  following 
  215. to see 'WINDON' in  use :
  216.  
  217. 30 print WINDON
  218.  
  219.  After you have displayed a window, if 
  220. you  want to move it you can  use  the 
  221. command 'WINDMOVE'. The syntax of this 
  222. command is - WINDMOVE x,y. X=the new x 
  223. text  coordinate  of  the  window  and 
  224. Y=the  new y  text  coordinate.  Enter 
  225. this  small program to see  'WINDMOVE' 
  226. in effect:
  227.  
  228. 10 mode 0:key off
  229. 20 windopen 1,0,0,10,10,4
  230. 30 wait key
  231. 40 windmove 4,4
  232.  
  233.   After you have run this,press a  key 
  234. and you will see the window move.
  235.  
  236.  If you want to delete a window  after 
  237. it  has  been  created  it  is  really 
  238. simple.  Just use the command  WINDEL. 
  239. The syntax is:
  240.  
  241. WINDEL w
  242.  
  243. W=the number of the window you wish to 
  244. be  deleted.To see 'WINDEL' in  action 
  245. just  replace  line  40  of  the  last 
  246. program with:
  247.  
  248. 40 windel 1
  249.  
  250.  After you have run it,press a key and 
  251. the window will be deleted.
  252.  
  253.   To  clear a window of  its  contents 
  254. there is a special command.  Just  use 
  255. CLW.  Enter this small program to  see 
  256. CLW in use:
  257.  
  258. 10 mode 0:key off
  259. 20 windopen 1,0,0,10,10,4
  260. 30 for A=0 to 9:for B=0 to 9
  261. 40 locate A,B:print "W"
  262. 50 next B:next A 
  263. 60 wait key:clw
  264.  
  265.   After you run this program  press  a 
  266. key  and  the contents of  the  window 
  267. will be erased.
  268.  
  269.            Window Scrolling
  270.           ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  271.  Normally,  when you print text at the 
  272. bottom  of a window,  the window  will 
  273. scroll up by a line. Alternatively,you 
  274. can use the cursor keys to scroll  the 
  275. window.  However,  if for some  reason 
  276. you  didn't want the window to  scroll 
  277. you  can use the command  SCROLL  OFF. 
  278. Try  entering  SCROLL  OFF  and   then 
  279. try  using the cursor keys  to  scroll 
  280. the  screen.You  will  see  that   the 
  281. cursor now wraps around (that is,  the 
  282. cursor  goes  past the bottom  of  the 
  283. screen  it will appear at the top  and 
  284. vice  versa).  To  enable  the  window 
  285.  scrolling , just   use   the  command  
  286. SCROLL ON.
  287.  
  288.   If you want to scroll the screen  up 
  289. or  down  by hand,  you  can  use  the 
  290. commands  SCROLL UP and  SCROLL  DOWN. 
  291. SCROLL UP will move anything above the 
  292. text  cursor  one line up  and  SCROLL 
  293. DOWN will move anything below the text 
  294. cursor  one line down.Try  this  small 
  295. program:
  296.  
  297. 10 mode 0:key off
  298. 20 locate 0,11:print"Hello":wait key
  299. 30 for A=0 to 3:scroll up:next A
  300.  
  301. This concludes our article on windows.
  302.  
  303.  
  304.  
  305.