SPLat Logo

#EQU directive

NOTICE: Our web site is being updated, but is currently experiencing extreme slowness due to host issues. Please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map
SPLat will be shut down for the Christmas Holiday season from Friday 20 December 2024 through Tuesday 7 January 2025. We will check emails periodically and will continue to process orders but at a slower pace. Santa hat

#EQU directive

The #EQU directive assigns a text string to a label.

Example

DefaultBGColour    #EQU     'FF808080

In any regular program line after this, wherever the word DefaultBGColour appears as an argument in an instruction or hash function, the text 'FF808080 will replace it.

Note: This is not a hash command. There must not be any spaces in the keyword.

Rules:

  1. This is not a hash command. There must not be any spaces in the keyword
  2. #EQU definitions are seen only by later lines in the program - "forward referencing" is not possible. In other words, the #EQU definition must appear before any lines that use it. For example, this will work:

    DefaultBGColour #EQU 'FF808080
    .....
    #HMI SetColours( b:DefaultBGColour ) Cls() ;After the definition above, will set the colour as expected

    But this will fail:

    #HMI SetColours( b:DefaultBGColour ) Cls() ;BEFORE the definition below, will FAIL
    .....
    DefaultBGColour #EQU "128, 128, 255"
  3. They can be cascaded. For example this will work:

    DefaultBGColour #EQU 'FF808080
    .....
    ThisScreenBGColour #EQU DefaultBGColour
  4. #EQU values cannot be redefined.
  5. #EQU values cannot be used as arguments in Formatting functions.

#EQU is particularly useful for globally changing colour schemes in display screens (e.g. SimpleHMI) and for managing memory allocations for Xwire. The following sample code shows several uses:

Greet          #EQU    "Hello World"
Pi #EQU 3.1415926
XWRxBlockSize #EQU 5
XWTxBlockSize #EQU 2
XWSlaveAddr EQU 45 ;Could also be a #EQU

defBLOCK XWRxBlockSize
RxB1 defByte
RxF1 defFLOAT

defBLOCK XWTxBlockSize
TxB1 defByte
TxB2 defByte

iiPrintText 251,Greet
fLoadW Pi
....

NVEM0
XWireCCB NV0Byte XWSlaveAddr, TxB1, XWTxBlockSize, RxB1, XWRxBlockSize

a #EQU can refer to a previous #EQU, eg:

Hello #EQU "Hello World"
Greet #EQU Hello

#EQU can generally be used in place of EQU and fEQU, providing the definition appears before the use. It must not be used in place of mEQU which triggers under the hood memory management operations during Translation (compilation).


See also EQU, fEQU