[Oberon] Copy a text buffer to a string?

Michael Schierl schierlm at gmx.de
Thu May 11 22:47:46 CEST 2023


Hello,


Am 11.05.2023 um 22:12 schrieb peter at easthope.ca:
> Hi,
>
> I want to add the Date field in email message submission implemented in A2,
> Oberon.Mail.Mod.  Conceptually this.
>
>      PROCEDURE SendText ...
>          VAR ...
>              t, d: SIGNED32;
>      BEGIN
>          ...
>          Oberon.GetClock(t,d); (* Ref. Oberon.Oberon.Mod *)
>          WritePair(W, " ", d MOD 32);
>          WritePair(W, " ", d DIV 32 MOD 16);
>          Texts.Write(W, " "); Texts.WriteInt(W, 1900 + d DIV 512, 1);
>          WritePair(W, " ", t DIV 4096 MOD 32);
>          WritePair(W, ":", t DIV 64 MOD 64);
>          WritePair(W, ":", t MOD 64);
>          SendCmd(S,"Date:", W.buf);
>
> With SendCmd requiring an ARRAY OF CHAR rather than Text buffer in the
> third parameter, that fails.  What alternatives are appropriate?

I don't know if A2 provides some abstractions for that, but in good old
Oberon (V5) you'd have to append the Text buffer to a Text, create a
sufficiently large char array and use a Reader to read the text back
into the array in a loop.

Alternatives would require to manually split up digits and set them into
the character array.

Note that format of a Date header specified in RFC5322 is different to
the one you used, as it requires the month to be abbreviated in three
letters and a time zone following the seconds. (Day of week is optional,
yet most email clients add it as well in three letters at the beginning
of the format.)


Regards,


Michael


More information about the Oberon mailing list