Listing of file='@MENU' on disk='vmedia/mvp-cs386-1.30-disk2.wvd.zip'
# Sector 200, program filename = '@MENU' 0005 REM % Prog = @MENU By PLS Date = 02/01/85 0010 REM %(c) Copr. Wang Laboratories, Inc. 1986 0015 REM %Updated for OS Release 2.7 by SPM 28 April 1986 0020 REM @MENU provides a menu structure for program selection. : REM Multiple levels of menu can be set up with each successive screen : REM displaying the next menu node. Node information is overlayed in at 0025 REM lines 9000-9999; each node is saved as a separate program file ('24). : REM Access to the root node is always available with RESET & LOADRUN if : REM the progam START is this program or loads in this program. : REM 0030 REM @MENU is loaded from a program (eg START) that sets $PSTAT=" ". : REM $PSTAT indicates which node is to be loaded (if " ", the root node). : REM @MENU sets $PSTAT=node-name when a program is selected, so that the 0035 REM program can return to this menu node by overlaying in @MENU. 0060 REM %VARIABLES........ : DIM U$8,U1$68,U8$68,U2$30,U6$1,W$(95,3)1,U(5),R$10,W$1,W0$1,U4$8,U9$1,M$3 1 0070 REM Display : REM W$=cursor : REM W0$=alt. cursor : REM W1=column# : REM W0=CRT column : REM W5=# CRT columns : REM U3=tab : REM R1=row# : REM R0=CRT row : REM R5=# CRT rows : REM R9=# rows : REM W$(=item coordinates : REM U(i)=length column(i) : REM M$=message 0080 REM Node Items : REM U1=# fields/item : REM U$=filename : REM U1$,U8$=description : REM U2$=type : REM W,R=item# : REM R2=data record# : REM U=# extra fields in node descriptor : REM W9=# items (including blank lines) : REM W8=# items (excluding blank lines) : REM U4$=password 0090 REM Other : REM U6$=keystroke : REM U4,R$=scratch 0100 REM %GET NEXT NODE ............. : REM Entry- $PSTAT=node name (if " ", node name loaded from .STARTD) 0110 REM %ROOT NODE : U$=$PSTAT(#PART) : $PSTAT=" " : IF U$<>" "THEN 120 0115 DATA LOAD DC OPEN T#U2,".STARTD" : DATA LOAD DC #U2,U$ 0120 REM %GET NEXT NODE : LOAD T#U2,U$9000,9999BEG 140 : ERRORREM 0130 IF U1$=" "THEN 110 : M$="File "&U$&" not found." : GOSUB '201(M$) : PRINT HEX(07) : GOTO 320 0140 REM NODE DESCRIPTORS : RESTORE LINE8100 : READ U$,U1$,U1,U 0160 REM %CRT SIZE : REM Exit-- R5=#rows, W5=#columns, W$=cursor character : R5=24 : W5=80 : W$=HEX(8B) : W0$=HEX(85) : $GIO/005(7601,R$) : R$=AND HEX(10) : IF STR(R$,,1)=HEX(10)THEN 170 : R5=16 : W5=64 : W$="*" : W0$="." 0165 REM %DETERMINE DISPLAY COORDINATES OF NODE ITEMS........ 0170 REM %# NODE ITEMS : R=-1 : RESTORE LINE8100,5+U 0180 GOSUB 560 : IF U$<>"no more"THEN 180 : W9=R : W1=INT((W9+R5-6)/(R5-5)) : R9=-INT(-W9/W1) 0190 REM %MAX ITEM LENGTH FOR EACH COL : R=-1 : W1=0 : MAT U=ZER : RESTORE LINE8100,5+U 0200 FOR W=1TO W9 : GOSUB 560 : IF MOD(R,R9)=0THEN W1=W1+1 : U(W1)=MAX(U(W1),LEN(U1$)+2) : NEXT W 0210 REM %CALC. DISPLAY COORDS : R0=INT((R5-5-R9)/2)+5 : W0,U3=INT((W5-U(1)-U(2)-U(3)-U(4)-U(5))/(W1+1)) : IF U3<5THEN STOP "Screen too small -- reduce length or no. of items. " : W8=0 : RESTORE LINE8100,5+U : R2=-1 0220 FOR W=1TO W9 : R1=MOD(W-1,R9) : W1=INT((W-1)/R9) : IF R1=0AND W1>0THEN W0=W0+U(W1)+U3 : GOSUB 560 : IF STR(U2$,,1)="B"THEN 230 : W8=W8+1 : W$(W8,1)=BIN(R1+R0) : W$(W8,2)=BIN(W0) : W$(W8,3)=BIN(R2) 0230 NEXT W 0240 REM %DISPLAY NODE......... 0280 REM %DISPLAY NODE TITLE : RESTORE LINE8100 : READ U$,U1$,U1,U : SELECT PRINT 005(W5),P : PRINT HEX(020D0C030F060E);AT(0,(W5-LEN(U1$))/2);U1$ 0290 REM %DISPLAY INSTRUCTIONS : GOSUB '201(" ") 0298 PRINT AT(2,W5-22);"Partition";#PART;HEX(08);",";SPACEK;"K" : PRINT AT(3,W5-15);"Terminal";#TERM 0300 REM %DISPLAY NODE : RESTORE LINE8100,5+U : FOR W=1TO W8 : GOSUB 530 : U8$=U1$ : GOSUB 650 : NEXT W : W=1 0310 REM %PROCESS USER REQUESTS........ 0320 REM %DISPLAY CURRENT ENTRY HIGHLIT : RESTORE LINE8100,5+U+U1*VAL(W$(W,3)) : GOSUB 530 : U8$=U1$ : PRINT HEX(0E);AT(VAL(W$(W,1)),VAL(W$(W,2)));W$;" ";U8$;HEX(0F); 0330 REM %USER REQUEST : KEYIN U6$,,465 : IF M$<>" "THEN GOSUB '201(" ") : ON POS(HEX(20088281)=U6$)GOTO 400,410,420,470 0340 REM %Starting character? : RESTORE LINE8100,5+U : R=0 0350 GOSUB 530 : IF W<>RTHEN 350 0360 GOSUB 530 : IF U$="no more"THEN 370 : U9$=HEX(20)OR STR(U1$,,1) : IF STR(U1$,,1)<>U6$AND U9$<>U6$THEN 360 : GOTO 390 0370 RESTORE LINE8100,5+U : R=0 0380 GOSUB 530 : IF W=RTHEN 330 : U9$=HEX(20)OR STR(U1$,,1) : IF STR(U1$,,1)<>U6$AND U9$<>U6$THEN 380 0390 GOSUB 650 : W=R : GOTO 320 0400 REM %SPACE key : GOSUB 650 : W=MOD(W,W8)+1 : GOTO 320 0410 REM %BACKSPACE key : GOSUB 650 : W=MOD(W-2,W8)+1 : GOTO 320 0420 REM %RUN key : RESTORE LINE8100,5+U : R=0 0430 GOSUB 530 : IF W<>RTHEN 430 0440 REM Device selection : U7$,U3$,U5$,U4$=" " : $UNPACK(D=HEX(012C))U2$TO R$,U7$,U4$,U3$,U5$ : GOSUB 610 0450 REM Check for password : GOSUB 580 : IF U4$<>" "THEN 240 0452 REM Check SPACEK : IF U7$=" "THEN 460 : CONVERT U7$TO U4 : ERRORGOSUB '201("Error in SPACEK.") : PRINT HEX(07) : GOTO 320 0454 IF U4<=SPACEKTHEN 460 : M$=U$&" needs a ##K partition." : CONVERT U4TO STR(M$,7+POS(STR(M$,8)="#"),2),(##) : GOSUB '201(M$) : PRINT HEX(07) : GOTO 320 0460 M$="(Loading "&U$&")" : GOSUB '201(M$) : IF STR(U2$,,1)<>"P"THEN 120 : RESTORE LINE8100 : READ R$ : $PSTAT=R$ : SELECT PRINT 005(80) : LOAD T#U2,U$ : ERRORSELECT PRINT 005(W5) : GOTO 130 0465 REM %TRANSLATE NEXT TO RUN & SF'31, CLEAR, PREV TO CANCEL : IF M$<>" "THEN GOSUB '201(" ") : IF U6$=HEX(42)OR U6$=HEX(52)THEN 700 : IF U6$=HEX(43)OR U6$=HEX(53)THEN 710 : IF U6$<>HEX(1F)AND U6$<>HEX(F0)THEN 330 0470 REM %CANCEL/EDIT key : IF U=0THEN 330 : RESTORE LINE8100,5 : READ U$ : U2$="M" : R$=" " : IF U>=2THEN READ R$ : $UNPACK(D=HEX(012C))R$TO U3$,U5$ : GOSUB 610 : GOTO 460 0480 REM %SUBROUTINES......... 0490 DEFFN'29"LISTSD 9000,";HEX(0D) 0500 DEFFN'24 : PRINT "Saving node data" : RESTORE LINE8100 : READ U$ : SAVE T$(5)U$9000, : ERRORSCRATCH TU$ : SAVE T$()U$9000, 0510 RETURN 0520 REM %GET NEXT NODE ITEM (excluding blank lines) 0530 READ U$,U1$,U2$ : IF U1=3THEN 540 : FOR U4=4TO U1 : READ R$ : NEXT U4 0540 IF POS("MP "=STR(U2$,,1))=0THEN 530 : R=R+1 : RETURN 0550 REM %GET NEXT NODE ITEM (including blank lines) 0560 READ U$,U1$,U2$ : IF U1=3THEN 570 : FOR U4=4TO U1 : READ R$ : NEXT U4 0570 R2=R2+1 : IF POS("MPB "=STR(U2$,,1))=0THEN 560 : R=R+1 : RETURN 0580 REM %CHECK FOR PASSWORD : REM RETURN -- U4$=" " if password ok or none : REM : IF U4$=" "THEN RETURN 0590 PRINT AT(3,0,50);AT(2,0,50);HEX(02050F0E);"Enter password: "; : FOR U4=1TO LEN(U4$) : KEYIN U6$ : STR(U4$,U4,1)=XOR U6$ : PRINT W$; : NEXT U4 : $TRAN(U4$,HEX(2000))R : PRINT HEX(0601) : RETURN 0600 REM %DISK SELECT : REM Entry-- N$=file# (" " ==> #0), A$=device-addr (" " ==> no selection) : REM Return-- N=file# (selected) 0610 U2=0 : IF U3$<>" "THEN CONVERT U3$TO U2 : ERRORGOTO 640 0620 IF U2<0OR U2>15THEN 640 : IF U5$<>" "THEN SELECT #U2<U5$> : ERRORGOTO 640 0630 RETURN 0640 M$="Error in selecting ## "&U5$ : CONVERT U2TO STR(M$,19,2),(##) : GOTO 320 0650 REM %DISPLAY CURRENT ENTRY (W) WITHOUT HIGHLIGHT : PRINT AT(VAL(W$(W,1)),VAL(W$(W,2)));W0$;" ";U8$; : RETURN 0700 DEFFN'42 0705 DEFFN'52 : U6$=HEX(81) : GOTO 470 : RETURN 0710 DEFFN'43 0715 DEFFN'53 : U6$=HEX(82) : GOTO 420 : RETURN 1000 DEFFN'201(M$) : REM %DISPLAY M$ BRIGHT IN TOP LEFT CORNER 1010 IF M$=" "THEN 1015 : PRINT AT(2,0,50);AT(3,0,50);HEX(0E);STR(M$);HEX(0F01) : GOTO 1020 : REM - DISPLAY THE MESSAGE 1015 PRINT AT(3-MIN(U,1),0);"Select an item and press RUN/EXEC"; : IF U<>0THEN PRINT AT(3,0);"or press CANCEL/EDIT for previous menu"; : PRINT ":" 1020 RETURN 7999 DEFFN'31"Z$=";HEX(22);"@MENU ";HEX(22);":SCRATCHTZ$:SAVET$()Z$0,8100";H EX(0D) 8000 REM %NODE DATA (lines 9000-) 8010 REM 1st line of data is the NODE DESCRIPTION -- : REM : REM DATA "node filename" (required) : REM "node title" (required) : REM "# items in each ITEM DESCRIPTION" (required) 8020 REM "# other items in NODE DESCRIPTION" (required) : REM "previous node name" (optional) : REM "[file#][,device-address]" (optional,see below) 8030 REM other alpha items (optional) : REM 8040 REM Each other line of data is an ITEM DESCRIPTION -- : REM : REM DATA "item name (ie, filename)" (required) : REM "item description (displayed information)" (required) 8050 REM "type" (required) : REM P=program : REM M=menu node : REM B=blank display line : REM O=overlay or related file (not used by @MENU) : REM (must follow an item of type P or O) 8060 REM other alpha items (optional) : REM 8070 REM Types P & M can optionally be followed by, separated by commas, : REM : REM required partition size (SPACEK) : REM execution password (8 bytes) 8080 REM file# to load from (default #0) : REM device-addr (file# selected to this, default no selection) : REM : REM Eg, "P,14,password,1,B10" : REM "M,,,,D32" : REM 8090 REM Last line of data defines the end of items -- : REM : REM DATA "no more","end of node"," " 8100 REM