-
Notifications
You must be signed in to change notification settings - Fork 0
/
history.ts
45 lines (41 loc) · 1.27 KB
/
history.ts
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
import * as fs from 'fs';
function createFileFromHistory(histFile: string, vvll: string) {
fs.readFile(histFile, (error, buffer) => {
if (error) {
console.error("Error reading file: " + error);
return 'read-error';
}
let lines: string[] = buffer.toString().split('\n');
let output: string[] = [];
let changeDetail: string = '';
let foundDetail: boolean = false;
for (let line of lines) {
if (!foundDetail && line[2] == ' ') {
if (line.slice(3, 7) == vvll) {
foundDetail = true;
changeDetail = line.slice(13);
}
} else if (line[2] == '+') {
if (line.slice(3, 7) > vvll) continue;
if (line[7] == '-' && line.slice(8, 12) <= vvll) continue;
output.push(line.slice(13));
// output.push(line.trimRight());
}
}
fs.writeFile(histFile + "." + vvll, Buffer.from(output.join('\n')), error => {
if (error) {
console.error("Error writing file: " + error);
return 'write-error';
}
console.log(histFile + "." + vvll + ": " + changeDetail);
});
});
}
const file = 'bc1pserv.asmpgm.lst';
const oldvvll = '0202';
const newvvll = '0203';
// createFileFromHistory(file, newvvll);
createFileFromHistory(file, '0170');
createFileFromHistory(file, '0171');
createFileFromHistory(file, '0172');
createFileFromHistory(file, '0173');