! 1 Jul 87
! select.cmd	- Extensible class/speed menu driver
! Terrence R. Lambert
!
! NOTE: This file can be modified by the system administrator to add, delete, 
! or change the menu options displayed.  Up to 15 entries can be specified.
! As distributed, 5 entries are defined.
!
! If your system uses the Sytek LAN card, you must modify plist[3] below
! to reflect the correct /dev/ttyXX port number.
!
! If your system uses multiple modems for diferent speeds, 
! the plist[X] entries below must be modified to reflect the correct lines
! to use for each speed.
!
! Each entry in the list specifies 4 items:
!		name	-> The English-Language that appears on the menu
!		plist	-> An optional list of ttyXX ports that TERM can use
!		baud	-> An optional baud rate to set on the port
!		config	-> An optional configuration file to run
! Also:
!
!	1) A name MUST be present for an option to show up in the menu
!	2) If a plist (portlist) is not given, the default portlist is used.
!		multiple ports are semicolon separated, e.g.: "ttyc1;ttyc2"
!	3) If a baud rate is 0, the default is used
!	4) If a config is given, it will be "connected" to
!

setvar maxentry	15			! maximum menu entries
dimstr name	maxentry		! names as they will appear on menu
dimstr plist	maxentry		! portlist for each name (class)
dimint baud	maxentry		! baud rate associated with each name
dimstr config	maxentry		! configuration for each name
!
! the following 5 entries are provided as distributed
!
setvar name[0]		"Dial out at 300 baud"
setvar plist[0]		"/dev/term"
setvar baud[0]		300
setvar config[0]	""

setvar name[1]		"Dial out at 1200 baud"
setvar plist[1]		"/dev/term"
setvar baud[1]		1200
setvar config[1]	""

setvar name[2]		"Dial out at 2400 baud"
setvar plist[2]		"/dev/term"
setvar baud[2]		2400
setvar config[2]	""

setvar name[3]		"Sytek 9600 baud"
setvar plist[3]		"/dev/term"
setvar baud[3]		9600
setvar config[3]	""

setvar name[4]		"Connect to the DDN"
setvar plist[4]		"/dev/term"
setvar baud[4]		0			! use the baud in the config
setvar config[4]	"ddn"			! use ddn.con

! The following 4 entries are blank entries.  They won't be shown until
! you fill in the name.  Just fill in the name, plist, baud and config to the
! desired values.
setvar name[5]		""
setvar plist[5]		"/dev/term"
setvar baud[5]		0
setvar config[5]	""

setvar name[6]		""
setvar plist[6]		"/dev/term"
setvar baud[6]		0
setvar config[6]	""

setvar name[7]		""
setvar plist[7]		"/dev/term"
setvar baud[7]		0
setvar config[7]	""

setvar name[8]		""
setvar plist[8]		"/dev/term"
setvar baud[8]		0
setvar config[8]	""

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Don't modify this file past this point!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

menu 1 close					! make sure it's not used
menu 1 open "",2,10				! then use it
menu 1 entry "File Transfer"			! always first one

setvar sub	0				! the first entry is 0
repeat
	menu 1 entry name[sub]			! put the name on the list
	setvar sub sub+1
until name[sub] = ""				! not set so stop
menu 1 entry "Quit"				! always last one

* Incidently, sub now contains the total number of user entered menu items.
* this means that "Quit" is 1 (for "File Transfer") + sub + 1.

repeat
	cls
	at  0, 0 "T E R M   C o m m u n i c a t i o n s   S o f t w a r e"
	at  0,67 "OPTIONS MENU"
	at  1, 0 "==============================================================================="

	at 14,40 "Use cursor keys to choose,"
	at 15,40 "Then hit RETURN"
	repeat
		setvar picked menu(1,0)
		menu 1 off
	until picked > 0				! don't allow <ESC> key
	cls

	if picked = 1					! file transfer
	  ? "Please wait for the 'OK' prompt before transferring your files"
	  ?
	  ? "Use the Function key F1 menu to transfer files.  When you are"
	  ? "done, pick 'TERMINAL' from the main menu, then type Control-C"
	  ? "(Use the 'CTRL' key like a shift key) to get back to the TERM"
	  ? "Options Menu"
	  ?
	  run term -x
	endif
	if picked = sub+2				! Where quit lives
		? "Are you sure you want to quit? (Y/N) ";
		repeat
			setvar x toupper(chrin())
			if x="Y"
				cls
				quit
			endif
			if x!="N"
				? "\007";		! beep at wrong keys
			endif
		until x="N"
		? "N"
		?
		? "Okay..."
		wait 1
	endif
	if picked != 1 & picked != sub+2		! must be theirs
		if plist[picked-2]!=""			! init only if there
			iferror init plist[picked-2]
				? "Please use another option or try later"
				quit
			endif
		endif
		if config[picked-2]=""
			if baud[picked-2] != 0
				baud $(baud[picked-2])
			endif
		else
			iferror connect $(config[picked-2])
				? "No such configuration"
				quit
			endif
		endif	
		? "TERM Communications Software, sn#$(_sernum)"
		? "Copyright (c) 1982-1987 by Century Sofware, Utah"
		?
		? "[Type F1 for Command Menu F2 for Help]"
		return					! will drop to terminal
	endif
until false
quit
