Category : BASIC Source Code
Archive   : QB_CODE.ZIP
Filename : TESTDOS2.BAS

 
Output of file : TESTDOS2.BAS contained in archive : QB_CODE.ZIP

DECLARE SUB EditFiles (LePath$(),Flname$(),Ext$(),NFile%,_
FindStr$(),ReplaceStr$(),NStr%,EchoPrint%)
DECLARE SUB Center.Message (Msg$, Line.Num%)
DECLARE SUB Blank.Lines (M%)
DECLARE SUB Display.Heading ()
DECLARE FUNCTION YesNo$ (Msg$)
DECLARE FUNCTION Integer.In.Range% (Msg$, Lo%, Hi%)

' QuickBASIC 4.0 program that uses module DOSFILE.BAS
' to perform fast editing on a collection of files.
' Copyright (c) 1988 Namir Clement Shammas
'
' Modules Required:
' DOSFILE.BAS
' TOOLBOX0.BAS

OPTION BASE 1

DIM LePath$(20), F$(20), Ext$(20), FindStr$(20), ReplaceStr$(20)

CALL Display.Heading
OK$ = YesNo$("Need to invoke DOS shell")

IF OK$ = "Y" THEN
CALL CallDos
CALL Display.Heading
ELSE
PRINT
END IF

NFile% = Integer.In.Range%("Number of files (1 to 20)", 1, 20)
PRINT

DO

INPUT "Enter default pathname "; DefPath$
PRINT
INPUT "Enter default filename "; DefName$
PRINT
INPUT "Enter default file extension name "; DefExt$
PRINT
OK$ = YesNo$("Information correct")
PRINT

LOOP UNTIL OK$ = "Y"

ON ERROR GOTO BAD.FILES

' Obtain filenames
FOR I% = 1 TO NFile%
CLS
PRINT "For file # "; I%
PRINT
INPUT "Enter pathname [ [Enter] = default] "; LePath$(I%)
IF LePath$(I%) = "" THEN LePath$(I%) = DefPath$
PRINT
INPUT "Enter filename [ [Enter] = default] "; F$(I%)
IF F$(I%) = "" THEN F$(I%) = DefName$
PRINT
INPUT "Enter extension filename [ [Enter] = default] "; Ext$(I%)
IF Ext$(I%) = "" THEN Ext$(I%) = DefExt$
PRINT
TF$ = LePath$(I%) + F$(I%) + "." + Ext$(I%)
OPEN "I", 1, TF$' test if present
CLOSE #1
NEXT I%

ON ERROR GOTO 0

CLS
' Obtain find/replace strings
NStr% = Integer.In.Range%(_
"Number of find/replace strings (1 to 20)", 1, 20)

FOR I% = 1 TO NStr%
PRINT
PRINT "For Find/Replace string # "; I%
INPUT "Enter search string "; FindStr$(I%)
INPUT "Enter replace string ([Enter] for find only) ";_
ReplaceStr$(I%)
NEXT I%

PRINT
OK$ = YesNo$("Echo to printer")
PRINT
IF OK$ = "Y" THEN EchoPrint% = 1 ELSE EchoPrint% = 0

CALL EditFiles(LePath$(), F$(), Ext$(), NFile%, FindStr$(),_
ReplaceStr$(), NStr%, EchoPrint%)

PRINT
PRINT "Program terminated"

END

' Bad filename error handler
BAD.FILES:
PRINT
PRINT "Error: Cannot find file "; TF$
PRINT
PRINT "Please re-enter information"
PRINT
PRINT "press any key to continue "; : A.KEY$ = INPUT$(1)
I% = I% - 1 ' decrement FOR loop counter to re-enter data
RESUME NEXT

REM $DYNAMIC
SUB Display.Heading STATIC
' Subroutine to clear screen and display heading
CLS
CALL Center.Message("FAST MULTI-FILE EDITING PROGRAM", 1)
CALL Center.Message("-------------------------------", 2)
CALL Blank.Lines(3)

END SUB