Gentee Programming Language > Documentation > Syntax Download documentation

Declaring text function

The text command is particularly used for text data.

When you declare a text-function, you specify the keyword text, the attributes enclosed in angle brackets and the parameters enclosed in parantheses. The attributes as well as the parameters are optional. A text-function does not return the value. The attributes as well as the parameters are declared in the same way as functions.

<text-function declaration> ::= text <text-function name> [<function attributes >]['(' [<parameters declaration>] ')']
<text-function body> ::= { <const string element> | '\@'<text-function name>'(' [<parameters>]> | '\('<expression>')' | '\{'(<block command> | <subfunction>) <block command> {<end-of-line> (<block command> | <subfunction>) }'}' }['\!']
<text> ::= <text-function declaration><end-of-line><text-function body>

As for the simple function, strings enclosed in double quotes are inserted into the source code; as for the text function, on the contrary, the source code is inserted into the text.A text function outputs a text to a console or to a string. It is subject to the text function call.
The body of the text function (the output text) starts in a new line after declaring the text function and goes either to the end of the file or to the following service characters: \!, '\' is the current service character. The service character and the commands operated in a string are used in a text function. Furthermore, a text function uses the following additional commands.
 
\!The end of a text function. By default, a text function goes to the end of the file.
\@name(...)Calling another text function. The output mode (to a console or to a string) is not changed.
\{...}Insertion of the code block. You can specify the source code enclosed in braces as in the function body. This block fits the block of the lowest level of the function and you can declare subfunctions there.

text hello
Hello, World!
\{getch()}\!

func b <main>
{
@hello() // Write to console
str out
print( out @ hello())
getch()
}

See also

    func Function Declaration    The @ Operator And Text-Function Call


 Copyright © 2004-2006 Gentee Inc. All rights reserved.