Positron Compiler Documentation

Parameters

Positron16 · Revision 1.1.3.5 · PDF pages 450–451

A procedure may have up to 10 parameters. Each parameter must be given a unique name and a variable type. The parameter name must consist of more than one character. The types supported as parameters are:

Bit, Byte, SByte, Word, SWord, Dword, SDword, Float, Double, and String.

A parameter can be passed by value or by reference. By value will copy the contents into the parameter variable, while by reference will copy the address of the original variable into the parameter variable. By default, a parameter is passed by value. In order to pass a parameter by reference, so that it can be accessed by one of the PtrX commands, the parameter name must be preceded by the text ByRef. For clarification, the text ByValue may precede a parameter name to illustrate that the variable is passed by value.

View original PDF page 450Open page in PDFOriginal PDF page 450

For example:

Proc MyProc(ByRef pWordin as Word, ByValue pDwordin as Dword)
  HrsoutLn Dec pWordin, " : ", Dec pDwordin
EndProc

The syntax for creating parameters is the same as when they are created using Dim. String or Array variables must be given lengths. For example, to create a 10 character String parameter use:

Proc MyProc(pMyString as String * 10)

To create a 10 element unsigned Word array parameter, use:

Proc MyProc(pMyArray[10] as Word)

A parameter can also be aliased to an SFR (Special Function Register). For example:

Proc MyProc(pMyWord as WREG0)

As with standard variables, the aliased parameter can also be casted to a type that has fewer bytes. For example, a Word variable can be casted to a Byte type, or a Dword can be casted to a Word or Byte type etc…

Proc MyProc(pMyByte as WREG2.Byte0)
View original PDF page 451Open page in PDFOriginal PDF page 451