[comp.sys.transputer] Occam DOES have types other than int, you just gotta look....

blknowle@uokmax.UUCP (Bradford L Knowles) (04/04/89)

>As a novice user of occam just getting my feet wet, I find it
>irritating that the language doesn't include a character 
>data type, and that all the I/O procedures included in the
>userio library refer to reading, writing, and echoing 
>parameters of type INT char.  These are muddy waters!

I don't know what version of Occam you're using, but _A tutorial introduction
to OCCAM programming_, by Dick Pountain shows types various types that are
available, including int (16, 32, 64), real (32, 64), bool, byte, timer, and
arrays of these.  The one you want is array of byte.  It would be used like:
	
    PROTOCOL String IS BYTE::[]BYTE :

Which would actually be used in a program like (similar to program on p. 46 of
_tutorial_):

    PROTOCOL String IS BYTE::[]BYTE :
    CHAN OF String comm :
    PAR
	SEQ
	    ...
	    VAL message IS "Put your string here..."
	    comm ! BYTE(SIZE message)::message
	    ...
	[255] BYTE string :
	BYTE size :
	SEQ
	    comm ? size::string

Now, if you wanted strings to be longer than 255 characters, just define this:

    PROTOCOL String IS INT::[]BYTE :

And, to get really nasty, you could try this:

    PROTOCOL String IS INT64::[]BYTE :

The first one that uses INT will get you character strings that can be up to
2147483648 characters long (31 bits of length plus a useless sign bit), and the
second will get you strings that can be 9.223372037 E+18 bytes long (63 bits of
length plus a useless sign bit).  If that doesn't fix you up, then nothing
will.  Note that by including a string in double quotes, the compiler
automatically translates that into sequences of bytes.  If you want to have a
single character, as opposed to a string, you could just enclose that single
character in single quotes (maybe you want to put an 'a' on the screen), and
the compiler will automatically translate this into a byte for you -- you MUST
specify that the communications will be of type BYTE, however.

If you need anymore help, you can mail me directly (via tha address below), or
you can ask INMOS to send you a copy of their tutorial -- I got mine just by
calling up and asking for all information available on OCCAM and the T800
transputer.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
If you think a lot of people will be interested in what you have to say, post!
Otherwise, please reply via EMAIL!  I read the net, but it sometimes interferes
with school.  If I get any really interesting stuff, I'll summarise and post.

-Brad Knowles

UUCP: ...!texsun!uokmax!blknowle
ARPA: blknowle@uokmax.ecn.uoknor.edu
SNAIL: 1013 Mobile Circle
       Norman, OK  73071-2522

Disclaimer: (The above opinions are my own.  They have nothing to do with the
		Univeristy of Oklahoma nor intelligence of any sort. :-)