Navigation:  thinBasic language > Data types and variables > BEGIN >

BEGIN CONST ... END CONST

Previous pageReturn to chapter overviewNext page

 

Description

 

Define beginning and end of a constant declaration block.

It can be used to define a series of constants (equates) with some advantages like automatic increment of numeric values.

 

Syntax

 

BEGIN CONST [, InitialNumericValue]

 %NumericEquate [= Numeric Expression]

 ...

 $StringEquate = String Expression

END CONST

 

Returns

 

None

 

Parameters

 

Remarks

 

Numeric equate name must start with % sign.

String equate must start with $ sign

 

If numeric equate value is not specified, the last value used incremented by 1 will be assigned.

 

Restrictions

 

For string equate it is mandatory to specify the = sign followed by a string expression because it has no sense to assign a blank value.

In any case a string expression resulting in an empty string is accepted.

 

See also

 

Dim

 

Examples

 

Begin Const                '---Start of BEGIN CONST block

    %a = 1                 '---A value was specified so new auto increment will start from 1 + 1

    %b                     '---No value specified. The last value (1) incremented by 1 will be used

    %c = 100               '---A value was specified so new auto increment will start from 100 + 1

    %d                     '---No value specified. The last value (100) incremented by 1 will be used

    %e, %f                 '---Use comma to specify multiple consts

    $s1 = "Any text"       '---For string equates an assignment clause is mandatory

    %f1 = 123.456 As EXT   '---A value was specified and also forced an EXT type

 

End Const                  '---End of BEGIN CONST block

 

MSGBOX 0, "Values: " & $crlf & _

            %a  & $crlf & _    '---1

            %b  & $crlf & _    '---2

            %c  & $crlf & _    '---100

            %d  & $crlf & _    '---101

            $s1 & $crlf & _    '---AnyText

            %f1 & $crlf & _    '---123.456

            ""

 

'---See also BEGIN CONTROLID

Begin Const, %WM_USER      '---Start of BEGIN CONST block with starting value = %WM_USER

    %idButton1

    %idButton2

    %idTextBox1

End Const                  '---End of BEGIN CONST block