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

       %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

    $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

            ""

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com