-
Notifications
You must be signed in to change notification settings - Fork 1
/
GraphTool.Mod
228 lines (221 loc) · 11.3 KB
/
GraphTool.Mod
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
MODULE GraphTool; (*NW 8.8.2013*)
IMPORT Files, Texts, Oberon;
CONST Context = 0; Line = 1; Caption = 2; Macro = 3; Rectangles = 4;
VAR W: Texts.Writer;
PROCEDURE DecGraph*;
VAR ch: CHAR;
class, col, fno, cat, inx, libno: BYTE;
xy, wh: INTEGER;
name: ARRAY 32 OF CHAR;
F: Files.File; R: Files.Rider;
S: Texts.Scanner;
BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
IF S.class = Texts.Name THEN
Texts.WriteString(W, "decode "); Texts.WriteString(W, S.s);
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
F := Files.Old(S.s);
IF F # NIL THEN
Files.Set(R, F, 0); Files.Read(R, ch);
IF ch = 0F8X THEN
Files.ReadByte(R, class);
WHILE ~R.eof & (class < 255) DO
Texts.WriteInt(W, class, 4);
IF class = Context THEN
Files.ReadByte(R, cat); Files.ReadByte(R, inx); Texts.WriteInt(W, cat, 4); Texts.WriteInt(W, inx, 4);
Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name);
IF cat = 2 THEN Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name) END
ELSE Files.ReadInt(R, xy);
Texts.WriteInt(W, xy * 10000H DIV 10000H, 5); Texts.WriteInt(W, xy DIV 10000H, 5);
Files.ReadInt(R, wh);
Texts.WriteInt(W, wh * 10000H DIV 10000H, 5); Texts.WriteInt(W, wh DIV 10000H, 5);
Files.ReadByte(R, col); Files.Read(R, ch); Texts.WriteInt(W, col, 5); Texts.Write(W, "|");
IF class = Line THEN
ELSIF class = Caption THEN
Files.ReadByte(R, fno); Texts.WriteInt(W, fno, 5); Texts.Write(W, " ");
Files.ReadString(R, name); Texts.WriteString(W, name)
ELSIF class = Macro THEN
Files.ReadByte(R, libno); Files.ReadString(R, name);
Texts.WriteInt(W, libno, 4); Texts.Write(W, " "); Texts.WriteString(W, name)
ELSIF class = Rectangles THEN
Files.ReadByte(R, fno); Texts.WriteInt(W, fno, 4); Files.ReadByte(R, fno); Texts.WriteInt(W, fno, 4);
Files.ReadByte(R, fno); Texts.WriteInt(W, fno, 4)
ELSE Texts.WriteString(W, "other class ="); Texts.WriteInt(W, class, 4)
END
END ;
Texts.WriteLn(W); Files.ReadByte(R, class)
END
ELSE Texts.WriteString(W, " not a graphics file")
END
ELSE Texts.WriteString(W, " not found")
END ;
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END
END DecGraph;
PROCEDURE DecGraph1*;
VAR ch: CHAR;
class, col, fno, len, lw, vers, cat, inx, libno: BYTE;
xy, wh: INTEGER;
name: ARRAY 32 OF CHAR;
F: Files.File; R: Files.Rider;
S: Texts.Scanner;
BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
IF S.class = Texts.Name THEN
Texts.WriteString(W, "decode "); Texts.WriteString(W, S.s);
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
F := Files.Old(S.s);
IF F # NIL THEN
Files.Set(R, F, 0); Files.Read(R, ch);
IF ch = 0FAX THEN
Files.ReadByte(R, class);
WHILE ~R.eof & (class < 255) DO
Texts.WriteInt(W, class, 4);
IF class = Context THEN
Files.ReadByte(R, cat); Files.ReadByte(R, inx); Texts.WriteInt(W, cat, 4); Texts.WriteInt(W, inx, 4);
Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name);
IF cat = 2 THEN Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name) END
ELSE Files.ReadInt(R, xy);
Texts.WriteInt(W, xy * 10000H DIV 10000H, 5); Texts.WriteInt(W, xy DIV 10000H, 5);
Files.ReadInt(R, wh);
Texts.WriteInt(W, wh * 10000H DIV 10000H, 5); Texts.WriteInt(W, wh DIV 10000H, 5);
Files.ReadByte(R, col); Texts.WriteInt(W, col, 5); Texts.Write(W, "|");
IF class = Line THEN
ELSIF class = Caption THEN
Files.ReadByte(R, fno); Texts.WriteInt(W, fno, 5); Texts.Write(W, " ");
Files.ReadString(R, name); Texts.WriteString(W, name)
ELSIF class = Macro THEN
Files.ReadByte(R, libno); Files.ReadString(R, name);
Texts.WriteInt(W, libno, 4); Texts.Write(W, " "); Texts.WriteString(W, name)
ELSIF class = Rectangles THEN
Files.ReadByte(R, len); Texts.WriteInt(W, len, 4);
Files.ReadByte(R, lw); Texts.WriteInt(W, lw, 4);
Files.ReadByte(R, vers); Texts.WriteInt(W, vers, 4)
ELSE Texts.WriteString(W, "other class ="); Texts.WriteInt(W, class, 4)
END
END ;
Texts.WriteLn(W); Files.ReadByte(R, class)
END
ELSE Texts.WriteString(W, " not a graphics file")
END
ELSE Texts.WriteString(W, " not found")
END ;
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END
END DecGraph1;
PROCEDURE DecLibrary1*;
VAR ch: CHAR;
class, col, fno, cat, inx, libno, len, lnw, vers: BYTE;
xy, wh: INTEGER;
name: ARRAY 32 OF CHAR;
F: Files.File; R: Files.Rider;
S: Texts.Scanner;
BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
IF S.class = Texts.Name THEN
Texts.WriteString(W, "decode library1 "); Texts.WriteString(W, S.s);
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
F := Files.Old(S.s);
IF F # NIL THEN
Files.Set(R, F, 0); Files.Read(R, ch);
IF ch = 0FBX THEN
Files.ReadByte(R, class);
WHILE (class < 255) & ~R.eof DO
WHILE class < 255 DO
Texts.WriteInt(W, class, 4);
IF class = Context THEN
Files.ReadByte(R, cat); Files.ReadByte(R, inx); Texts.WriteInt(W, cat, 4); Texts.WriteInt(W, inx, 4);
Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name);
IF cat = 2 THEN Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name) END
ELSE Files.ReadInt(R, xy);
Texts.WriteInt(W, xy * 10000H DIV 10000H, 5); Texts.WriteInt(W, xy DIV 10000H, 5);
Files.ReadInt(R, wh);
Texts.WriteInt(W, wh * 10000H DIV 10000H, 5); Texts.WriteInt(W, wh DIV 10000H, 5);
Files.ReadByte(R, col); Texts.WriteInt(W, col, 5);
IF class = Line THEN
ELSIF class = Caption THEN
Texts.Write(W, "|"); Files.ReadByte(R, fno); Texts.WriteInt(W, fno, 5); Texts.Write(W, " ");
Files.ReadString(R, name); Texts.WriteString(W, name)
ELSIF class = Rectangles THEN
Texts.Write(W, "|"); Files.ReadByte(R, len); Texts.WriteInt(W, len, 4);
Files.ReadByte(R, lnw); Texts.WriteInt(W, lnw, 4);
Files.ReadByte(R, vers); Texts.WriteInt(W, vers, 4)
ELSE Texts.WriteString(W, "other class ="); Texts.WriteInt(W, class, 4)
END
END ;
Texts.WriteLn(W); Files.ReadByte(R, class)
END ;
(*end macro*) Texts.WriteString(W, "---");
Files.ReadInt(R, wh); Texts.WriteInt(W, wh MOD 10000H, 5); Texts.WriteInt(W, wh DIV 10000H, 5);
Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name);
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf); Files.ReadByte(R, class)
END
ELSE Texts.WriteString(W, " not a graphics library")
END
ELSE Texts.WriteString(W, " not found")
END ;
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END
END DecLibrary1;
PROCEDURE ConvertFontname(VAR x: ARRAY OF CHAR);
BEGIN (* Syntax --> Oberon *)
IF (x[0] = "S") & (x[1] = "y") & (x[2] = "n") & (x[3] = "t") & (x[4] = "a") & (x[5] = "x") THEN
x[0] := "O"; x[1] := "b"; x[2] := "e"; x[3] := "r"; x[4] := "o"; x[5] := "n"
END
END ConvertFontname;
PROCEDURE ConvertLibrary*;
VAR ch: CHAR;
class, col, fno, cat, inx, libno, len, lnw, vers: BYTE;
xy, wh: INTEGER;
name: ARRAY 32 OF CHAR;
F, G: Files.File; R, Q: Files.Rider;
S: Texts.Scanner;
BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
IF S.class = Texts.Name THEN
Texts.WriteString(W, "convert library "); Texts.WriteString(W, S.s);
F := Files.Old(S.s);
IF F # NIL THEN
Texts.Scan(S); G := Files.New(S.s);
Texts.WriteString(W, " => "); Texts.WriteString(W, S.s);
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
Files.Set(R, F, 0); Files.Set(Q, G, 0); Files.Read(R, ch);
IF ch = 0FDX THEN
Files.Write(Q, 0FBX); Files.ReadByte(R, class);
WHILE (class < 255) & ~R.eof DO
WHILE class < 255 DO
Files.WriteByte(Q, class);
IF class = Context THEN
Files.ReadByte(R, cat); Files.ReadByte(R, inx); Texts.WriteInt(W, cat, 4); Texts.WriteInt(W, inx, 4);
Files.WriteByte(Q, cat); Files.WriteByte(Q, inx);
Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name);
IF cat = 0 THEN (*font*) ConvertFontname(name) END ;
Files.WriteString(Q, name);
IF cat = 2 THEN (*class*) Files.ReadString(R, name); Texts.Write(W, " "); Texts.WriteString(W, name); Files.WriteString(Q, name) END ;
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
ELSE Files.ReadInt(R, xy); Files.WriteInt(Q, xy); Files.ReadInt(R, wh); Files.WriteInt(Q, wh);
Files.ReadByte(R, col); Files.Read(R, ch); Files.WriteByte(Q, 1);
IF class = Line THEN
ELSIF class = Caption THEN
Files.ReadByte(R, fno); Files.WriteByte(Q, fno); Files.ReadString(R, name); Files.WriteString(Q, name)
ELSIF class = Rectangles THEN
Files.ReadByte(R, len); Files.WriteByte(Q, len); Files.ReadByte(R, len);
Files.ReadByte(R, lnw); Files.WriteByte(Q, lnw);
Files.ReadByte(R, vers); Files.WriteByte(Q, vers)
ELSE Texts.WriteString(W, "alien class "); Texts.WriteInt(W, class, 4)
END
END ;
Files.ReadByte(R, class)
END ;
Files.WriteByte(Q, 255); (*end macro*) Files.ReadInt(R, wh); Files.WriteInt(Q, wh);
Files.ReadString(R, name); Files.WriteString(Q, name);
Texts.WriteString(W, name); Texts.WriteInt(W, wh MOD 10000H, 4); Texts.WriteInt(W, wh DIV 10000H, 4);
Texts.WriteLn(W); Files.ReadByte(R, class)
END
ELSE Texts.WriteString(W, " not a graphics library")
END ;
Files.Register(G); Texts.WriteString(W, " done")
ELSE Texts.WriteString(W, " not found")
END ;
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END
END ConvertLibrary;
BEGIN Texts.OpenWriter(W); Texts.WriteString(W, "GraphTool 8.8.2013");
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
END GraphTool.