PRI

Designator: Declare a Private Method Block.

((PUBPRI))
  PRI Name < (Param <, Param >…) > <: RValue > <| LocalVar < [Count] >> <, LocalVar < [Count] >>…
    SourceCodeStatements

  • Name is the desired name for the private method.
  • Param is a parameter name (optional). Methods can contain zero or more comma-delimited parameters, enclosed in parentheses. Param must be globally unique, but other methods may also use the same symbol name. Each parameter is essentially a long variable and can be treated as such.
  • RValue is a name for the return value of the method (optional). This becomes an alias to the method's built-in RESULT variable. RValue must be globally unique, but other methods may also use the same symbol name. The RValue (and/or RESULT variable) is initialized to zero (0) upon each call to the method.
  • LocalVar is a name for a local variable (optional). LocalVar must be globally unique, but other methods may also use the same symbol name. All local variables are of size long (four bytes) and are left uninitialized upon each call to the method. Methods can contain zero or more comma-delimited local variables.
  • Count is an optional expression, enclosed in brackets, that indicates this is a local array variable, with Count number of elements; each being a long in size. When later referencing these elements, they begin with element 0 and end with element Count-1.
  • SourceCodeStatements is one or more lines of executable source code that perform the function of the method; usually indented by at least two spaces for readability.

Explanation

PRI is the Private Method Block declaration. A Private Method is a section of source code that performs a specific function then returns a result value. This is one of six special declarations (CON, VAR, OBJ, PUB, PRI, and DAT) that provide inherent structure to the Spin language.

Every object can contain a number of private (PRI) and public (PUB) methods. Private methods can only be accessed from inside of the object and serve to perform vital, protected functions, for the object. Private methods are like Public methods in every way except that they are declared with PRI, instead of PUB, and are not accessible from outside the object. See PUB for more information.Define functions that will be private to this object.

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