To represent a line jump in a file:
* Unix and MacOS X: the byte 0A (hexadecimal number 0A, decimal 10, LF, Line Feed).
* MacOS 9: the byte 0D (hexadecimal number 0D, decimal 13, CR, Carriage Return).
* Windows: the byte 0D followed by the byte 0A, that is CR+LF.
I have been experimenting:
PROCEDURE WriteSmallFile*;
CONST fileName = "MyFile_CRLF.txt";
VAR l: Files.Locator;
f: Files.File;
w: Files.Writer;
res: INTEGER;
BEGIN
l := Files.dir.This("Priv");
ASSERT(l.res = 0, 20);
f := Files.dir.New(l, Files.dontAsk);
ASSERT(l.res = 0, 21);
w := f.NewWriter(NIL);
w.WriteByte(61H); (* ascii "a" *)
w.WriteByte(62H); (* ascii "b" *)
w.WriteByte(0DH); (* ascii 13 CR *)
w.WriteByte(0AH); (* ascii 10 LF *)
w.WriteByte(63H); (* ascii "c" *)
f.Flush;
f.Register(fileName, "", Files.ask, res);
ASSERT(res = 0, 22);
END WriteSmallFile;
I have wrote 0D only (CR), 0A only (LF), and both 0D and 0A (CR+LF). I have found that it is always interpreted like a line jump, both by the BB editor and the Notepad++.
I have also noted the following:
* When you are in the BB editor editing a file, and you hit the Return key, then that hit is translated onto a 0D byte (CR). So the .odc files use the CR to represent a line jump, like the files of MacOS 9.
* The procedure "TextMappers.Formatter.WriteLn" inserts the two bytes CR and LF (I am using WindowsOS). At least that is what is seen in the file generated, although I think it is due to the converter (HostTextConv.ImportText) that is used to make persistent the file.
PROCEDURE WriteSmallFileUsingAbstractions*;
CONST fileName = "MyFile.txt";
VAR loc: Files.Locator;
frmter: TextMappers.Formatter;
v: TextViews.View;
BEGIN
frmter.ConnectTo(TextModels.dir.New());
frmter.WriteString("First line");
frmter.WriteLn; (* CR+LF under Windows OS *)
frmter.WriteString("Second line");
loc := Files.dir.This("Priv");
ASSERT(loc.res = 0, 20);
v := TextViews.dir.New(frmter.rider.Base());
Converters.Export(loc, fileName, conv, v);
ASSERT(loc.res = 0, 21);
END WriteSmallFileUsingAbstractions;
BEGIN (* module *)
conv := Converters.list;
WHILE (conv # NIL) & (conv.imp # "HostTextConv.ImportText") DO conv := conv.next END
So far so good, but the documentation of BB 1.5 (Caracter Set - Control codes used in Black Box) says:
0AX ltab reverse tabulator key
0DX line return key
I am confused about the fact that the hexadecimal number 0A is the "reverse tabulator key". Does somebody know what does this mean?
Thanks,
Manuel
---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
Received on Mon Feb 21 2011 - 18:57:31 UTC