Spinroot

A forum for Spin users

You are not logged in.

#1 2019-09-17 03:57:06

Maxvonhippel
Member
Registered: 2019-09-13
Posts: 7

[Solved] Storing arbitrary channel message in a variable

I would like to have some logic like:

IF the channel chan1 is not empty:
    Let X = chan1.pop()
    do some stuff with X

But the only way I know how to do this is to explicitly enumerate all possible values of X, ie, if X were of some mtype { BANANA, HOTDOG, MANGO, KOALA }, I would do

mtype tmp;
if
:: chan1 ? BANANA -> tmp = BANANA;
:: chan1 ? HOTDOG -> tmp = HOTDOG;
:: chan1 ? MANGO -> tmp = MANGO;
:: chan1 ? KOALA -> tmp = KOALA;
fi
do some stuff with tmp

Is this the best way to do it?  Or is there some method like the ".pop()" I want that I can use?

Thank you!

Last edited by Maxvonhippel (2019-09-17 04:01:15)

Offline

#2 2019-09-17 04:00:54

Maxvonhippel
Member
Registered: 2019-09-13
Posts: 7

Re: [Solved] Storing arbitrary channel message in a variable

I was a fool, the answer is obvious - I need to use receive, with < >; ie

byte msg;
myChan ? < msg >;

http://spinroot.com/spin/Man/receive.html

Last edited by Maxvonhippel (2019-09-21 23:23:22)

Offline

Board footer

Powered by FluxBB