Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,56 @@
|
|||
def LF=$0A, EOF=$1A;
|
||||
|
||||
proc EatLine; \Read and discard a text line from input file
|
||||
int Ch;
|
||||
[repeat Ch:= ChIn(3);
|
||||
if Ch = EOF then
|
||||
[Text(0, "Attempted to remove a line beyond EOF"); exit];
|
||||
until Ch = LF;
|
||||
];
|
||||
|
||||
proc CopyLine; \Read and write a text line
|
||||
int Ch;
|
||||
[repeat Ch:= ChIn(3);
|
||||
if Ch = EOF then
|
||||
[Text(0, "Attempted to copy a line beyond EOF"); exit];
|
||||
ChOut(3, Ch);
|
||||
until Ch = LF;
|
||||
];
|
||||
|
||||
proc RemoveLines(FileName, StartLine, NumLines);
|
||||
int FileName, StartLine, NumLines;
|
||||
int N, Ch, IH, OH;
|
||||
[IH:= FOpen(FileName, 0);
|
||||
FSet(IH, ^i); \open specified file for input
|
||||
OpenI(3);
|
||||
|
||||
OH:= FOpen("file.tmp", 1);
|
||||
FSet(OH, ^o); \open temporary file for output
|
||||
OpenO(3);
|
||||
|
||||
for N:= 1 to StartLine-1 do CopyLine; \copy lines up to start of Start line
|
||||
for N:= 1 to NumLines do EatLine; \discard NumLines
|
||||
loop [Ch:= ChIn(3); \copy remainder of input file
|
||||
if Ch = EOF then quit;
|
||||
ChOut(3, Ch);
|
||||
];
|
||||
Close(3);
|
||||
FClose(OH); FClose(IH);
|
||||
|
||||
OH:= FOpen("foobar.txt", 1);
|
||||
FSet(OH, ^o); \open file for output
|
||||
OpenO(3);
|
||||
|
||||
IH:= FOpen("file.tmp", 0);
|
||||
FSet(IH, ^i); \open temp file for input
|
||||
OpenI(3);
|
||||
|
||||
loop [Ch:= ChIn(3); \copy file
|
||||
if Ch = EOF then quit;
|
||||
ChOut(3, Ch);
|
||||
];
|
||||
Close(3);
|
||||
];
|
||||
|
||||
RemoveLines("foobar.txt", 1, 2)
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue