Mailboxes

Mailboxing is the method that OZ uses to transfer information between applications. For example, PipeDream can receive filenames marked in the Filer and so on.

CamelForth offers easy access to these facilities. You can check for mail of a particular type with:

    CHECKMAIL  ( mailtype -- false | c-addr n true)

This word takes a null-terminated string as a mailtype and returns false if no mail of that type is waiting, or true and the address and length of the mail detected.

Words provided for handling null-terminated strings are 0" which compiles a null-terminated string into the current definition (it cannot be used interpretively) and S>0 which copies a string to the temporary 0PAD area (this can be overwritten by many other words including file words), appends a null and returns its address. Also available is 0TYPE.

As an example, suppose we want to check for a filename and display it. Try this definition:

    : FNAME?  0" NAME" CHECKMAIL IF  TYPE  THEN ;

Try executing FNAME? both before and after going to the Filer and marking a file.

You can also send mail that can be picked up by other applications. This is done with:

    SENDMAIL  ( 0|mailtype c-addr n -- )

This sends n bytes of data at c-addr as the specified mailtype. (If you specify "0" for the mailtype, then it is emptied; the string is ignored in this case). Note that the "NAME" mailtype expects the buffer to contain a null-terminated string, so we'll need to append a null. For example:

    S" NAME" S>0 S" hello there!" 2DUP + 0 SWAP C! CHAR+ SENDMAIL

If you now immediately start Unzip, for example, it will take this string as a filename!


More about CamelForth

Back to the Z88 home page