This repository was archived by the owner on Oct 11, 2022. It is now read-only.
forked from nickelsworth/swag
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0040.pas
More file actions
70 lines (60 loc) · 2.05 KB
/
Copy path0040.pas
File metadata and controls
70 lines (60 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
> A friend of mine has a small problem with Binkley connecting, and whenever
> this happens, Binkley writes a bunch of Line noise characters in his log f
> Some of these characters are EOF and EOL markers. I am trying to write a s
> program that will read it, and write the contents to a new file, without a
> the garbage in it. Of course, when I get to the first EOF, my program thin
> it's done.
}
Program KillChar;
{ Written by Tom Carroll and released to the public domain
on 12/11/93.
This program will read any file and delete any characters passed on
the command line.
For example: KillChar InFile OutFile ASCII Value (of character)
i.e.: KILLCHAR MYFILE.TXT NEWFILE.TXT 12
This will remove all form feeds from a text file.
No error control is included.
}
VAR
Buffer : ARRAY[0..255] OF Char;
TmpString,
StringVar : STRING;
FileLoc,
NumBytes : LongInt;
InFile,
OutFile : FILE;
NumRead : Integer;
StringPos : Integer;
BEGIN
Val(ParamStr(3), NumRead, StringPos);
TmpString := Chr(NumRead); {#26;}
Assign(InFile, ParamStr(1));
Reset(InFile, 1);
Assign(OutFile, ParamStr(2));
Rewrite(OutFile, 1);
NumBytes := FileSize(InFIle);
WHILE FilePos(InFile) < NumBytes DO
BEGIN
FileLoc := FilePos(InFile);
IF FileLoc < (NumBytes - 255) THEN
BlockRead(InFile, Buffer, 255, NumRead)
ELSE
BlockRead(InFile, Buffer, FileSize(InFile) - FileLoc,
NumRead);
Move(Buffer[0], StringVar[1], NumRead);
StringVar[0] := Chr(NumRead);
StringPos := Pos(TmpString, StringVar);
WHILE StringPos > 0 DO
BEGIN
StringPos := Pos(TmpString, StringVar);
Delete(StringVar, StringPos, 1);
END;
StringPos := Length(StringVar);
Move(StringVar[1], Buffer, Length(StringVar));
BlockWrite(OutFile, Buffer, Length(StringVar));
END;
Close(InFile);
Close(OutFIle);
END.