8. NS BASIC Tech Note                                   January 1, 1995

How to turn NS BASIC into a button on the screen           
--------------------------------------------------------------------------
Suppose you want to leave your NS BASIC program running while you do
something else on your Newton, and then just bring it back when you're 
ready.
Here's some sample code showing how.


0010 rem Park NS BASIC in the corner
0020 GOSUB 1000 //hide BASIC
0030 stop
1000 rem hide BASIC
1010 LET base:=getroot().|basic:nsbasic|
1020 LET oldBounds=base.viewBounds
1030 LET newBounds={left:2, right:60, top:2, bottom: 15}
1040 LET w={viewBounds: newBounds, viewJustify: 2, goto: 2000}
1050 LET W.viewformat=4*vfround+2*vfpen+vffillwhite+vfframeblack
1060 LET w.text="BASIC"
1070 window w1,w
1080 LET newBounds.bottom=newBounds.bottom+4
1090 LET newBounds.right=newBounds.right+4
1100 LET z=setvalue(base,'viewbounds,newBounds)
1105 LET X=setvalue(base,'viewflags,1)
1110 show w1
1120 end
2000 rem show BASIC
2010 LET z=setvalue(base,'viewBounds,oldBounds)
2020 LET z=setvalue(base,'viewflags,5)
2030 hide w1
2040 return

NS BASIC itself is contained in a window. What this program does is change 
the
bounds of the NS BASIC window from being the full screen to being just a 
small
rectangle in the upper left corner.  The viewBounds of the underlying NS 
BASIC
window are stored in getroot().|basic:nsbasic|.viewbounds. The setValue()
function works like a LET statement would, but forces a redraw of the 
window
if something important (like the viewbounds) changes.