📄 manager.bas
字号:
'MANAGER.EXE
'If there are program lines in this source code which aren't clear to you,
'drop me a line and I'll try to comment them so as to explain things a bit
'more clearly.
'consecutive to wait30:
'Check for parameters.
'This section reads INSTALL.CFG. This feature installs an automatic
'parameter, in essence; once installed, it'll go directly to a specific menu
'option.
'INSTALL.CFG is only read if no parameters have been specified from DOS.
IF COMMAND$ = "" THEN
OPEN "i", 1, "install.cfg"
line INPUT #1, install$ 'Read a line from INSTALL.CFG. This will have more
'validity later, when there's more to the file.
CLOSE 1 'Done.
GOTO doautopa 'Go to the routine that decides what to do depending on what was
'in INSTALL.CFG.
END IF
'If a parameter has been specified, INSTALL.CFG is not read. Instead, the
'parameter is read and you get sent to the section related to that
'parameter.
'The parameters are case-insensitive courtesy of QuickBASIC; its COMMAND$
'function returns only upper-case, regardless of the case at the command line.
'Find files (clone of DIR /W)
IF COMMAND$ = "/S" THEN GOTO seefiles
'Read text files (combination of TYPE and MORE)
IF COMMAND$ = "/V" THEN GOTO readfile
'Get length of file (part of what's missing in the DIR clone)
IF COMMAND$="/F" then goto filesize
'Print files (clone of COPY filename.ext PRN, with pause and quit options)
IF COMMAND$ = "/L" THEN GOTO printfil
'Copy files (decent clone of COPY)
IF COMMAND$ = "/C" THEN GOTO copyfile
'Move files (fairly decent clone of COPY and DEL)
IF COMMAND$ = "/O" THEN GOTO movefile
'Rename files (clone of REN/RENAME)
IF COMMAND$ = "/N" THEN GOTO renfile
'Delete files (clone of DEL/ERASE)
IF COMMAND$ = "/D" THEN GOTO killfile
'Run other programs (clone of COMMAND /C)
IF COMMAND$ = "/R" THEN GOTO runother
'View/modify CONFIG.SYS (no DOS equivalent that I know of)
IF COMMAND$ = "/CO" THEN GOTO changecon
'View/modify AUTOEXEC.BAT (no DOS equivalent that I know of)
IF COMMAND$ = "/AU" THEN GOTO chngauto
'Make directory (clone of MD/MKDIR)
IF COMMAND$ = "/M" THEN GOTO makedir
'Remove directory (fair clone of RD/RMDIR)
IF COMMAND$ = "/E" THEN GOTO removedr
'Change default directory (extremely poor clone of CD/CHDIR)
IF COMMAND$ = "/CD" THEN GOTO changedr
'Check for graphics card (no DOS equivalent that I know of)
IF COMMAND$ = "/P" THEN GOTO chckgrph
'Blank screen (no DOS equivalent that I know of)
IF COMMAND$ = "/B" THEN GOTO blankscr
'Go to the 40-column version of The Manager, which is really horrible (I've
'had little or no feedback on this option, so I'm assuming the visually
'impaired couldn't care less until further notice. Since I'm not visually
'impaired myself, I've put that mode on the back burner).
IF COMMAND$ = "/40" THEN GOTO managr40
'See a list of DOS parameter options (vaguely similar to DOS' HELP.EXE, but
'not really anything like it, since it's not nearly so involved. Hmmm,
'might be worth it to make an enhanced help feature, mightn't it?)
IF COMMAND$ = "/?" THEN GOTO help
'Crappy Calculator (no DOS equivalent that I know of)
IF COMMAND$ = "/CR" THEN GOTO calculat
'Get the time and/or date (partial clone of TIME and DATE; you can't set
'either, but you can read them)
IF COMMAND$ = "/G" THEN GOTO timedate
'See a list of ASCII codes, decimal only (no DOS equivalent that I know of)
IF COMMAND$ = "/A" THEN
shell "autil180.com /a"
goto menu2
endif
'Install a DOS parameter (vaguely similar to SET)
if command$="/I" then goto install
'See PATH (partial clone of PATH; you can only view the path, not change it)
if command$="/PA" then goto seepath
'............................................................................
'40-column parameters.
'............................................................................
'40-column list of DOS parameters option.
IF COMMAND$ = "/40 ?" THEN goto help40
'40-column delete files option.
IF COMMAND$ = "/40 D" THEN GOTO killfl40
'40-column make directory option.
IF COMMAND$ = "/40 M" THEN GOTO makedr40
'40-column rename files option.
IF COMMAND$ = "/40 N" THEN GOTO renfil40
'40-column time/date option.
IF COMMAND$ = "/40 G" THEN goto timedt40
'40-column blank screen option.
IF COMMAND$ = "/40 B" THEN
menuflag=1 'The blank screen option checks this variable. If it's 1, it goes
'to OPTION40: instead of OPTIONS: when it's finished blanking.
goto blankscr
END IF
'40-column find files option.
IF COMMAND$ = "/40 S" THEN GOTO seefil40
'The /40 v parameter doesn't do anything right now; it's just there for
'when I get a read files option that works in 40-column mode.
IF COMMAND$ = "/40 V" THEN GOTO menu40
'40-column print files option.
IF COMMAND$ = "/40 L" THEN goto prfile40
'40-column run other programs option.
IF COMMAND$ = "/40 R" THEN goto runoth40
'40-column remove directory option.
IF COMMAND$ = "/40 E" THEN goto removd40
'Copy files option.
IF COMMAND$ = "/40 C" THEN goto copyfl40
'40-column move files option.
IF COMMAND$ = "/40 O" THEN
SHELL "util1-40.com/o"
GOTO menu340
END IF
' If no parameter was specified, the above batch of IF statements is
' bypassed with a GOTO statement, to this section, which looks at the
' INSTALL.CFG file.
doautopa:
IF install$ = "/?" THEN GOTO help
IF install$ = "/d" THEN GOTO killfile
IF install$ = "/m" THEN GOTO makedir
IF install$ = "/n" THEN GOTO renfile
IF install$ = "/g" THEN GOTO timedate
IF install$ = "/b" THEN GOTO blankscr
IF install$ = "/p" THEN GOTO chckgrph
IF install$ = "/s" THEN GOTO seefiles
IF install$ = "/v" THEN GOTO readfile
IF install$ = "/l" THEN GOTO printfil
IF install$ = "/r" THEN GOTO runother
IF install$ = "/e" THEN GOTO removedr
IF install$ = "/c" THEN GOTO copyfile
IF install$ = "/o" THEN GOTO movefile
IF install$ = "/40" THEN GOTO managr40
'Here's a recent addition; if you set it up from the main program, you can
'bypass the opening screen, which can get kind of irritating after a while
'(trust me on this, I can't test the silly thing if I install ANYthing, and
'that opening screen really gets on my nerves).
IF install$ = "bypass" THEN GOTO menu
IF install$ = "/cd" THEN GOTO changedr
IF install$ = "/cr" THEN GOTO calculat
IF install$ = "/a" THEN
shell "autil180.com /a"
goto menu2
endif
IF install$ = "/au" THEN GOTO chngauto
IF install$ = "/co" THEN GOTO changecon
'If no parameters are installed, and INSTALL.CFG didn't contain one of the
'above parameters, all the IF statements fail (or "fall through"), and we
'begin from the beginning.
'Set up and print intro screen.
CLS
PRINT " The Manager 3.06"
PRINT
PRINT
PRINT " By Matt Roberts"
PRINT " 5 Cedar St., #8"
PRINT " Montpelier, Vt 05602-3006"
PRINT " (802)223-2553"
PRINT
PRINT
PRINT " If you find the programs on this disk useful, a donation of"
PRINT " $5.00 would be greatly appreciated. Thanks."
PRINT
PRINT
PRINT " If you're having trouble using this program, you can call"
PRINT " between 9AM and 9PM (EST), and I'll try to help."
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Press any key to continue. ";
'This use of the CURSOR: subroutine is mainly a matter of laziness; it's used
'with better purpose in the RETYPFI: routine. It is a handy little bugger,
'though.
GOSUB cursor
'The cursor is off by default. I prefer it when I'm typing in stuff (which
'you get to do a lot in this program), so I turned it on with that 1 at the
'end of the LOCATE command. The first two values give it a location, and the
'third tells it whether or not to turn on the cursor. 1 is on, and 0 (the
'default) is off.
LOCATE a, b, 1
'The CONTINUE: subroutine waits for a keypress and, if it's a letter key,
'makes it upper-case before returning to the main program.
GOSUB continue
'Intro screen is now printed.
'Now direct the program to create a menu of options.
'Here is the menu of options.
menu:
CLS
PRINT " Your Options"
PRINT
PRINT
PRINT "F1- Find Files. F10- Work with CONFIG.SYS."
PRINT
PRINT "F2- Read Files. <Alt-F1>- Work with AUTOEXEC.BAT."
PRINT
PRINT "F3- Length of File. <Alt-F2>- Make Directory."
PRINT
PRINT "F4- Print Files. <Alt-F3>- Remove Directory."
PRINT
PRINT "F5- Copy Files. <Alt-F4>- Change Default Directory."
PRINT
PRINT "F6- Move Files. <Alt-F5>- Check for Graphics Card."
PRINT
PRINT "F7- Rename Files. <Alt-F6>- Blank Screen."
PRINT
PRINT "F8- Delete Files. N- Next Menu."
PRINT
PRINT "F9- Run Other Programs. Esc- Quit and Return to DOS."
PRINT
PRINT
PRINT "Please press the key corresponding to your choice. ";
wait2:
GOSUB continue 'Wait for a keypress.
'The Esc key is chr$(27). Early in my computing life someone mentioned that
'this key ought to be the universal quit key. He was complaining about a game
'that required you to press Q or something like that. I thought his idea made
'a lot of sense, and I've used it ever since I figured out how.
IF a$ = CHR$(27) THEN
CLS
END
END IF
'UCASE$ gives us the upper-case value of A$. If it was already upper-case,
'that's OK, since the upper-case value of an upper-case letter is upper-case.
IF UCASE$(a$) = "N" THEN
GOTO menu2
END IF
'The extended keys (function keys, Alt, etc.) can be accessed by CHR$, but are
'duplicated elsewhere on the keyboard. For instance, the F1 key returns the
'same code as the semi-colon. The only difference is in the use of a "scan
'code", which is ASCII(0) [CHR$(0)]. The combination of ASCII 0 and the other
'code belongs to only one key. For instance, CHR$(59) belongs to both the
'semi-colon and the F1 key, but only the F1 key has CHR$(0) and CHR$(59) at
'the same time. You can use this method to access most of the extended keys
'on the keyboard.
IF a$ = CHR$(0) + CHR$(59) THEN goto seefiles
IF a$ = CHR$(0) + CHR$(60) THEN goto readfile
IF a$ = CHR$(0) + CHR$(61) THEN goto filesize
IF a$ = CHR$(0) + CHR$(62) THEN goto printfil
IF a$ = CHR$(0) + CHR$(63) THEN goto copyfile
IF a$ = CHR$(0) + CHR$(64) THEN goto movefile
IF a$ = CHR$(0) + CHR$(65) THEN goto renfile
IF a$ = CHR$(0) + CHR$(66) THEN goto killfile
IF a$ = CHR$(0) + CHR$(67) THEN goto runother
IF a$ = CHR$(0) + CHR$(68) THEN GOTO changecon
IF a$ = CHR$(0) + CHR$(104) THEN GOTO chngauto
IF a$ = CHR$(0) + CHR$(105) THEN goto makedir
IF a$ = CHR$(0) + CHR$(106) THEN GOTO removedr
IF a$ = CHR$(0) + CHR$(107) THEN goto changedr
IF a$ = CHR$(0) + CHR$(108) THEN goto chckgrph
IF a$ = CHR$(0) + CHR$(109) THEN goto blankscr
GOTO wait2
menu2:
CLS
PRINT " More Options"
PRINT
PRINT
PRINT "<Alt-F7>- 40-column Mode. F- First Menu."
PRINT
PRINT "<Alt-F8>- DOS Parameters. Esc- Quit to DOS."
PRINT
PRINT "<Alt-F9>- Crappy Calculator."
PRINT
PRINT "<Alt-F10>- Get Time/Date."
PRINT
PRINT "<Ctrl-F1>- ASCII Code List."
PRINT
PRINT "<Ctrl-F2>- Install Parameter."
PRINT
PRINT "<Ctrl-F3>- See PATH."
PRINT
PRINT "<Ctrl-F4>- Program Function Keys."
PRINT
PRINT "F- First Menu."
PRINT
PRINT
PRINT "Please press the key corresponding to your choice. ";
gosub cursor
locate a,b,1
wait4usr:
GOSUB continue
IF a$ = CHR$(27) THEN
CLS
END
END IF
IF UCASE$(a$) = "F" THEN GOTO menu
IF a$ = CHR$(0) + CHR$(110) THEN GOTO menu40
IF a$ = CHR$(0) + CHR$(111) THEN goto help
IF a$ = CHR$(0) + CHR$(112) THEN GOTO calculat
IF a$ = CHR$(0) + CHR$(113) THEN goto timedate
IF a$ = CHR$(0) + CHR$(94) THEN
shell "autil180.com /a"
goto menu2
endif
IF a$ = CHR$(0) + CHR$(95) THEN goto install
IF a$ = CHR$(0) + CHR$(96) THEN goto seepath
IF a$ = CHR$(0) + CHR$(97) THEN goto progfunc
GOTO wait4usr:
'............................................................................
' HERE ARE THE MENU OPTIONS (80-COLUMNS)
'............................................................................
'HERE IS THE ROUTINE FOR LOOKING AT AVAILABLE FILES.
seefiles:
'I haven't plugged in any error routines here yet. However, if there are
'other error routines specified in other routines, they would be jumped to
'if something went wrong, with some weird results most likely. So, I disable
'any error routines here.
ON ERROR GOTO 0
seeflagn:
CLS
PRINT " View Your Files"
PRINT
PRINT
PRINT "Which directory? ";
'Here's the routine that lets you type in files. It works better than INPUT
'because you can quit in the middle with the Esc key.
GOSUB retypefi
IF a$ = CHR$(27) THEN GOTO skip
PRINT
'I had to put this next line because of a quirk in the QuickBASIC compiler; it
'always lists the directory as the one the program is being run from.
PRINT "Directory "; UCASE$(file$); " contains these files:"
PRINT
'This line is necessary to tell QuickBASIC that you want to look at the files
'in the directory rather than just find out if the directory exists.
file$ = file$ + "\"
FILES file$ 'Essentially, what you have here is DIR/W.
skip:
file$ = ""
PRINT
PRINT
PRINT "Would you like to view more files (y/n)? ";
'This loop ignores everything but y(Y) or n(N) as responses. Seems obvious,
'but you'd be amazed at how many programs will send you back to the menu if
'any key but n(N) is pressed.
morefile:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO seeflagn
IF UCASE$(a$) = "N" THEN goto menu
GOTO morefile
'THIS IS THE END OF THE ROUTINE FOR LOOKING AT AVAILABLE FILES.
'HERE IS THE ROUTINE FOR DISPLAYING FILE CONTENTS.
readfile:
ON ERROR GOTO readfier 'If something goes wrong, go to the error handler.
CLS
PRINT " View File Contents"
PRINT SPACE$(68); 'Position the cursor for the Esc=Quit message.
COLOR 0, 7 'Reversed lettering. 0=black, 7=white.
PRINT "Esc=Quit"
COLOR 7, 0 'Change it back to normal, or you'll have a mess.
PRINT
PRINT
PRINT "Which file (include drive and path)? ";
GOSUB retypefi
IF a$ = CHR$(27) THEN GOTO viewmore
CLS
PRINT "To pause, press the space bar."
PRINT
PRINT "To quit, press Esc."
PRINT
PRINT "Special characters used in "; UCASE$(file$)
PRINT "may not print in exactly the same manner as the original."
PRINT
PRINT "Also, formatting may not be quite correct."
refiledf:
PRINT "Press any key to continue. ";
GOSUB continue
CLS
reread:
OPEN file$ FOR INPUT AS 1
WHILE NOT EOF(1) 'Keep going as long as the end of file isn't reached.
LINE INPUT #1, line$ 'Bring in one line of text.
linenumb = linenumb + 1 'Keep track of the number of lines.
IF linenumb = 20 OR linenumb > 20 THEN 'Is there a screenful?
PRINT
PRINT
PRINT "Press any key to continue. "; 'If so, pause.
GOSUB continue
IF a$ = CHR$(27) THEN GOTO viewmore 'If "any key" is Esc, quit.
linenumb = 0 'Reset number of lines for next "screen-full count".
CLS 'Looks prettier than just scrolling.
END IF
PRINT line$ 'Print the line you brought in from the file.
a$ = INKEY$ 'Check for keypress.
IF a$ = CHR$(27) THEN 'Esc pressed?
GOTO viewmore 'If so, quit.
a$ = "" 'Reset A$ so it doesn't foul up other routines.
ELSEIF a$ = CHR$(32) THEN 'CHR$(32) is the space bar.
PRINT
PRINT "Press any key to continue. "; 'If space bar pressed, pause.
GOSUB continue
a$ = ""
END IF
WEND
viewmore: 'If aborted or end of file, do this.
CLOSE 1 'Done with the file.
'If there's anything in FILE$, the next time you use RETYPEFI: it'll add your
'keystrokes to whatever is already in FILE$. So, we make it equal nothing.
file$ = ""
PRINT
PRINT
PRINT "Do you want to view more files (y/n)? ";
waitview:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO readfile
IF UCASE$(a$) = "N" THEN goto menu
GOTO waitview
'THIS IS THE END OF THE ROUTINE FOR DISPLAYING FILES.
'HERE IS THE ROUTINE FOR PRINTING FILES.
printfil:
ON ERROR GOTO printfie
CLS
PRINT " Print Files"
PRINT SPACE$(68);
COLOR 0, 7
PRINT "Esc=Quit"
COLOR 7, 0
PRINT
PRINT
PRINT "Which file (include drive and path)? ";
GOSUB retypefi
'It was just easier to make this a separate routine. It could have been
'included in the end-of-file routine, but it would have been kinda tangled and
'hard to change without messing something else up, so I made a separate one.
IF a$ = CHR$(27) THEN
print
print
PRINT "Print another file (y/n)? ";
GOTO waitprin 'This part of the end-of-file routine I was able to use.
END IF
doprintf:
OPEN "i", 1, file$ 'Equivalent to OPEN FILE$ FOR INPUT AS 1.
CLS
COLOR 0, 7
PRINT "Printing..."; UCASE$(file$)
COLOR 7, 0
PRINT
PRINT
PRINT "Press the space bar to pause printing, or Esc to quit."
PRINT
PRINT
printmor:
LINE INPUT #1, line$
LPRINT line$
a$ = INKEY$
IF a$ = CHR$(27) THEN 'Esc pressed?
PRINT "Printing has been terminated. The printer may still have data in its"
PRINT "buffer. If so, it will continue printing until the buffer is empty."
LPRINT CHR$(12) 'Send form feed to the printer.
CLOSE 1
file$ = ""
PRINT
PRINT
PRINT "Print another file (y/n)? ";
GOTO waitprin
END IF
IF a$ = CHR$(32) THEN 'Space bar pressed?
PRINT "Press any key to resume printing. "; 'If so, pause printing.
GOSUB continue
END IF
IF EOF(1) THEN GOTO eofp 'EOF=End Of File.
GOTO printmor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -