COGID

Command: Current cog's ID number (0-7).

((PUBPRI))
  COGID


Returns: The current cog's ID (0-7).

Explanation

The value returned by COGID is the ID of the cog that executed the command. Normally, the actual cog that code is running in does not matter, however, for some objects it might be important to keep track of it. For example:

PUB StopMyself
  'Stop cog this code is running in
  cogstop(cogid) 

This example method, StopMyself, has one line of code that simply calls COGSTOP with COGID as the parameter. Since COGID returns the ID of the cog running that code, this routine causes the cog to terminate itself.

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.