<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>


$CONST Search:

In String Constant Words in String Library

Word Name: $CONST
Type: Standard compiling word
Data Stack Signature: maxlen "value" --
Return Stack Signature: --
Availability: V1.2
Description:

Declares a string constant. String constants have a fixed size.

Example:

50 $CONST WELCOME \ declare a string constant called welcome with maximum size of 50 characters

To initialise the string constant with an actual string, see :=". To get the maximum allowed string length (the length specified when the string constant was created) see MAXLEN$.

Comment:

String constants require a maximum size and a name. Once created, they can hold any string up to, or smaller than the maximum size. Any attempt to load a string constant with a string that exceeds the maximum declared size when the constant was created will cause a run-time error.

When a string constant is referenced in code, it pushes the address of its maximum length field to the stack.

See Also: :=''  MAXLEN$ 

<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>