home *** CD-ROM | disk | FTP | other *** search
- PROGRAM Copy;
-
- {
- This program will copy any text file, including Pascal files,
- to a new file with the designated name.
-
- Source: "COPY and List for Pascal Source Files", TUG Lines Volume I Issue 6
- Author: Harold Drake
- Application: All systems
- }
-
- var
- source: string[14]; {name of source file}
- target: string[14]; {name of target file}
- line: string[80]; {one line of the file}
- n: integer; {index variable}
- lgth: integer; {length of filename string}
- f: text; {internal filename for source}
- g: text; {internal filename for target}
- pascal: boolean; {flag for pascal file extension}
- begin
- write('Enter source name: '); readln(source);
- pascal := true;
- lgth := length(source);
- for n := 1 to lgth do if source[n] = '.' then pascal := false;
- if pascal then insert('.PAS',source,1+lgth);
- if (not pascal) and (source[lgth] = '.') then delete(source,lgth,1);
- assign(f,source);
- write('Enter target name: ');readln(target);
- pascal := true;
- lgth := length(target);
- for n := 1 to lgth do if target[n] = '.' then pascal := false;
- if pascal then insert('.PAS',target,1+lgth);
- if (not pascal) and (target[lgth] = '.') then delete(target,lgth,1);
- assign(g,target);
- reset(f);
- rewrite(g);
- while not eof(f) do
- begin
- readln(f,line);
- writeln(g,line);
- end;
- close(g);
- close(f);
- end.
-
-
-
-
-