home *** CD-ROM | disk | FTP | other *** search
- * Program.: MENUGEN.PRG
- * Author..: Luis A. Castro
- * Date....: 2/7/83, 7/6/83, 3/30/84
- * Notice..: Copyright 1983 & 1984, Luis A. Castro, All Rights Reserved
- * Version.: dBASE II, version 2.4x
- * Notes...: Generates main menu and submenu command files.
- * Local...: choice, extension, outfile, heading, pos,
- * word, item, totalopts, yourname, select,
- * option, col:hdg, expanded, counter, length,
- * col:opts, prompt
- *
- CLEAR
- SET TALK OFF
- STORE ".PRG" TO extension
- STORE "Your Name" TO yourname
- *
- * ---Loop through until (S)ave is selected.
- STORE " " TO choice
- DO WHILE choice <> "S"
- ERASE
- @ 2, 0 SAY "M E N U G E N E R A T O R"
- @ 2,72 SAY DATE()
- @ 3, 0 SAY "========================================"
- @ 3,40 SAY "========================================"
- * ---Get program name.
- ACCEPT "Enter PROGRAM name " TO outfile
- STORE !( TRIM(outfile) ) + "." TO outfile
- STORE $( outfile, 1, @(".",outfile) - 1 ) TO outfile
- DO CASE
- CASE outfile = " "
- ERASE
- CLEAR
- SET TALK ON
- RETURN
- CASE FILE( outfile + extension )
- STORE "N" TO select
- SET BELL OFF
- @ 6,0 SAY "COMMAND FILE ALREADY EXISTS. "+;
- "Delete it? [Y/N] ";
- GET select PICTURE "!"
- READ
- SET BELL ON
- @ $,0 SAY "C"
- IF select <> "Y"
- CLEAR
- SET TALK ON
- RETURN
- ENDIF
- ENDCASE
- STORE outfile + extension TO outfile
- *
- * ---Get MENU heading.
- ACCEPT "Enter MENU heading " TO heading
- IF heading = " "
- CLEAR
- SET TALK ON
- RETURN
- ENDIF
- STORE TRIM( !(heading) ) TO heading
- STORE " " TO expanded
- *
- * ---E X P A N D h e a d i n g .
- *
- * -Will NOT correctly expand the heading if more
- * -than one space separates the words.
- SET EXACT ON
- DO WHILE heading <> " "
- STORE @(" ",heading) TO pos
- IF pos > 0
- STORE $(heading,1,pos-1) TO word
- STORE $( heading, pos+1, LEN(heading) - pos ) TO heading
- ELSE
- STORE heading TO word
- STORE " " TO heading
- ENDIF
- STORE 1 TO counter
- DO WHILE counter <= LEN(word)
- STORE expanded + $( word, counter, 1 ) + " " TO expanded
- STORE counter + 1 TO counter
- ENDDO
- STORE expanded + " " TO expanded
- ENDDO
- STORE TRIM( expanded ) TO expanded
- STORE $( expanded, 2, LEN( expanded ) ) TO expanded
- STORE ( 80 - LEN( expanded ) ) / 2 TO col:hdg
- SET EXACT OFF
- *
- * ---Enter MENU options.
- ?
- ? "Enter PROGRAM,DESCRIPTION options:"
- ? " 0:exit"
- STORE "exit" to option10
- STORE " " TO program10
- STORE 8 TO length
- *
- * ---Loop through until a carriage return or
- * ---more than 14 options are entered.
- STORE "11" TO item
- STORE "X" TO option&item
- STORE " " TO program&item
- DO WHILE option&item <> " " .AND. VAL( item ) - 10 <= 14
- STORE STR( VAL( item ) - 10, 2 ) TO prompt
- ACCEPT " &prompt" TO option&item
- STORE TRIM ( option&item ) TO option&item
- IF " " <> option&item
- STORE @(",",option&item) TO pos
- DO CASE
- CASE pos=0 .OR. (pos=1 .AND. LEN(option&item) > 1)
- * ---A blank program name is assumed.
- CASE pos=1 .OR. pos>9 .OR. pos=LEN(option&item)
- * ---Line was begun with a comma, or program
- * ---name is greater than 8 characters, or
- * ---there is no menu description.
- ? "INVALID ENTRY"
- LOOP
- OTHERWISE
- * ---Get program name.
- STORE TRIM($(option&item,1,pos-1)) TO program&item
- ENDCASE
- STORE $( option&item, pos + 1 ) TO option&item
- IF length < LEN( option&item ) + 4
- STORE LEN( option&item ) + 4 TO length
- ENDIF
- STORE STR( VAL( item ) + 1, 2 ) TO item
- STORE "X" TO option&item
- STORE " " TO program&item
- ENDIF
- ENDDO
- STORE VAL(item)-11 TO totalopts
- IF option11=" "
- CLEAR
- SET TALK ON
- RETURN
- ENDIF
- STORE ( 80 - length ) / 2 TO col:opts
- *
- * ---Redisplay menu frame and heading.
- ERASE
- @ 1, 0 SAY "========================================"
- @ 1,40 SAY "========================================"
- @ 2, 0 SAY "||"
- @ 2,col:hdg SAY expanded
- @ 2,78 SAY "||"
- @ 3, 0 SAY "========================================"
- @ 3,40 SAY "========================================"
- STORE 4 TO counter
- DO WHILE counter <= totalopts + 7
- @ counter,0 SAY "||"
- @ counter,78 SAY "||"
- STORE counter+1 TO counter
- ENDDO
- @ counter, 0 SAY "========================================"
- @ counter,40 SAY "========================================"
- *
- * Display menu options, centered on the screen.
- STORE "10" TO item
- DO WHILE VAL( item ) - 10 <= totalopts
- @ VAL( item ) - 5, col:opts SAY ;
- STR( VAL( item ) - 10, 2 )+ ". " + option&item +;
- " [" + program&item + "]"
- STORE STR( VAL( item ) + 1, 2 ) TO item
- ENDDO
- SET BELL OFF
- STORE " " TO choice
- DO WHILE .NOT. (choice $ "ERS")
- STORE " " TO choice
- @ 22,0 SAY "COMMAND: (E)xit, (R)edo, (S)ave ";
- GET choice PICTURE "!"
- READ
- ENDDO
- SET BELL ON
- IF choice="E"
- CLEAR
- SET TALK ON
- RETURN
- ENDIF
- ENDDO while choice <> "S"
- *
- * ---Generate MENU file.
- SET RAW ON
- ERASE
- SET ALTERNATE TO &outfile
- SET ALTERNATE ON
- ? [* Program.: ] + outfile
- ? [* Author..: ] + yourname
- ? [* Date....: ] + DATE()
- ? [* Notice..: Copyright 19] + $( DATE(), 7, 2 ) +;
- [, All Rights Reserved]
- ? [* Notes...: ]
- ? [* Local...: select, selectnum]
- ? [*]
- ? [SET TALK OFF]
- ? [SET BELL OFF]
- ? [SET COLON OFF]
- ?
- ? [DO WHILE T]
- ?
- ? [ERASE]
- ? [@ 1, 0 SAY "========================================"]
- ? [@ 1,40 SAY "========================================"]
- ? [@ 2, 0 SAY "||"]
- ? [@ 2,] + STR( col:hdg, 2 ) + [ SAY "] + expanded + ["]
- ? [@ 2,78 SAY "||"]
- ? [@ 3, 0 SAY "========================================"]
- ? [@ 3,40 SAY "========================================"]
- *
- STORE 4 TO counter
- DO WHILE counter <= totalopts + 7
- ? [@ ] + STR( counter, 2 ) + [, 0 SAY "||"]
- ? [@ ] + STR( counter, 2 ) + [,78 SAY "||"]
- STORE counter+1 TO counter
- ENDDO
- ? [@ ] + STR(counter,2) +;
- [, 0 SAY "========================================"]
- ? [@ ] + STR(counter,2) +;
- [,40 SAY "========================================"]
- *
- STORE "10" TO item
- DO WHILE VAL(item)-10 <= totalopts
- ? [@ ]+STR(VAL(item)-5,2)+[,]+STR(col:opts,2)+[ SAY ]+;
- ["]+STR(VAL(item)-10,2)+[. ] + option&item + ["]
- STORE STR(VAL(item)+1,2) TO item
- ENDDO
- ? [STORE ] + STR( totalopts + 1, 2 ) + [ TO selectnum]
- ? [DO WHILE selectnum < 0 .OR. selectnum > ]+STR(totalopts,2)
- IF totalopts < 10
- ? [ STORE " " TO select]
- ? [ @ ]+STR(totalopts+8,2)+[,33 SAY " select : : "]
- ? [ @ ]+STR(totalopts+8,2)+[,42 GET select PICTURE "#"]
- ELSE
- ? [ STORE " " TO select]
- ? [ @ ]+STR(totalopts+8,2)+[,33 SAY " select : : "]
- ? [ @ ]+STR(totalopts+8,2)+[,42 GET select PICTURE "##"]
- ENDIF
- ? [ READ]
- ? [ STORE VAL(select) TO selectnum]
- ? [ENDDO]
- ?
- ? [DO CASE]
- ? [ CASE selectnum= 0]
- ? [ SET COLON ON]
- ? [ SET BELL ON]
- ? [ SET TALK ON]
- ? [ CLEAR]
- ? [ RETURN]
- STORE "11" TO item
- DO WHILE VAL( item ) - 10 <= totalopts
- ? [ CASE selectnum=] + STR( VAL( item ) - 10, 2 )
- ? [ * DO ] + option&item
- IF program&item <> " "
- ? [ DO ] + program&item
- ENDIF
- STORE STR(VAL(item)+1,2) TO item
- ENDDO
- ? [ENDCASE]
- ?
- ? [ENDDO T]
- ? [* EOF: ] + outfile
- ?
- SET ALTERNATE OFF
- SET ALTERNATE TO
- *
- * ---Generate SUB-MENU programs.
- *
- STORE "11" TO item
- DO WHILE VAL( item ) - 10 <= totalopts
- STORE !( program&item ) + extension TO subfile
- IF program&item = " " .OR. FILE ( subfile )
- STORE STR( VAL( item ) + 1, 2 ) TO item
- LOOP
- ENDIF
- STORE !( option&item ) TO heading
- STORE " " TO expanded
- *
- * ---E X P A N D h e a d i n g .
- *
- * ---Will NOT correctly expand the heading if more
- * ---than one space separates the words.
- SET EXACT ON
- DO WHILE heading <> " "
- STORE @(" ",heading) TO pos
- IF pos > 0
- STORE $( heading, 1, pos - 1 ) TO word
- STORE $(heading,pos+1,LEN(heading)-pos) TO heading
- ELSE
- STORE heading TO word
- STORE " " TO heading
- ENDIF
- STORE 1 TO counter
- DO WHILE counter <= LEN( word )
- STORE expanded + $( word, counter, 1 ) + " " TO expanded
- STORE counter + 1 TO counter
- ENDDO
- STORE expanded + " " TO expanded
- ENDDO
- STORE TRIM( expanded ) TO expanded
- STORE $( expanded, 2, LEN( expanded ) ) TO expanded
- SET EXACT OFF
- *
- * ---Generate SUB-MENU file.
- SET RAW ON
- ERASE
- SET ALTERNATE TO &subfile
- SET ALTERNATE ON
- ? [* Program.: ] + subfile
- ? [* Author..: ] + yourname
- ? [* Date....: ] + DATE()
- ? [* Notice..: Copyright 19] + $( DATE(), 7, 2 ) +;
- [, All Rights Reserved]
- ? [* Notes...: ]
- ? [*]
- ? [ERASE]
- ? [@ 2, 0 SAY "] + expanded + ["]
- ? [@ 2,72 SAY DATE()]
- ? [@ 3, 0 SAY "========================================"]
- ? [@ 3,40 SAY "========================================"]
- ? [STORE " " TO select]
- ? [@ 5,0 SAY "Strike any key to continue... ";]
- ? [ GET select PICTURE "!"]
- ? [READ]
- ? [*]
- ? [RETURN]
- ? [* EOF: ] + subfile
- ?
- SET RAW OFF
- SET ALTERNATE OFF
- SET ALTERNATE TO
- STORE STR( VAL( item ) + 1, 2 ) TO item
- ENDDO
- *
- ERASE
- STORE $( outfile, 1, @(".",outfile) - 1 ) TO outfile
- ? [TO START "] + outfile + [" MAIN MENU, TYPE THE FOLLOWING:]
- ? [.]
- ? [. DO ]+outfile
- ? [.]
- ? [.]
- CLEAR
- SET TALK ON
- SET RAW OFF
- RETURN
- * EOF: MENUGEN.PRG