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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
PACKET to 16 DEFINES to 16 :
LET OLDRECORD = STRUCT (INT succ, pred, x, y, TEXT line) ,
OLDFILE = BOUND ROW 4075 OLDRECORD ;
LET free root = 1 ,
used root = 2 ;
LET file type 16 = 1002 ;
FILE VAR file 17 ;
OLDFILE VAR file 16 ;
DATASPACE VAR file space ;
PROC to 16 :
to 16 (last param)
ENDPROC to 16 ;
PROC to 16 (TEXT CONST file name) :
last param (file name) ;
file 17 := sequential file (input, file name) ;
disable stop ;
file space := nilspace ;
file 16 := file space ;
type (file space, file type 16) ;
copy 17 to 16 ;
IF NOT is error
THEN replace 17 by 16 file
FI ;
forget (file space) .
replace 17 by 16 file :
forget (file name, quiet) ;
copy (file space, file name) .
ENDPROC to 16 ;
PROC copy 17 to 16 :
enable stop ;
build used record chain ;
build free record chain .
build used record chain :
copy all records ;
construct used chains head and circular links .
copy all records :
INT VAR line ;
FOR line FROM 1 UPTO lines (file 17) REP
copy one record ;
cout (line)
PER .
copy one record :
INT VAR index := line + 2 ;
TEXT VAR line 17;
record.pred := index - 1 ;
record.succ := index + 1 ;
getline (file 17, line 17) ;
change special 17 chars;
record.line := line 17.
change special 17 chars:
change all (line 17, ""217"", ""225"");
change all (line 17, ""218"", ""239"");
change all (line 17, ""219"", ""245"");
change all (line 17, ""214"", ""193"");
change all (line 17, ""215"", ""207"");
change all (line 17, ""216"", ""213"");
change all (line 17, ""220"", ""235"");
change all (line 17, ""221"", ""173"");
change all (line 17, ""222"", ""163"");
change all (line 17, ""223"", ""160"");
change all (line 17, ""251"", ""194"").
construct used chains head and circular links :
record.succ := used root ;
used root record.pred := index ;
used root record.succ := used root + 1 ;
used root record.line := headline (file 17) .
build free record chain :
free root record.pred := free root ;
free root record.succ := free root ;
free root record.y := index + 1 ;
free root record.line := " 0 1 1" ;
free root record.line CAT text (maxlinelength (file 17), 5) .
record : CONCR (file 16) (index) .
used root record : CONCR (file 16) (used root) .
free root record : CONCR (file 16) (free root) .
ENDPROC copy 17 to 16 ;
ENDPACKET to 16 ;
|