{ * CONNECT FILES ROUTINE Connectfiles will open an input file either from the console or from the command buffer. It will open an output file using the primary file name and adds a default extension whether or not one was specified. INPUT FILE NAME: OUTPUT FILE NAME: XYZ XYZ.CCD MYLETTER.TXT MYLETTER.CCD EXECUTION OF PROGRAM: -from the command line: A>DUMP XYZ -from the console: A>DUMP Enter This allows complete freedom of operation from the programmers point of view. DECLARE THE FOLLOWING IN YOUR MAIN PROGRAM: TYPE BYTE: 0..255; VAR STDIN, { Input file } STDOUT: TEXT; { Output file } FUNCTION length(x: str255): INTEGER; EXTERNAL; PROCEDURE setlength(VAR x: str0; y: INTEGER); EXTERNAL; FUNCTION index(Source, Pattern: str255): INTEGER; EXTERNAL; } FUNCTION ConnectFiles: boolean; { returns true if was able to open files. fatal_error true if file not found. } const dflt_extension = '.CCD'; {+++ THIS IS USER DEFINED +++} fid_len = 14; { Max length CP/M file names } input = 0; type FID = string fid_len; var iname, FirstIn, { Input file identifier } FirstOut : FID; { Output file identifier } ix : byte; BEGIN ConnectFiles := true; fatal_error := FALSE; setlength(iname,0); {+ READ FROM THE CCP COMMAND LINE +} if not eoln(input) then readln(iname) else {+ READ FROM THE CONSOLE +} begin WRITELN; WRITE('Enter '); readln(iname); END; IF (length(iname)>fid_len) then setlength(iname,fid_len); FirstIn := iname; append(FirstIn, chr(13)); RESET(FirstIn, STDIN); IF EOF(STDIN) THEN {ABORT} BEGIN WRITELN('FILE ', iname, ' NOT FOUND'); ConnectFiles := false; fatal_error := TRUE; END ELSE BEGIN ix := index(iname,'.'); { search for an extension } IF (ix<>0) then setlength(iname,ix-1); { FirstOut := CONCAT( iname, dflt_extension ); } FirstOut := iname; append(FirstOut, dflt_extension); append(FirstOut,chr(13)); REWRITE(FirstOut, STDOUT); end; END{ of ConnectFiles }; t, dflt_extension); append(FirstOut,chr(13)); R