⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manager.bas

📁 StarCom Manager 3.06 用QB编写的管理程序
💻 BAS
📖 第 1 页 / 共 3 页
字号:
eofp:
LPRINT line$
PRINT "Finished."
CLOSE 1
file$ = ""
LPRINT CHR$(12)
PRINT
PRINT
PRINT "Print another file (y/n)? ";

waitprin:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO printfil
IF UCASE$(a$) = "N" THEN goto menu

'THIS IS THE END OF THE ROUTINE FOR PRINTING FILES.


'HERE IS THE ROUTINE FOR COPYING FILES.

copyfile:
ON ERROR GOTO copyfier
CLS
PRINT "                                   Copy File"
PRINT
PRINT
PRINT "NOTE: The date and time of the copied file will be changed to today's"
PRINT "time and date."
PRINT
PRINT "Press any key to continue. ";
GOSUB continue

copymore:
file1$=""
file2$=""
CLS
PRINT SPACE$(68);
COLOR 0, 7
PRINT "Esc=Quit"
COLOR 7, 0
PRINT
PRINT "File to copy (include drive and path)? ";
GOSUB retypefi
if a$=chr$(27) then goto menu
file1$ = file$ 'Input file.
file$ = ""     'We need FILE$ again right away, so clean it up.
PRINT
PRINT "Destination (include drive and path)? ";
GOSUB retypefi
if a$=chr$(27) then goto menu
file2$ = file$ 'Output file.
file$ = ""

reinput:
OPEN file1$ FOR BINARY AS 1 'This mode copies all types of files.

reoutput:
OPEN file2$ FOR BINARY AS 2
remaining# = LOF(1) 'LOF=Length Of File.

copycont:
IF remaining# > 4096 THEN thispass# = 4096 ELSE thispass# = remaining#
buffer$ = SPACE$(thispass#)
GET #1, , buffer$
PUT #2, , buffer$
remaining# = remaining# - thispass#
IF remaining# > 0 THEN GOTO copycont
CLOSE
PRINT
PRINT
PRINT UCASE$(file1$); " has been copied to "; UCASE$(file2$); "."
PRINT
PRINT "Copy another? ";

wait5:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO copymore

IF UCASE$(a$) = "N" THEN 
file1$=""
file2$=""
goto menu
endif

GOTO wait5

'THIS IS THE END OF THE ROUTINE FOR COPYING A FILE.


'HERE IS THE ROUTINE FOR MOVING FILES.

movefile:
ON ERROR GOTO movefier
CLS
PRINT "                                   Move File"
PRINT
PRINT
PRINT "NOTE: The date and time of the moved file will be changed to today's"
PRINT "time and date.  The original will be destroyed."
PRINT
PRINT "Press any key to continue. ";
GOSUB continue

movemore:
CLS
PRINT SPACE$(68);
COLOR 0, 7
PRINT "Esc=Quit"
COLOR 7, 0
PRINT
PRINT "File to move (include drive and path)? ";
GOSUB retypefi
file1$ = file$
file$ = ""
IF a$ = CHR$(27) THEN goto menu
PRINT
PRINT "Destination (include drive and path)? ";
GOSUB retypefi
file2$ = file$
file$ = ""
IF a$ = CHR$(27) THEN goto menu

reinputm:
OPEN file1$ FOR BINARY AS 1

reoutpum:
OPEN file2$ FOR BINARY AS 2
remaining# = LOF(1)

movecont: 'Copy the file.
IF remaining# > 4096 THEN thispass# = 4096 ELSE thispass# = remaining#
buffer$ = SPACE$(thispass#)
GET #1, , buffer$
PUT #2, , buffer$
remaining# = remaining# - thispass#
IF remaining# > 0 THEN GOTO movecont
CLOSE
KILL file1$ 'Get rid of original, giving illusion of having moved the file.
PRINT
PRINT
PRINT UCASE$(file1$); " has been moved to "; UCASE$(file2$); "."
PRINT
PRINT "Move another? ";

wait6:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO movemore
IF UCASE$(a$) = "N" THEN goto menu
GOTO wait6


'HERE IS THE OPTION FOR RENAMING FILES.

renfile:
ON ERROR GOTO renfilee
CLS
PRINT "                                 Rename Files"
PRINT
PRINT
PRINT SPACE$(68);
COLOR 0, 7
PRINT "Esc=Quit"
COLOR 7, 0
PRINT "Name of file to change (include drive and path)? ";
GOSUB retypefi
file1$ = file$
file$ = ""
IF a$ = CHR$(27) THEN goto menu
PRINT
PRINT
PRINT
PRINT "New name for "; UCASE$(file1$); "? ";
GOSUB retypefi
file2$ = file$
file$ = ""
IF a$ = CHR$(27) THEN goto menu

refile:
NAME file1$ AS file2$
PRINT
PRINT
PRINT UCASE$(file1$); " has been renamed "; UCASE$(file2$); "."
file1$ = ""
file2$ = ""
PRINT
PRINT "Rename another? (y/n) ";

wait7:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO renfile
IF UCASE$(a$) = "N" THEN goto menu
GOTO wait7

'THIS IS THE END OF THE ROUTINE FOR RENAMING FILES.


'HERE IS THE ROUTINE FOR DELETING FILES.

killfile:
ON ERROR GOTO killfier
CLS
PRINT "                                 Delete Files"
PRINT
PRINT

'What we want here is to place the cursor on the right hand side of the
'screen.  We could use the LOCATE command, but this is easier to use in
'text mode, since we don't have to remember the coordinates for the row
'position; we're already on the line we want, anyway.

'Now, once we have the silly thing positioned where we want it, we want to
'keep it there until we can give some more directions.  The semicolon will
'suppress the carriage return, so we can tack some stuff onto the end of
'all those spaces we just printed.

PRINT SPACE$(68);

'We want to make it easy for the user to quit, so we'll put that direction
'into reversed lettering, making it easy to see.  Color 7 is white, and 0
'is black.  Normally, we would have color 7,0, which is white on black.
'But we want to reverse that, which is simple enough (if we remember to
'change it back when we're done, that is.

COLOR 0, 7

'Now, the next line will stand out and keep all the hard work we put in to
'make it easy for the user to quit from going to waste.

PRINT "Esc=Quit"

'Better change back to normal colors, or we'll have a mess on the screen.

COLOR 7, 0
PRINT "File to delete? ";
GOSUB retypefi
IF a$ = CHR$(27) THEN goto menu
PRINT
PRINT
PRINT
PRINT "All the data in "; UCASE$(file$); " will be destroyed."
PRINT
PRINT
PRINT "Press any key to continue, or Esc to quit. ";
GOSUB continue 'Press a key.

IF a$ = CHR$(27) THEN 'Was key Esc?
file$ = "" 'If so, forget there was ever any file to delete in the first 
           'place.
goto menu
END IF

rekill:
KILL file$
PRINT
PRINT
PRINT UCASE$(file$); " has been deleted."
file$ = ""
PRINT
'Note the space between the right parenthesis (in the line following) and
'the quote mark.  It's just a little touch, but it makes a world of
'difference in the readability of your screen writes.
'
'With INPUT the user would have to press Enter.  I've always considered
'this a pain in the butt with all the programs I've ever used if I'm just
'typing a Y or N response, so I try to avoid it here.

PRINT "Delete another? (y/n) ";

wait8:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO killfile
IF UCASE$(a$) = "N" THEN goto menu
GOTO wait8

'THIS IS THE END OF THE ROUTINE FOR DELETING FILES.


'HERE IS THE ERROR ROUTINE FOR RUNNING OTHER PROGRAMS.

runother:
ON ERROR GOTO runothee
CLS
PRINT "                              Run Other Programs"
PRINT
PRINT SPACE$(68);
COLOR 0, 7
PRINT "Esc=Quit"
COLOR 7, 0
PRINT
PRINT "Type in the drive, path, program you want to run, and any arguments"
PRINT "you want to include (example: C:\DOS\CHKDSK A:)."
PRINT

'The CURSOR subroutine tells The Manager to save the current screen location
'of the cursor.

GOSUB cursor

'As far as I can tell, the location of COMMAND.COM on disk is always in
'ENVIRON$(1).  This is not necessarily the case with other environment strings.
'Notably, environment strings you manipulate will tend to change their
'locations after they've been changed.  In other words, if you fuss with your
'PATH setting, it's likely to change from ENVIRON$(2) to another number,
'probably the end of the list of environment strings.  You need a slightly
'fancier method for finding such strings, which is demonstrated in the routine
'for viewing your path.

'This routine allows you to shell to DOS by just pressing Enter [CHR$(13)].
'The first thing you need to do is find COMSPEC, which has always been at
'location 1 of ENVIRON$ as far as I've been able to tell.

commandc$ = ENVIRON$(1)

'Once we've found COMSPEC and initialized it to a variable, we need to remove
'the "COMSPEC=" part so it'll be callable by the program (and so it'll look
'better on-screen).  We'll cut out the stuff after "COMSPEC=", which is the
'location of COMMAND.COM, and print it to the screen.

PRINT MID$(commandc$, 9, 79);
GOSUB continue

IF a$ = CHR$(13) THEN
CLS
PRINT "Use the DOS command EXIT to return to The Manager."
SHELL 'Without any arguments, this just jumps to DOS.
GOTO runother 'Go back to see if there are any more programs to run.
END IF

IF a$ = CHR$(27) THEN goto menu 'If user is finished or changes mind, quit.

'If anything but Enter or Esc is pressed, the COMMAND.COM location is removed
'from the screen, the cursor goes back to the start, and the key pressed is
'added to the variable which will be created in RETYPEFI:.

'Return to the original cursor location.

LOCATE a, b

'Print spaces for about a line, to delete the COMMAND.COM location that was on
'the screen.

PRINT SPACE$(68);

'Go back to the start of the line, so we can put stuff there.

LOCATE a, b

'And print the keypress.

PRINT a$;

'Now we'll add the keypress to the variable (FILE$) that RETYPEFI: uses, which
'is currently nothing; as a result, FILE$ now equals the keypress, and is
'ready for other characters to be added.  A lot of trouble, but it sure makes
'your programs look professional.

file$ = file$ + a$

'Now we'll pop down to the subroutine that allows other characters to be added
'to FILE$.

GOSUB retypefi

IF a$ = CHR$(27) THEN 'Esc pressed?
file$ = "" 'If so, clean house.
goto menu  'Quit.
END IF

rerun:
SHELL file$

'If you're running programs that don't pause after they're done, such as 
'CHKDSK, you'll go back to the program too fast to see what's on the screen.
'This next routine pauses so you can see what's on the screen before quitting.

PRINT "Press any key to return to The Manager."
GOSUB continue
file$ = ""
CLS
PRINT "Would you like to run another program? ";

wait11:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO runother
IF UCASE$(a$) = "N" THEN goto menu
GOTO wait11

'THIS IS THE END OF THE ROUTINE FOR RUNNING OTHER PROGRAMS.


'HERE IS THE ROUTINE FOR WORKING WITH CONFIG.SYS

changecon:
ON ERROR GOTO 0 'No error routines plugged in yet.
CLS
PRINT "                      View or Change Your CONFIG.SYS File"
PRINT
PRINT

'We want to back up the rather important CONFIG.SYS file, which we assume
'is in the root directory of the drive in question.  In order to do that,
'we need to know which drive the file is on.

PRINT "On which drive is your CONFIG.SYS file? ";
GOSUB retypefi
IF a$ = CHR$(27) THEN GOTO menu

redrive:
file1$ = UCASE$(file$) + "\config.sys"
file2$ = UCASE$(file$) + "\config.bak"
file$ = ""

confmenu:
CLS
PRINT "You have the following options:"
PRINT
PRINT
PRINT "F1- Just view the CONFIG.SYS file."
PRINT
PRINT "F2- Add lines to the end of your file."
PRINT
PRINT "F3- Create a new CONFIG.SYS file."
PRINT
PRINT "Esc- Return to the Main Options Menu."
PRINT
PRINT
PRINT "Please press the key corresponding to your choice. ";

wait17:
GOSUB continue
IF a$ = CHR$(27) THEN GOTO menu

IF a$ = CHR$(0) + CHR$(59) THEN
CLS
GOSUB seesys
GOTO confmenu
END IF

IF a$ = CHR$(0) + CHR$(60) THEN
CLS
GOSUB appendln
GOSUB seesys
GOTO confmenu
END IF

IF a$ = CHR$(0) + CHR$(61) THEN
CLS
GOTO newfilec
END IF

GOTO wait17


'THIS SECTION CREATES A NEW CONFIG.SYS FILE.

newfilec:
CLS

'Here's where all that work initializing CONFIG.SYS to a string variable
'pays off; we get to rename it CONFIG.BAK, thus averting disaster to some
'degree at least.

NAME file1$ AS file2$
PRINT
PRINT
PRINT "Your CONFIG.SYS file has been changed to CONFIG.BAK in order to save"
PRINT "it for future use.  To use it later, your new CONFIG.SYS will have to"
PRINT "be renamed to something else (for example, CONFIG.X), and your .BAK"
PRINT "file renamed CONFIG.SYS."
PRINT
PRINT
PRINT "Press any key to continue. ";
GOSUB continue

changeagn:
CLS
PRINT SPACE$(68);
COLOR 0, 7
PRINT "Esc=Quit"
COLOR 7, 0
OPEN "o", 1, file1$ 'Equivalent to OPEN FILE1$ FOR OUTPUT AS 1.
PRINT "How many files do you want? ";
GOSUB retypefi

'if Esc is pressed at this point, we can go to the routine that restores
'the old CONFIG.SYS, and let the user quit.

IF a$ = CHR$(27) THEN GOTO restorec

'Otherwise, we write the string to the new file.

PRINT #1, "files=" + file$
file$ = ""
PRINT

'Now we do the same thing with BUFFERS=.

PRINT "How many buffers do you want? ";
GOSUB retypefi
IF a$ = CHR$(27) THEN GOTO devcagain 'This time, Esc="Done".
PRINT #1, "buffers=" + file$
file$ = ""

'The user may want to include device drivers, but be unsure of which one or
'the spelling of the driver wanted.  So, we send him/her to the routine
'that deals with listing those drivers.

GOSUB listsys

devcagain:
PRINT
PRINT
PRINT "Which device would you like to include (N for none) ";
GOSUB retypefi

IF UCASE$(file$) = "N" THEN GOTO nodevice
PRINT #1, "device=" + file$
file$ = ""
PRINT
PRINT "Would you like to include more devices? ";

wait18:
GOSUB continue
IF UCASE$(a$) = "Y" THEN GOTO devcagain
IF UCASE$(a$) = "N" THEN GOTO nodevice
GOTO wait18

nodevice:
PRINT
PRINT
PRINT "Do you want Break on or off (if not sure, type OFF)? ";
GOSUB retypefi

IF UCASE$(file$) = "ON" THEN
PRINT #1, "break=on"
END IF

'Now we ask for approval from the user.

CLOSE 1
file$ = ""
GOSUB seesys
CLS
PRINT "If this is not O.K. AND you want to go back and change the file, press"
PRINT "C and then press Enter."
PRINT
PRINT "To restore your original CONFIG.SYS file, press R and Enter."
PRINT
PRINT "If you're happy with it as is, type OK and Enter."
PRINT
PRINT "> ";
GOSUB retypefi

okdecide:

IF UCASE$(file$) = "C" THEN
file$ = ""
GOTO changeagn
END IF

IF UCASE$(file$) = "R" THEN
file$ = ""
GOTO restorec
END IF

IF UCASE$(file$) = "OK" THEN
file$ = ""
GOTO confmenu
END IF

PRINT
PRINT "You must choose between C, R, or OK."
PRINT
GOSUB retypefi
GOTO okdecide

'Here we restore things if it didn't work out the way the user wanted.

restorec:
CLS
CLOSE 1
CLOSE 2
KILL file1$
NAME file2$ AS file1$
PRINT "Your original CONFIG.SYS file has been restored."
PRINT
PRINT
PRINT "Press any key to continue. ";
GOSUB continue
GOTO confmenu


'HERE IS THE ROUTINE FOR LOOKING AT THE CONFIG.SYS FILE.

seesys:
CLOSE 1
CLOSE 2
PRINT
PRINT "Here is your file:"
PRINT
PRINT
OPEN file1$ FOR INPUT AS 1

nextlnco:

LINE INPUT #1, line$
PRINT line$
IF EOF(1) THEN
CLOSE 1
PRINT
PRINT
PRINT "Press any key to continue. ";
GOSUB continue
RETURN
END IF

GOTO nextlnco

'THIS IS THE END OF THE ROUTINE FOR LOOKING AT THE CONFIG.SYS FILE.


'HERE IS THE ROUTINE FOR ADDING LINES TO THE END OF CONFIG.SYS

appendln:
CLS
PRINT SPACE$(63);
COLOR 0, 7
PRINT "Esc=Quit/Done"
COLOR 7, 0
PRINT
CLOSE 1
CLOSE 2
OPEN "a", 1, file1$ 'Equivalent to OPEN FILE$ FOR APPEND AS 1.

appendagn:
PRINT
PRINT "Line to add? ";
GOSUB retypefi

'If the user presses Esc, we can just close the file and return.  If
'nothing was added to the file, it's not affected by being opened, so we
'don't have to get fancy with aborts.  For once.

IF a$ = CHR$(27) THEN
CLOSE 1
file$ = ""
RETURN
END IF

PRINT #1, file$
GOTO appendagn

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -