PDA

View Full Version : equates: what are they?



Benjamin
17-12-2023, 01:00
I'm sure the answer to my question is in the manual, but I can't find it, so I'll ask: What is an equate?

Benjamin
17-12-2023, 01:24
Constants?

Benjamin
17-12-2023, 01:28
Yes, they are constants.

Petr Schreiber
24-12-2023, 23:05
Yes, basically constants with a syntactic sugar to make their declaration shorter.

You can also declare constant as:


Const MyText As String = "Ciao"


...very handy is then also this construct:


BEGIN CONST
%MyValue = 1
%MyOtherValue
%MyFinalValue
END CONST


...this will automatically assign value of 2 to %MyOtherValue and value of 3 to %MyFinalValue.

Original equates are inspired by languages such as PowerBASIC, while CONST & BEGIN CONST were added later.

There are some tricks you can do with equates, like:


$MYTEXT = "Hello"

MsgBox 0, %MYTEXT(3) ' Will display "HelloHelloHello" - just syntactical sugar, handy especially for pre-defined equates such as $TAB or $CRLF



Petr