int main() {
chan c[Size];
....
Is it possible to write the following code in another way such as SIZE can be chosen at compile time ?
E.g.
#define SIZE 4
Code: Select all
do {
t:>time;
select {
case slave {
c[0]:>len;
c[0]:>colour;
for (int i = 0; i < len; i++)
c[0]:>msg[i];
}:
{ cursorX,cursorY}=insert_str(cursorX, cursorY, msg,colour,cursorColour,table);
break;
case slave {
c[1]:>len;
c[1]:>colour;
for (int i = 0; i < len; i++)
c[1]:>msg[i];
{ cursorX,cursorY}=insert_str(cursorX, cursorY, msg,colour,cursorColour,table);
break;
}
case slave {
c[2]:>len;
c[2]:>colour;
for (int i = 0; i < len; i++)
c[2]:>msg[i];
}:
{ cursorX,cursorY}=insert_str(cursorX, cursorY, msg,colour,cursorColour,table);
break;
case slave {
c[3]:>len;
c[3]:>colour;
for (int i = 0; i < len; i++)
c[3]:>msg[i];
}:
{ cursorX,cursorY}=insert_str(cursorX, cursorY, msg,colour,cursorColour,table);
break;
case tc when timerafter(timec) :> timec:
...