' This program will provide the user with a
' menu front end for the PBASIC demo programs
'
' Since we are going to save screens, set string size to 350
ssize=350

' Declare our main and auxilary menu arrays
dim m$(8), a$(8)

' Here is the matrix of Programs
' The first elements are the options of the main menu, as well as
' the titles for the auxilary menus
' The data lines need to be number from 1, with the last data line
' Containing only the null "" string
'
' Then the entire list of programs for the auxilary menu
' They are followed by the null "" string
'
'      Title        	Programs
1 data "Recreation",	"ETCH","QCHESS","REDDOG","REV","TIC","VADERS",""
2 data "Music",		"BACH1","BACH2","BDAY","BETH2","KRIEGER","PETER1",""
3 data "Graphics",	"RUNMAN","2CURVE","CIRCLE","PGDEMO","WKSPLOT","BAR","CHART",""
4 data "Time",		"WTIME","100DAY","ADDTIM","DAYS",""
5 data "Other",		"AREACD","SIEVE","TEST47","GATE40","TERMINAL",""
6 data ""


cline=0		' Current Line
select=0	' Selected Item
cls
mcnt=0		' Main Menu Count
done=false                       	
repeat
	restore mcnt+1		' Point to data line
	read m$(mcnt)		' Read Title
	if m$(mcnt)<>"" then mcnt=mcnt+1 else done=true
until done

' Display main menu
10 mc=menu(1,1,mcnt,cline,select,mcnt+1,"PBASIC Menu",m$(0),m$(1),m$(2),m$(3),m$(4),m$(5),m$(6),m$(7))
select = mc % 256		' Determine the item selected
cline = mc \ 256		' Determine the top line so we can go back
if select=-1 then cls:end	' Hit <ESC>? Exit...
restore select+1		' Otherwise Point to selected data line
read title$			' Read Title
ocnt=0
done=false
repeat
	read a$(ocnt)		' Read the Programs
	if a$(ocnt)<>"" then ocnt=ocnt+1 else done=true
until done

scrsave s$			' Save the current screen
ndis=ocnt
if ocnt>6 then ndis=6
mc=menu(1,10,ndis,0,0,ocnt+1,title$,a$(0),a$(1),a$(2),a$(3),a$(4),a$(5),a$(6))
pick = mc % 256			' Determine which Program
if pick=-1 then scrload s$:goto 10	' <ESC>?  Restore Screen, Main Menu
cls				
run a$(pick)                    ' Run the Program
'
'
'	At the end of each program on the list, install this line:
'
'	IF ISRUN THEN RUN "MENU" ELSE END
'
'	This will return each program to this program, if it was started
'	from this program
'
