[Oberon] Mail.GetUIDLs

Chris Glur easlab at absamail.co.za
Thu Jan 19 19:45:23 CET 2012

> >        PROCEDURE GetUIDLs(S: NetTools.Session; VAR T: Texts.Text);
> >                VAR
> >                        F: Files.File;
> >                        R: Files.Rider;
> >        BEGIN
> >                SendCmd(S, "UIDL", "");
> >                IF ReadState(S) THEN
> >                        F := Files.New(""); Files.Set(R, F, 0);   <-- initFile
> >                        ReadText(S, R);                     <--  ?presume? S=>R
> >                        NEW(T); Texts.LoadAscii(T, F)
> >                ELSE
> >                        T := NIL  <-- perhaps at error-flag for callingProc
> >                END
> >        END GetUIDLs;
> >
> > Files.New("") creates an anonymous file.  What becomes of this file when
> > GetUIDLs exits?  Why is the file involved rather than the data from Session
> > put directly into T?
> >
> > Thanks,                        ... Peter E.
> >
> >
> > --
        PROCEDURE GetUIDLs(S: NetTools.Session; VAR T: Texts.Text);
S              SendCmd(S, "UIDL", "");
               IF ReadState(S) THEN
                      F := Files.New(""); Files.Set(R, F, 0);   <-- initFile
S=>R                   ReadText(S, R);                     <--  ?presume? S=>R

Aubrey McIntosh wrote:-
> This code has the same interpretation under V4 or Component Pascal, so I
> think my comment will be true for the ETH / PC Native.
> A Text is not a sequence of bytes.  It is more abstract than a file is.  It
> is a sequence of "Runs" where each run has attributes such as font, color,
> length, and a source file and the starting position.
> This structure makes it very fast to copy from one viewer to another.
> When a Text is saved to a file, the separate runs are all written anew to
> that file.  At that time it is very easy to confuse the concepts of Text
> and File, so I always try to think of a text that is displayed in a viewer
> after it has had items copied from other texts whenever I am writing code.
> So, there has to be a file that is referenced in the Run data structure.
>  In this code snippet, the new anonymous file is created to fill that role.
> In Component Pascal, Converters all appear to contain code that looks
> almost identical this.

I always understood that such low-level implementation details were hidden,
and that the interface [to other modules] couldn't see that.
For no obvious reason Alexander Iljin
wrapped his mail in inconvenient base64 encoding, that:
]  The anonymous file will be garbage-collected at a later time.
]  I would guess that Texts.LoadAscii contains some important data conversion, 
]  e.g. it may ensure that there are no garbage characters, etc. 
]  One has to look at the procedure to find out.

======> Lets see if switching from LEO to LNO can show N-O:Mail.Mod  ?
OK, LNO can mount my decades old N-O:<Source>.Mod
 and can write Mail.Mod to a linux file; but the <select BIG text via 2 viewers
via shift-key> doesn't work. So I've just copied 	PROCEDURE ReadState
 and 	PROCEDURE ReadText

I'm particularly interested in this, because I had to modify/extend the
<mail> code to handle <Send Authenticate>.
And now I remember that I discovered that Mail.Mod was terrible code,
whereas TextMail.Mod was nicely structured  --  which I used.

When I started ETHO in the late 90's I couldn't get Mail.Panel to work;
so I used TextMail.* and have been using it since then.
It's call inertia and it's the reason why 98% of the population uses M$
even though it is such garbage.

== Chris Glur.

PS. for convenience I'm just going to mail this my: /home/Mail.Mod
Don't bother to read the 2 attatched PROCs. Of course I could cut them.
BTW, of course you can't see how I've coloured this text to help in the
analysis [mental process aid].

IMO this <object view> of computing is powerful and flexible:
you don't think ito applications like mailers and browsers.
You think rather ito of files [& lines & bytes].
And being-emailed is just one of the actions that the object:file can do.
So what is valuable and 'permanent' is YOUR data, and the applications
which it uses are just transitory.  So eg. *this* discussion about Mail.GetUIDLs
doesn't belong to email, Usenet , http, *.pdf-apps ..etc. It is data that belongs
at a suitable place in your data-repository [currently in a file directory]
and what ever applications become suitable and available can use the 
data and add value.

	PROCEDURE ReadState(S: NetTools.Session): BOOLEAN;
		NetSystem.ReadString(S.C, S.reply);
		IF trace THEN
			Texts.WriteString(W, "RCV: "); Texts.WriteString(W, S.reply);
			Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
		IF S.reply[0] = "+" THEN
			S.status := NetTools.Done; S.res := NetTools.Done
			S.status := NetTools.Failed; S.res := NetTools.Failed
		RETURN S.status = NetTools.Done
	END ReadState;
	PROCEDURE ReadText(S: NetTools.Session; VAR R: Files.Rider);
			buffer: ARRAY BufLen OF CHAR;
			len, rlen, i, offs: LONGINT;
			state: INTEGER;
			ch, old: CHAR;
		old := 0X; offs := 1;
		len := NetSystem.Available(S.C);
		state := NetSystem.State(S.C);
		WHILE (len > 0) OR (state = NetSystem.inout) DO
			IF len > (BufLen-2) THEN
				rlen := BufLen-2
				rlen := len
			NetSystem.ReadBytes(S.C, 0, rlen, buffer);
			i := 0;
			WHILE i < rlen DO
				ch := buffer[i];
				IF ch = Strings.CR THEN
					Files.Write(R, ch);
					IF (offs = 2) & (old = ".") THEN
						Files.Write(R, Strings.LF);
					offs := 0
					IF (offs > 0) OR (ch # ".") THEN
						Files.Write(R, ch)
				old := ch; INC(i)
			DEC(len, rlen);
			IF len <= 0 THEN
				len := NetSystem.Available(S.C);
				state := NetSystem.State(S.C)
	END ReadText;
================> LEO:  *Mail*Mod*

More information about the Oberon mailing list