Пытаюсь создать файл TXT, записывая конвертером текстовую модель.
Вот часть кода:
Код:
PROCEDURE (F: TextFile) ConnectWriter*, NEW;
VAR store: Stores.Store;
BEGIN
ASSERT(F # NIL); ASSERT(F.IsOpen); ASSERT(F.exporter # NIL);
F.text := TextModels.dir.New();
(*F.writer := F.text.NewWriter(NIL);*)
F.formatter.ConnectTo(F.text)
END ConnectWriter;
PROCEDURE (F: TextFile) WriteLine* (IN S: ARRAY OF CHAR), NEW;
BEGIN
ASSERT(F.IsOpen);
F.formatter.WriteString(S); F.formatter.WriteLn
END WriteLine;
PROCEDURE (F: TextFile) Register* (name: Files.Name; type: Files.Type; ask: BOOLEAN; OUT res: INTEGER), NEW;
BEGIN
ASSERT(F.IsOpen);
ASSERT(name # "");
F.exporter(F.text, F.file);
F.file.Register (name, type, ask, res)
END Register;
PROCEDURE DoWrite*;
VAR
F: TestAsciiFile.TextFile;
res: INTEGER;
line: ARRAY 1024 OF CHAR;
BEGIN
NEW(F); ASSERT(F # NIL);
res := F.New (Files.dir.This("e:/"), Files.dontAsk);
IF F.IsOpen THEN
F.SetExporter (HostTextConv.ExportText);
F.ConnectWriter;
WriteLn ("Connection done.");
F.WriteLine ("Line1");
F.WriteLine ("Line2");
F.WriteLine ("Line3");
WriteLn ("Lines done.");
F.Register("hello", "txt", Files.dontAsk, res);
F.Close;
WriteLn ("Register done.")
END;
IF res # 0 THEN Error (res) END
END DoWrite;
Получаю пустой файл hello.txt.