-
Notifications
You must be signed in to change notification settings - Fork 2
/
TextsTest1.m
51 lines (43 loc) · 1018 Bytes
/
TextsTest1.m
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
MODULE TextsTest1;
(*
A. V. Shiryaev, 2012.01
*)
IMPORT Texts, Files:=OFiles, Out;
VAR
Log: Texts.Text;
PROCEDURE NewW1 (VAR W: Texts.Writer);
BEGIN
Texts.OpenWriter(W);
Texts.WriteString(W, "hello"); Texts.Write(W, ' '); Texts.WriteInt(W, 7FFFFFFFH, 0);
Texts.Write(W, ' '); Texts.WriteSet(W, {0..14,30}); Texts.Write(W, ' '); Texts.WriteReal(W, 0.1, 0);
Texts.WriteLn(W)
END NewW1;
PROCEDURE Do;
VAR W: Texts.Writer;
B: Texts.Buffer;
T: Texts.Text;
BEGIN
NewW1(W);
Texts.Append(Log, W.buf);
Texts.Append(Log, W.buf);
NEW(T);
Texts.Open(T, "CR.TXT");
Out.String("CR.TXT len = "); Out.Int(T.len, 0); Out.Ln;
NEW(B);
Texts.OpenBuf(B);
Texts.Save(T, 0, T.len, B);
Texts.Append(Log, B)
END Do;
PROCEDURE SaveLog;
VAR f: Files.File;
len: INTEGER;
BEGIN
f := Files.New("TextsTest1.log");
Texts.Store(Log, f, 0, len);
Out.String("stdout len = "); Out.Int(len, 0); Out.Ln
END SaveLog;
BEGIN
NEW(Log); Texts.Open(Log, "");
Do;
SaveLog
END TextsTest1.