Referencing a pointer to a communication handle in a pointer table

I am trying to use a pointer to a communication handle that is in a pointer array.

This OptoScript code compiles:

p2pSocketPtr = p2pSocketPtrs[p2pPmIdx];
p2pIoChannelStatus = ListenForIncomingCommunication(*p2pSocketPtr);

This does not:

p2pIoChannelStatus = ListenForIncomingCommunication(*p2pSocketPtrs[p2pPmIdx]);

I get the following error message:

Compiling…
Error on line 42: Unable to find variable or command “*p2pSocketPtrs”
1 error(s), 0 warning(s)

Is there a trick to de-referencing a pointer to communication handle when that pointer is in a pointer table?

I think the problem is not about referencing to a pointer table, but the command is not able to take a table as argument…? Just my thought.

My understanding is that Optoscript can’t utilize pointers in pointer tables directly, as it needs to know the data type of the value the pointer is referencing. Since pointer tables can hold pointers to any data type, the interpreter would not know the data type that is being referenced. So the pointer in the table needs to be copied into an individual pointer for the data type being used first. You can think of it like “casting” from other programming languages.

It would be nice if this could be inferred at times, but it just doesn’t do that.

You are probably correct. Pointers to timers need the same treatment:

p2pTimerPtr = p2pClearResetTimerPtr[p2pPmIdx];
                    if ( HasDownTimerExpired(*p2pTimerPtr) ) then
. . .

works.

 if ( HasDownTimerExpired(*p2pClearResetTimerPtr[p2pPmIdx]) ) then
. . .

does not.

It would be useful to have the ability to specify the “Pointer to Type” for pointer tables.