Introduction

A programming language Gentee is considered to be a procedural high-level language. Actually, syntax of the language has much in common with the syntax C/C++, that helps users master the many features of it quickly in order to write programs in Gentee. Like the Java or C# languages, a source program is compiled into the object code, which is executed by a virtual machine afterwards.

What is a great advantage of Gentee?

A great advantage of Gentee is that a compiler as well as a virtual machine can be used in your applications. Take into account that the only use of one dll provides your program with the newer language features. For example, many people use regular expressions in their programs. However, you can take advantage of a valuable programming language. You will be able to write separate modules in Gentee by yourself, so it is generally unnecessary to make users study Gentee.

Have you ever created programs?

You usually have to make a lot of different routines. Note that Gentee is perfectly adequate for the process automation. You do not really need bulky and expensive compilers. You should install Gentee and built-in functions would actually provide you with much more features than batch files. Make sure that you can execute programs in Gentee and should not save the compiler-produced code - just edit a text and execute a program. Which language does programming make easier?

Would you like to learn programming?

Well, to really learn how to programm, we offer you a perfect programming language. And we help meet your needs. Usability and lucidity of the language are intended to be the basic principles, which we attempted to establish while designing it. Furthermore, our goal was to make your programming faster and comfortable.

Copyright © 2004-2006 Gentee Inc. All rights reserved. On-line documentation


Syntactical description

Actually, the syntax of Gentee is described using verbal characters as well as Backus-Naur Form(BNF) in this documentation. A syntactical description of Gentee using BNF provides in the appendix A.

The formula of BNF consists of two parts, as follows: the first part denotes the name of a defined notion enclosed in metacharacter braces < >, and followed by the ::= metacharacter; the second part defines a notion description. The following metacharacters are used for this description:

| - means OR
( ) - parentheses are group delimiters.
{ } - contents of the braces can be repeated any number of times or not once.
[ ] - contents of the square brackets are optional.

Note that characters of the language are enclosed in single quote marks in order to distinguish them from metacharacters used in the BNF description. Characters of the language can be represented in hexidemical notation: 0xCharacter_Code.

Exanples of formulas

<letter> ::= 'A' | 'B' | ... | 'Z' | 'a' | 'b' | ... | 'z' | 0x80 | 0x81 | ... | 0xFF
<name> ::= (<letter> | '_') {<letter> | '_' | <decimal digit>}

The first character of an identifier name must be a nondigit, i.e. it must be a letter or an underscore followed by letters, digits and underscores; an identifier name allows even one character.

See also

Syntax Of the Gentee Language In BNF Form


A character set

A character set is a set of numerals, letters, and special characters:

Digits:
<binary digit> ::= '0' | '1'
<decimal digit> ::= <binary digit> | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
<hexadecimal digit> ::= <decimal digit> | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'

Letters:
<letter> ::= 'A' | 'B' | ... | 'Z' | 'a' | 'b' | ... | 'z' | 0x80 | 0x81 | ... | 0xFF

Bear in mind that you should not use the ANSI character code greater than 0x79 ( languages that do not use the Roman alphabet ), if a computer where a source program is likely browsed uses another code page.

Special characters:
<space> ::= 0x20
<tabulation> ::= 0x09
<end-of-line> := 0x0D 0x0A
<delimiter> ::= '!' | '"' | '#' | '$' | '%' | '&' | ''' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | '<' | '=' | '>' | '?' | '@' | '[' | '\' | ']' | '^' | '_' | '|' | '}' | '{' | '~' | <tabulation> | <space> | <end-of-line>

An end-of-line is a significant character set that consists of carriage-return and line-feed characters.
<character> ::= <decimal digit> | <letter> | <delimeter>


Identifiers

Identifiers are the names you supply for variables, functions, methods, types, fields and macros in your program. Identifier names are sequences of letters, underscores and decimal numerals; furthermore, the first character must be an underscore or a letter. The length of an identifier name is limited to less than 255 characters. Note that the characters'case makes good sense.

<name> ::= (<letter> | '_') {<letter> | '_' | <decimal digit>}
<function name> ::= <name>
<variable name> ::= <name>
<type name> ::= <name>
<field name> ::= <name>
<method name> ::= <name>
<attribute name> ::= <name>
<macro name> ::= <name>

See also

A character set


Numbers

Actually, in the language natural numbers are denoted by:

a decimal number, that is based on the decimal digits.
<decimal number> ::= <decimal digit> {<decimal digit>}

a hexadecimal number, that is based on hex digits. To specify the hexadecimal number, start the hexadecimal number with - '0x' or '0X'.
<hexadecimal number> ::= '0' ('x' | 'X') <hexadecimal number> {<hexadecimal number>}

a binary number, that is based on binary digits. To specify the binary number, start the binary number with - '0b' or '0B'.
<binary number> ::= '0' ('b' | 'B') <binary number> {<binarynumber>}

number-a character code is a number that represents a particular character enclosed in single quote marks, i.e it is equal to the ANSI character code.
<character code> ::= '''<any character>'''

Natural numbers are decimals, hexadecimal numbers and character codes.
<natural number> ::= <decimal number> | <hexadecimal number> | <binary number> | <character code>

The following example illustrates a number expressed in different ways:

65     //  a decimal
0x41   //  a hexadecimal number = 65
'A'    //  a character code = 65

Some language constructions apply a number denoted by a byte, i.e. numbers from 0 to 255 furthermore, these are only numbers in hexadecimal notation in a range from 00 to FF.

<byte> := <hexadecimal digit><hexadecimal digit>

Integer constants can be preceded by a minus sign '–'.
<integer number> ::= ['-'] <natural number> ['l' | 'L']

Type long is assigned by appending the letter L to the end of the integer constant.

There are two types of real numbers: double and float. A real number of the double type contains a decimal point or a mantissa. The letter F is appended to the end of the constant to make float. Type double might be denoted by the letter D appended to the end of the constant.
<floating point number> ::= <decimal number>'.'[<decimal number>]
<real number> ::= ['-'] (<floating point number> | <floating point number> ('e' | 'E') ['+' | '-'] <decimal number>) ['d' | 'D']

123.122   //  the floating-point number
-123.2å-2 //  the number with a mantissa
12D
12.34F    //  the number of type float

<number> := <integer number> | <floating point number> | <real number>

See also

Built-In Data Types


Strings

Strings are sequences of characters enclosed in double " quotation marks. All characters including line feeds and ignoring command characters are considered to be significant.

"This is string with a new line break.
There is the next line."

Note, there is also a macro string. Like the string, a macro string is enclosed in quotation marks; moreover, they are preceded by a dollar sign '$'. Unlike the string, the macro string does not use a command character, but it replaces macros which appear in a string. This type of a string is very appropriate for pointing file paths.

define {
 mypath = $"c:\myfolder\subfolder"
 myname = "application"
}
...
s = $"$mypath\$myname$123.exe"
// s = c:\myfolder\subfolder\application123.exe

The operator '\' is a command character, and actions performed by it are subject to characters followed this operator. Take into account that the command character can be redefined, thus considering the operator '\' the current command character.
\\ | The command character output.
\" | A single character ".
\a | A bell character, code 0x07.
\b | Backspace, cancel character, code 0x08.
\f | Form feed, code 0x0c.
\n | Line feed, code 0x0A.
\r | Carriage return, code 0x0D.
\t | Horizontal tabulation, code 0x09.
\l | End-Of-Line - combination \r\n. It might be useful for output to a text file.
\0XX | Combination of command character and zero followed by a number of character in hexadecimal notation makes any character with code from 0 to 255 put in a string.
\$macro$ | In-line insertion of preprocessor macro. The last dollar sign '$' is optional if this sign is followed neither by letter nor by digit.
\$"string" | Insertion of a macro string.
\% | Disable command character processing to the end of string.
\%[name] | Disable command character processing to the end of string or to the occurrence of \name, furthermore name - combination of any characters.
\# | Deleting of the preceding line feed.
\=n | Redefining of a command character for the current string. n can be one of the following characters: \ / ~ ^ & :.
\[comments] | In-line insertion of remarks.
\(...) | Outputting a result of the expression. In parentheses there might be an expression of any type, where string conversion occurs.
\<file> | Content of the specified file is inserted. File name in the angle brackets must be specified as a macro string, i.e. ignoring the command character.
\! | On/off ignore instruction of double quote marks. After this instruction double quote marks are used without the command character. If you use this instruction for the next time, the double quote marks will denote the end of line character again. In the text function this instruction is denoted as the end of it.

"\=^This is string without a new line break.
^# There is no new line."
//after compiling the string looks as follows:
//"This is string without a new line break. There is no new line."
...
a=1
b=2333
string="This is a string with the expression a + b = \( a + b )"

You can use str type for describing the string variable. You can find string methods and operations in Standard Library-Strings.

<str character> ::= <tabulation> | <space> | '!' | '#' | ... | '[' | ']' | ... | 0xFF
<ext str character> ::= <str character> | '\'
<any character> ::= <ext str character> | '"'
<macrostring element> ::= {<str character>|<end-of-line>| '$'<macro name>}
<const string element> ::= <str character> | <end-of-line> | '\\' | '\"' | '\a' | '\b' | '\f' | '\n' | '\r' | '\t' | '\l' | '\0'<byte> | '\$'<macro name>'$' | '\$"' {<macrostring element>} '"' | '\#' | '\=' ( '\' | '/' | '~' | '^' | '&' | ':') | '\%['[ {<ext str character>} ]']'{<ext str character>}[{<ext str character>}] | '\[' {<any character>}']' | '\<'{<macrostring element>}'>'
<string element> ::= {<ext str character>} | '\('<expression>')'
<const string> ::= '"' { <const string element> | '\!'{<const string element>| '"'}'\!' }'"'
<string> ::= '"' { <string element>| '\!'{<string element>| '"'}'\!' }'"'


Binary Data

Binary data are surrounded by single quotation marks '. The basic elements of binary data are numbers represented in decimal or hexadecimal notation and the string. The numbers can be separated by spaces, commas and line-feeds.

You must use the escape sequances, as listed below, begining with a backslash '\' to define different types of data.
\"string" | The string insertion. Actually, you can follow all the rules of the string description in order to deal with the string. It is important to note that the Null character is not appended to the end of a string. The Null character is appended if the string is enclosed in parentheses \("string").
\[comments] | A comment insertion.
\(...) | A result expression is inserted. An expression of any type enclosed in parentheses is to be converted into the binary data.
\h | Insertion mode of numbers in hexadecimal notation. The numbers 2, 4, 8, are followed then, which indicate the total number size in bytes. If the number size is not specified, numbers are considered to be bytes. Keep in mind that hex digits are read in byte-read mode by default.
\i | The read mode of decimal numbers. Numbers can be represented in floating-point notation in this mode. The size number of 2, 4 or 8 can also be indicated after i.
\$macro$ | Macro value is inserted into the binary data. If the last sign '$' is followed by neither a digit nor a letter, it is considered to be optional.
\$"string" | A macro string is inserted into the binary data.
\<file> | Contents of the required file is inserted. A file name enclosed within angle brackets must be written as a macro string, i.e. the command character is ignored.

'5 \(50 + 45) afdcCCAB FF \[ comments ]
 \h 567, 12 ; \"string" 45 \i4 255 3 +356 -1 45.56'

You can use buf type for describing the binary data variable. You can find binary data methods and operations in Standard Library-Buffer.

<const binary data element> ::= '\h'<space> [ ( '2' | '4' | '8' ) <space>] | '\i'<space> [ ( '2' | '4' | '8' ) <space>] | <hexadecimal digit> {<hexadecimal digit>} { (<space> | ',' | <end-of-line>) <hexadecimal digit> {<hexadecimal digit>} } | <integer number> { (<space> | ',' | <end-of-line>) <integer number> } | '\'<const string> | '\[' {<any character>}']' | '\$'<macro name>'$' | '\$"' {<macrostring element>} '"' | '\<'{<macrostring element>}'>'
<binary data element> ::= <const binary data element> | '\('<expression>')'
<const binary data> ::= ''' {<const binary data element>} '''
<binary data> ::= ''' {<binary data element>} '''


Macros

Macros of any fundamental type of the Gentee language are defined by using the define command. To perform macro substitution, you need to specify an expression name surrounded by the dollar signs '$'. If the macro is followed by the character which is unlikely to be used in the name, the final dollar sign '$' is considered to be optional. Actually, macros are not variables; instead, macros are replaced with their values during compilation.

define {
   a = "str"
   b = 10
}
...
print( "\$a$ing \( $b + 20 )" )

There are the following predefined macros.
$_FILE | The full name of the current source file.
$_LINE | The current line of the source file.
$_DATE | The current date in the format DDMMYYYY.
$_TIME | The current time in the format HHMMSS.
$_WINDOWS | Equals 1 in Windows.
$_LINUX | Equals 1 in Linux.

See also

The define command


Collections

The collection type is used to initialize arrays and structures; furthermore, you can apply this type to pass a variable number of arguments of different types to functions. The collections are defined with the help of the percent sign and curly braces %{ ... }. Global variables can be initialized by collections which contain only constants.

global
{
   arr  months of str = %{"January", "February", "March", "April", "May",
   "June", "July", "August", "September", "October", "November","December" }
}

In order to initialize a structure with the help of collection, the appropriate assignment operator is required to be defined.

type test
{
   uint  num
   str    string
}

operator test =( test left, collection right )
{
   if right.gettype( 0 ) != uint : return left
   left.num = right.val( 0 )
   if right.gettype( 1 ) != str : return left
   left.string = right.val( 2 )->str
   return left
}

After that, a value is assigned to the fields, as follows:

test  myt
myt = %{ 10, "test string" }

Using the collection argument in the function, you are able to pass a variable number of arguments of different types.

func outvals( collection cl )
{
   uint i
   fornum i,*cl
   {
      print("\(i) = \(cl.val( i ))\n")
   }
}

The function call has the form.

outvals( %{ 10, 20, 30, 40 })

The collection type is required in order to define the collection argument. To get to know more about methods and operations applied for collection, please go to the section Standard Library-Collections.

<const collection> ::= '%{' <constant> {','<constant>} '}'
<collection> ::= '%{' <expression> {','<expression>} '}'


The keywords

Take a look at the list of the keywords which must not be used as identifiers and names:

as, break, case, continue, default, define, do, elif, else, exception,extern, finally, for, foreach, fornum, func, global, goto, if, ifdef, import, include, label, method, of, operator, return, sizeof, subfunc, switch, text, throw, type, while, inherit


The program structure

A Gentee program may consist of one or several files. Actually, the Gentee program has a primary element - a command. A command begins in a new line, furthermore, most commands have blocks enclosed by curly braces { }.

<program> ::= <command> {<end-of-line><command>}

You can use the following commands in a Gentee program:
include | Files incorporation.
import | Importing functions from DLL.
define | The definition of macros.
ifdef | Conditional compilation.
func | Declaring function.
method | Method declaration.
operator | Operator redefinition.
text | Text function declaration.
type | Declaring type.
global | Global variable declaration.
extern | Predefined functions, methods and operations.

<command> ::= <define> | <func> | <method> | <text> | <operator function> | <include> | <type> | <global> | <extern> | <import>

An executable source code is located only in the blocks of the following commands: func, method, operator, text. A block of the above mentioned commands is considered to be called a function body. Nested blocks and statement blocks are likely to occur within the function. The function body and the nested blocks are considered to be function blocks. In addition, function blocks include Expressions, statements and local variable declaration.

<block contents> ::= <block command> {<end-of-line><block command>}
<block> ::= '{'<block contents>'}'
<block command> ::= {<label>} (<block> | <expression> | <variables declaration> | <if> | <for> | <fornum> | <while> | <dowhile> | <foreach> | <switch> | break | continue | <return>)


Comment. Character substitution.

While tokens are read, the compiler does front-end processing on a text, i.e some characters are substituted and comments are ignored.
/*...*/ | Comments can appear anywhere. A comment begins with a forward slash/asterisk combination /* and is terminated by “end comment” delimiter */.
//... | Single-line comments. These comments are terminated by the End-of-Line characters.
; | is replaced with the End-of-Line characters.
: | is replaced with the first left brace, but the first End-of-Line characters, which follow a colon, are replaced with the closing right brace.
$name | a macro name with a dollar sign $ is replaced with its value.

/*
 This is a comment.
*/
// This is a comment too.

a = b + c; c = d + e
//after processing it looks like this:
a = b + c
c = d + e

if a == 10 : a++
//after processing it looks like this:
if a == 10 { a++ }

See also

Macros


The include command

Using the include command the specified files are compiled into the object code that is appended to the complete file. If a file has already been compiled and contains the object file, which has a .ge filename extension, this file is linked without recompiling.

<file name> ::= '"' {<str character>} '"'
<include> ::= include '{'<file name> {<end-of-line><file name>} '}'

Filenames are located in a block (i.e enclosed within curly braces); furthermore, each filename enclosed in double quotes is located in a new line. Actually, a filename contains an absolute or relative path.

include {
   "myfile1.g"
   $"c:\path\myfile2.g"
}

You can use an environment variable GINCLUDE to specify searching file folders for include command. Let you have c:\My Gentee Lib\mylib.g and c:\Programs Files\Gentee\Lib\registry.ge files. Define a environment variable with Start-Settings-Control Panel-System.

GINCLUDE=c:\My Gentee Lib;c:\Programs Files\Gentee\Lib

In this case, you can use files from those directories without the full path.

include {
   "mylib.g"
   "registry.ge"
}


The define command

The define command is used to specify macros. If the define command has the export attribute, macros are included in object code and can be used in other files. You can assign a constant to a macro, which applies to the following types of constants: a number, a string, a data set or an identifier name, furthermore, you can assign a macro to the value of another macro. Macros are defined enclosed within curly braces, and each line contains only one macro definition. The macro definition consists of a name followed by the equal sign = and the appropriate constant or another macro name.

<macro declaration> ::= <macro name> ['=' (<constant>|<name>) ]
<define> ::= define [<attributes>] '{'<macro declaration> {<end-of-line><macro declaration>} '}'

The specified values are substituted for macros while processing the source program. To get the macro value, you need to use the dollar sign '$' before the macro name.

define
{
   macr_a = 10                  //a number
   macr_b = "This is a string." //a string
   macr_c = idname              //an identifier
   macr_d = $macr_a             //another macro equals 10
}

If a macro is not defined, the enum is considered to be defined and you can assign a macro to the enumerator, that is one larger than the value of the previous one, by default, i.e. the first enumerator has a value of 0, the second one has a value of 1, etc; furthermore, if you specify a value for the previous enumerator, you will start counting from it. Macros can be separated from each other with a space character while enumerating. By using the define command you can define several enumerators at once.

define
{
   macr_0 macr_1 macr_2

   new_a = 100
   new_b new_c
}

See also

Macros The ifdef command


The ifdef command

The conditional compilation command ifdef allows the compiler to include or ignore some parts of the program, it depends upon conditions to be evaluated. For example, you can use the expression which consists of macros and constants, i.e a number, a string and a data set.

<macro expression> ::= <macro> | <constant> | '!'<macro expression> | '('<macro expression>')' | <macro expression> ( '&&' | '||' | '==' | '!=' ) <macro expression>

Note that the result of any operation is 0 as False or 1 as True.
== | the equality operator, a binary operator, is used to test both operands for equality. The result of a relational expression is 1 if the tested relationship is True and 0 if it is False. The types of the operands must be the same; if the operands are strings, they are compared character-by-character.
!= | the inequality operator (a binary operator) is exactly the negation of equality.
&& | the logical-AND operator (a binary operator) produces the value 1 if both operands have nonzero values, otherwise the result is 0.
|| | the logical-OR operator (a binary operator) produces the value 1 if either operand has a nonzero value.
! | the logical-NOT operator (a unary operator) produces the value 1 if its operand is 0 and vice versa.

Parenthesis can also be used to group operands.
Operator precedence in Gentee is defined below, from the higher to the lower one.
!
==, !=
&&
||

The logical operators ! perform numeric calculations, and the operands are strings or data sets, the values of which are converted to 0 or 1 by default. If the string or the data set is Null, they evaluate to False (0); otherwise, they evaluate to 1.

<ifdef> ::= ifdef <macro expression> '{' ... '}' { elif <macro expression> '{' ... '}' } [ else '{' ... '}']

The command ifdef description: first, the conditional-expression follows the ifdef command, then the block contains the text portion which is to be compiled, if the conditional expression is evaluated, i.e. it is not equal to 0.

ifdef $a == 5
{
   include "adv.g"   //This file is to be included, if macro a equals 5.
}

If another text portion is to be compiled and the conditional expression is False, the (optional) elsecommand is used.

ifdef $a==5
{
   include : "adv.g" // This file is to be included, if macro a equals 5.
}
else
{
   include : "def.g" // This file is to be included, if macro a is not equal 5.
}

elif, an abbreviation of "else if," lets you create a compound conditional command. You can use several elif commands one after another, which can be followed by the else command.

ifdef $a == 1
{
   include : "a.g"
}
elif $a == 2
{
   include : "b.g"
}
elif $a == 3
{
   include : "c.g"
}
else
{
   include : "else.g"
}

The ifdef command can be nested within any block of code.

See also

The define command


The import command

The import command allows you to export functions from DLL.
The keyword import is followed by DLL filename, which contains imported functions, and afterwards we open the description block. Each line of the block contains a description of the imported function, i.e. a type of the return value, if any, and a function name are aligned with parameters separated by commas and enclosed in parentheses. You can substitute a new function name for the name of the imported file. To rename the function, you need to use -> after the description and a new name. When function is imported, calling DLL function is made in the same way as calling function written in Gentee.

You can use the following attributes with import command:
cdecl Means that the __cdecl functions are imported. By default, the imported functions are considered to be the __stdcall functions.

import "myfile.dll" <cdecl>
{
...
}

link In this case, a required .dll file will be included in a .ge file; while launching a program the .dll file is written to the temporal directory where the program load it. The .dll file will be deleted after the program has ended. In other words, if you don't want some extra .dll files to be distributed, but you doubt if the files have been stored before in a user's computer, this attribute will be helpful for you. It is desirable that the complete path to the .dll file should be specified.

import $"c:\mypath\myfile.dll" <link>
{
...
}

exe This attribute should be used if you get to know the relative path from your program to the .dll file. This is an example illustrated my.dll loading from the subdirectory Plugins.

import $"plugins\my.dll" <exe>
{
...
}

<imported function declaration> ::= [ <type name> ] <function name> '(' [ <type name> { ','<type name> } ] ')' [ '->' <function name>]
<import> ::= import <file name> [<attributes>] '{' <imported function declaration> { <end-of-line><imported function declaration> } '}'

import "kernel32.dll"
{
   uint CloseHandle( uint )
   uint CopyFileA( uint, uint, uint ) -> CopyFile
   uint CreateFileA( uint, uint, uint, uint, uint, uint, uint ) -> CreateFile
   uint CreateProcessA( uint, uint, uint, uint, uint, uint, uint, uint,
                        STARTUPINFO, PROCESS_INFORMATION ) -> CreateProcess
}


The public command, the private command

All functions, metods, types or other elements of the Gentee language become publicly available by default after they have been defined. Take advantage of the private command in order to make elements be accessible only within the file, where they have been defined. All language elements that follow this command, will be accessible before the current .g file has compiled. After that, names of these elements will be deleted, you will be unable to find the elements by specifying their names. The public command makes the next elements be publicly available. You can use either public or private in the source as necessary.

private

func str mylocal
{
   ...
}

public

func str myfunc
{
   ...
   mylocal()
   ...
}

These commands are likely to be used for the (func) functions, the (method) methods, the (operator) operators, the (type) types, the (global) global variables.

<public> ::= public
<private> ::= private


Built-In Data Types

Actually, Gentee distinguishes the following data types: fundamental, structure and the reserved type. All fundamental types and some structure ones are built in the language. Structure types are defined by the type command.

Fundamental types:

Type Name | Size of Type | Range of Values |  | Comments
Integer types
sbyte | 1(4) | -128 | +127 | signed
byte | 1(4) | 0 | +255 | unsigned
short | 2(4) | -32768 | +32767 | signed
ushort | 2(4) | 0 | +65535 | unsigned
int | 4 | -2147483648 | +2147483647 | signed
uint | 4 | 0 | +4294967295 | unsigned
long | 8 | -2^63 | +2^63 - 1 | signed
ulong | 8 | 0 | +2^64 - 1 | unsigned
Floating types
float | 4 | (+ or -)10E-37 | (+ or -)10E38 |
double | 8 | (+ or -)10E-307 | (+ or -)10E308 |

Gentee has strict typing.
uint is a one of the fundamental integer types, which is combined with any structure type and is applied to store an address. The Gentee language is unlikely to have any pointer types; instead, uint type is used.
When performing arithmetic operations the following types: sbyte, byte, short, ushort are considered as the int or the uint type, which is subject to the signed/unsigned type.

The reserved type is of special significance, which belongs neither to the fundamental types nor to the structure ones. This type is denoted by the array of bytes, which is defined and used as the array. The distinctive feature of the reserved type is that, the memory space is reserved where it has been defined, for example, a field in a structure.
reserved field[50] means that a memory space of 50 bytes will be reserved in the structure. The size of memory reservation allows up to 65 535 bytes. Bear in mind that you should not use an expression in order to specify the required size. It is a constant number that must be enclosed in square brackets.

More information regarding the structure types accessed by default is provided in the Library's section.


The Type Command. Description Of Structure Types

Structure types are defined by using the type command. This command is followed by the specified type name and fields description. The structure types can contain fields and methods. However, the type command defines fields only, and methods are defined by the method command. There can be one or more fields of the same type defined in each string of the block. First, a type name is specified, which is followed by field names separated by commas. The field can have a fundamental type as well as the previously defined structure type. Fields of the structure type are organized in memory as they have been described in the source code; if the field has a structure type, the structure of this type is completely embedded in the final structure. When arrays are defined, dimensions separated by commas and enclosed in square brackets and the item type followed the keyword of can be determined.

<array declaration> ::= ['['<natural number> { [','] <natural number>} ']'] [of <type name>]
<field declaration> ::= <field declaration> [<field attributes>] [<array declaration>]
<field declaration> ::= <type name><field declaration> {[','] <field declaration>}<end-of-line>
<type> ::= type [<type attributes>] '{'<field declaration>{<field declaration>} '}'

You can set the index=<type name> attribute for the type command. The item type of the specified structure is declared by default.

type mytype<index = arr of str>
{
   ...
}

You can inherit types. You have to use the attribute inherit=<type name> for this purpose. See more details in Type inheritance.

Gentee makes it possible to restrict access to fields of the type from other modules. The specified protected attribute is used for this purpose. In this case, all fields of the type will be accessible before the current file has compiled. Otherwise, fields of this type will be unaccessible.

type mytype<protected>
{
   ...
}

You can set the free attribute for a field. In this case, the field type should be uint; moreover, the memory space address allocated by the alloc function will be stored in the specified field. When an object of the type is destroyed, the memory space will be freed automatically. The other attribute xdim must be set for the singular field type uint, if the object supports a multidimensional array. In this field the service information of the multidimensional array will be stored.

type customer
{
   str name, last_name
   uint age
   arr phones[ 5 ] of str
}


Type inheritance

Gentee allows you to inherit structure types. For this purpose you have to specify an attribute inherit with the name of the parent type.

type mytype <inherit = str>
{
   uint i
   uint k
}

Specify an empty curly brackets or a collon if a new type does not have additional fields.

type mynewtype <inherit = mytype> :

You cannot inherit base numeric types and the type reserved.

The type inheritance allows you to get fields of any parent type.

type my <inherit = mytype>
{
   str name
}

...
my m
m.i++

Also, you can call methods or functions of all parent types. The compiler finds a suitable method or function when you call some function or method. For example, there are the following functions

func print( mytype mt, uint i )
{
   print("MYTYPE PARAMETER = \( mt.i + i )\n")
}

func print( mytype mt )
{
   print("MYTYPE = \( mt.i )\n")
}

func print( my m )
{
   print("MY = \( m.i )\n")
}

You have

my mm

print( mm, 20 )
print( mm )

The first print outputs MYTYPE PARAMETER = 20, and the second print outputs MY = 0, but nor MYTYPE = 0. The situation with methods or operators is like. If you need to call just a parent method or a function then use the typecasting operator '->' with the parent typename.

print( mm->mytype )

displays MYTYPE = 0.
So, Gentee gives you the such main object-oriented programming features as the inheritance and the polymorphism.


The Global Command. Declaring Global Variables

Global variables are declared by using the global command. All necessary variables defined within the block follow the global command. You can put variables of the same type together in a single line; first, you specify a type name, which is followed by variable names separated by either a comma or a space. When variable arrays are defined, dimensions and the item type followed the keyword of can be determined. Moreover, the built-in type variables as well as strings and binary data may be initialized at the same time they are declared, using the assignment character '='. You may use the global variable from the time of its declaring.

<array declaration> ::= ['['<natural number> { [','] <natural number>} ']'] [of <type name>]
<global variable declaration> ::= <variable name> [<array declaration>]['=' <constant> ]
<global variable declaration> ::= <type name><global variable declaration> {[','] <global variable declaration>}<end-of-line>
<global> ::= global '{' {<global variable declaration>} '}'

global
{
   str a b = "My string", c
   uint num = 25, num2
   arr x[ 10 ] of int
}

See also

Local Variables


Local Variables

A local variable is likely to be declared anywhere inside a function body as well as in nested blocks. Each variable must be given its own type declaration in a new line, that contains a specified type name and variable names separated by commas.

<variable declaration> ::= <variable name> ['['<expression> { [','] <expression>} ']'] [of <type name>]
<variable list> ::= <variable declaration> ['='<expression>','<variable list>] | <variable declaration> [[',']<variable list>]
<variables declaration> ::= <type name><variable list><end-of-line>

Variable arrays are declared in a peculiar way (for example, the arr type). So, you can specify its dimension and item type of the object. The number of dimensions and their size enclosed in square brackets follow the variable name. For the measures dimension the expression can be applied. If the array element type differs from uint, the keyword of and the element type name are inserted into the same line.
Local variables can be initialized at the same time they are declared. Moreover, the variable name list is a comma-delimited list. As for the variable of arr type, you may not initialize them in the way mentioned above.

str a = "This is a string", b= "The second string"
uint i = 1, j k = 3
arr myarr[ 10, 10] of byte

Numeric variables are initialized to zero by default. Otherwise, either the appropriate initialized method or the zero fill is applied.

The scope of a local variable extends from its declaration to the end of the block in which it was declared, including nested blocks.
Global and local variables are likely to be redefined; in other words, within a block a newly declared variable shares the same name as the variable previously declared. It is possible that the new variable may be of another type. The last-mentioned variable will be available till the end of the current block, and the previously declared variable becomes hidden. Once the block ends, the variable that was subsequently hidden is again available. Actually, the objects declared as local ones are automatically created when the block begins execution, and destroyed when the block ends. You can create objects with the help of the new service function. In this case, a programmer should keep an eye on deleting objects, using the destroy function.

{
   uint a = 10
   ... // variable a is equal to 10

   {
      ... // variable a is equal to 10
      uint a = 3
      ...// variable a is equal to 3
      {
         ... // variable a is equal to 3
      }
   ]}
   ...// variable a is equal to 10
}

See also

The Global Command. Declaring Global Variables


Expressions And Operators

Expressions are considered to be a part of function body or block.
Expressions consist of operands and operators. Expressions are built from constants, strings, data sets, variables, function calls, method calls and type names. Gentee defines the term "object or structure". An object consists of fields; moreover, it can have methods and an array of elements. Array is a structure which is declared by its dimensions, number of elements and the element type. Furthermore, an array is considered to be the arr type or some other types.
Lvalue is an expression that refers to some memory location. An l-value can be an object or a variable of fundamental type or an element of an array or a field of a structure.
Logical expressions can be denoted by numeric expressions. A logical expression is TRUE, if it returns nonzero. If a logical expression returns zero, it is treated as FALSE.

<object> ::= <variable name> | <pointer> | <array element> | <field> | <function call> | <method call> | <expression> | <late binding>
<lvalue> ::= <object> | <variable name> | <pointer> | <array element> | <field>
<operand> ::= <lvalue> | <constant> | <string> | <binary data> | <collection> | <function call> | <method call> | <type name> | <late binding>
<increment operator> ::= '++' | '--'
<assignment operator> ::= '=' | '%=' | '&=' | '*=' | '+=' | '-=' | '/=' | '<<=' | '>>=' | '^=' | '|='
<unary operator> ::= '+' | '-' | '*' | '!' | '~' | '@'
<bynary operator> ::= '==' | '!=' | '>' | '<' | '<=' | '>=' | '&&' | '||' | '&' | '%' | '*' | '/' | '+' | '-' | '<<' | '>>' | '^' | '%==' | '%!=' | '%>' | '%<' | '%<=' | '%>=' | '@'
<operator> ::= <increment operator> | <assignment operator> | <unary operator> | <bynary operator>
<assignment expression> ::= <lvalue><assignment operator><expression>
<lvalue expression> ::= '&'<lvalue> | '&'<function name> | <increment operator><lvalue> | <lvalue><increment operator>


Table Of Operator Precedence

Character operation | Associativity
The highest priority
() [] . ~ -> | Left to right
! &(un) *(un) -(un) ~(un) ++ -- @(un) | Right to left
% * / | Left to right
+ - @ | Left to right
<< >> | Left to right
< > <= >= %< %> %<= %>= | Left to right
!= == %== %!= | Left to right
& | Left to right
^ | Left to right
| | Left to right
&& | Left to right
|| | Left to right
?(,,) | Left to right
= += -= *= /= %= &= |= ^= >>= <<= as | Right to left
The lowest priority

Operators

Parentheses () change the order in which expressions are evaluated. You can use square brackets in order to deal with the elements of the array or the indexed elements, for example, a character in a string. The unary operators include !, &, *, -, ~, ++, --. It is the prefix notation that is used for all unary operators, except increments. As for increment operations ++ è --, they can be occured either in the prefix or in the postfix notation. The following operators &, *, -, @, ~ are likely to be binary as well as unary operators. All other operators are binary (taking two operands).


Arithmetic Operators

The following arithmetic operators are applied in the language:
+ | Addition
- | Subtraction
* | Multiplication
/ | Division
% | Modulo
-(un) | Unary negation operator

Dividing one integer into another, any fractional portion is truncated. The following operation a % b returns the remainder (modulus) obtained by dividing a into b or 0, if result is a whole number. The modulus operator % is only used to perform division of two integers.
To indicate the negative value of an expression, you can use the unary negation operator -.

See also

Table Of Operator Precedence


Increment And Decrement Operators

The operators ++ and -- are unary operators and deal with only integers. The increment and decrement operators occur in “l-value” expressions.
++ is the increment operator. This operator is expressed in two notations: the prefix-form ++i and the postfix form i++. In the prefix form, variable i is incremented by the integer value 1, new value of variable i is used in the expression evaluation; in the postfix form, the increment takes place after the value of variable i is used in the expression evaluation.
-- is the decrement operator. The prefix notation is --i - the variable is decremented by one and the result is this decremented value. The postfix notation is i-- - the decrement occurs after the value of variable is used in expression evaluation.

i = 10
x = i++ // x = 10, i = 11
i = 10
x = ++i //x = 11, i = 11

See also

Table Of Operator Precedence


Bitwise Operators

These bitwise operators perform manipulation on integer operands.
& | Bitwise-AND (binary)
| | Bitwise-inclusive-OR (binary)
^ | Bitwise-exclusive-OR (binary)
<< | Bitwise shift left (binary)
>> | Bitwise shift right (binary)
~ | Bitwise negation (unary)

The bitwise shift operators shift their left operand left or right by the number of positions the right operand specifies, bits vacated by the shift operation are zero-filled.

See also

Table Of Operator Precedence


Logical Operators

These logical operators perform manipulation on integer operands.
&& | Logical-AND (binary)
|| | Logical-OR (binary)
! | Logical negation (unary)

The result of a logical operation is the integer of uint type, which has either 0 value -the result is FALSE or 1 value - the result is TRUE.

See also

Table Of Operator Precedence


Comparison Operators

Comparison operators are binary.
== | Equality
!= | Inequality
> | Greater-than
< | Less-than
>= | Greater-than-or-equal-to
<= | Less-than-or-equal-to

The result of this operation is the integer of uint type, which has either 0 value -the result is FALSE or 1 value - the result is TRUE.
The operators: %<, %>, %<=, %>=, %==, %!= are used to compare two operands alternatively. For example, using these operators you can compare strings by a case-insensitive value (no uppercase preference).

See also

Table Of Operator Precedence


Assignment Operators

The assignment operators are considered to be the binary operators. The left-hand operand of an assignment operation must be an l-value. These operators have right-to-left associativity.
= | Simple assignment
+= | Addition assignment
-= | Subtraction assignment
*= | Multiplication assignment
/= | Division assignment
%= | Remainder assignment
&= | Bitwise-AND assignment
|= | Bitwise-inclusive-OR assignment
^= | Bitwise-exclusive-OR assignment
>>= | Right-shift assignment
<<= | Left-shift assignment

As you have already noticed, except "simple assignment" you can perform the assignment with an operation, that is after a binary operation of the right-hand operand and the left-hand operand is performed, the result is assigned into the left operand.

a = 10
a += 33 // a = 43, is equivalent to a = a + 33

One and the same expression can contain several assignment operations, each of which returns the assigned value. In this case, the assignment operation is performed from right to left.

a = 10 + b = 20 + c = 3 // the result of expression evaluation is ñ=3, b=23, a=33

See also

The As Operator, Type Redefinition Table Of Operator Precedence


Array Element Operation

The majority of structures and objects can contain other structure types. Square brackets [] are used to get and set values of object items ( array elements, string characters ). It is the expression of uint type, that should be enclosed in square brackets. If a multidimensional object is used, its dimensions are separated by commas. The index numbers start at 0. The result of the defined evaluation will be an lvalue.

<parameters> ::= <expression> {','<expression>}
<array element> ::= <object>'['<parameters>']'

arr myarr[ 10, 10, 10] of byte
str mystr = "abcdef"

myarr[ i, k+3, 4 ] = 'd'
myarr[ 0, 0, 0 ] = mystr[i])

See also

Table Of Operator Precedence


Fields. Address And Pointer Operation

The . operator is used to access a field value or method call.

<field> ::= <object>'.'<field name>

type customer // we define type Customer
{
   str name, last_name
   uint age
   arr phones[ 5 ] of str
}
...
...
customer cust1 //we create a variable of type Customer
cust1.name = "Tom"
cust1.age = 30
cust1.phones[ 0 ] = "3332244"

The unary operator & gives the address of a local or global variable as well as the address of a function. The operation returns the value of uint type. However, if the result of any operation is an object, for example the function which returns a string, the address-of operator is also apllied to the obtained object. The address-of operator &, applied to the object (structure), returns the address of the required object and is used for a type cast to uint type.

uint a b
str mystr
...
a = &mystr        //The address of the object mystr is assigned to variable a
b = &getsomestr() //The address of the returned object is assigned to variable b

The pointer and the typecasting operator -> access a pointer value. The right-hand operand must be a type name. If the left-hand operand is an operand of uint type and the right-hand operand is a name of any fundamental type (an integer or a floating-point number), the left operator is treated as a pointer to the given type. The result of the operation is likely to be an lvalue, therefore a pointer value can be modified. Otherwise, the -> operator is used for a type cast.

<pointer> ::= <expression>'->'<type name> [<array>]

int a = 10, b
uint addra

addra = &a
b = addra->int // b is equal to 10
addra->int = 3 // a is equal to 3

If the right-hand operand is a name of the structure type, you can use the '.'operator after a pointer value has been accessed.

customer cust1
uint     pcust

pcust = &cust1
pcust->customer.name = "Tom"

The -> operation appears in an extended syntax provided that the object is designated by its pointer and you need to access the object element. In addition to the type, you have to specify the object's dimension and the element type. The object's dimension is enclosed in square brackets. If a one-dimensional array is specified, you do not need to use the square brackets; if you specify a two-dimensional array, a comma is used inside the square brackets; in case of a three-dimensional array, use two commas inside the square brackets, etc. It closely resembles declaring variables of such a type, nevertheless values of dimensions are not specified. If the element type differs from uint type, the type name is defined using the keyword of. Then the operation of retrieving elements may be applied.

arr myarr[ 10, 10 ] of byte
uint a

a = &myarr   //The compiler loses element type and dimensional data
(a->arr[,] of byte)[1,1] = 10

See also

The As Operator, Type Redefinition Table Of Operator Precedence


The As Operator, Type Redefinition

The as operator executes two functions: to assign a value to a variable and to redefine a type. This operator is binary, that has right-to-left associativity. The left-hand operand must be a local variable of uint type. Depending on the value of the right-hand operand, it can be operated in two possible ways:

1. The right-hand operand is a type name that is different from fundamental types. A value of the local variable is not modified, but its type is redefined with the required one; the variable is assumed to store an object's address, moreover this variable can be treated as the object, ignoring the pointer operation ->.

<as operation> ::= <variable name>'as' ((<type name>[<array>]) | <object>)

str  mystr
uint a

a = &mystr
a as str
a = "New value"

2. The right-hand operand is an expression that returns an object. An address of the object is assigned to the variable, which redefines its type with the object's type. The object type must be different from fundamental types.

str mystr
uint a

a as mystr
a = "New value"

The variable type will be redefined either until the end of the current block or until the next operation as with the variable occurs. If the variable stores an array address, you should specify dimensions and an element type in addition to the type in the same way as in the pointer operation ->.

See also

Fields. Address And Pointer Operation Table Of Operator Precedence


The Conditional Operator ?

The conditional operator ? operates in the similar way as the if-else statement, but the conditional operator can be located in the expression. The operator is a ternary operator (it takes three operands). The operands separated by commas are enclosed in parentheses; the first logical (integer) expression is evaluated. If the value is nonzero (TRUE), the second expression will be evaluated, the value of which will be a result of the conditional operation. Otherwise, the third operand will be evaluated, the value of which will be returned.

<question> ::= '?''(' <expression>',' [<expression>] ',' [<expression>] ')'

r = ?( a == 10, a, a + b ) // If a = 10, then r = a, else r = a + b

See also

Table Of Operator Precedence


Function Call And Method Call, Function Call Via A Pointer

A function call includes the name of the function being called and the arguments enclosed in parentheses and separated by commas. If the function does not have any arguments, the empty parentheses follow the function name.

<parameters> ::= <expression> {','<expression>}
<function call> ::= (<function name> | <expression>'->'func ) '(' [<parameters>] ')'
<method call> ::= <object>'.'<method name>'(' [<parameters>] ')'

myfunc( a, b + c )

If either a function or a method returns a value, the function or method call may be used in the expression. The . operator is used to call a method, then the arguments are listed in the same way as the arguments of a function: the variable, which stores a structure, is followed by the point, then you specify the name of the method and the arguments enclosed in parentheses.

a = my.mymethod( d )
a = b->mystruct.mymethod( d ) // if b stores the address of the structure

A variable of uint type can store the address of a function. In order to get the address of a function, the address-of operator is used, which is followed by the name of the function without parentheses. A function call includes the -> operator followed by the keyword func and the arguments listed inside parentheses. In this case, you ought to keep an eye on the number and types of the arguments, because the compiler is not able to verify the arguments.

a = &myfunc
a->func( c, d )

Gentee allows you to call functions by their address. For example, you can get the function address when you use Windows API function GetProcAddress. Use the -> operator followed by the keyword stdcall and the arguments listed inside parentheses. If the function has cdecl type then use the keyword cdecl instead of stdcall.

a = GetProcAddress( mylib, "myfunc" )
a->stdcall( 1, b )

See also

Fields. Address And Pointer Operation Table Of Operator Precedence


The @ Operator And Text-Function Call

The @ operator is applied to call a text-function. This operation can be either unary or binary.

@ name(...)

If a text-function is called from the simple function or method, the text function will output data to a console. In case of calling the function from another text-function, data will be outputted to the same place as the current text-function. A text function may be called without the unary @ operator. In other words, the text function is called in the same way as the simple function.

dest @ name(...)

If the @ operator is applied as a binary operator, the left-hand operand must be a string, to which data will be outputted from the text function. In the example illustrated above, dest is a variable or an expression of the str type. Actually, data are appended to a destination string.

The @ operator is used not only for the text-function call, but also for the string output. If the right-hand operand is either a variable or an expression of the str type, this string will be outputted to the console or will be appended to a destination string as described above.

@mytext( 10 )
str a
a @ mytext( 20 )

See also

Declaring text function Table Of Operator Precedence


Data Type Conversion

By default, data are converted from one type to another, as follows: sbyte, short to int and byte, ushort to uint; otherwise an explicit data type conversion is required. For an expression of the type to be converted to another type, it is necessary to specify a type name, to which data will be converted, and the expression enclosed in parentheses; moreover, the conversion will occur if the specified source type has the appropriate method.

str a = "10"
uint b

b = uint( a )    //b=10

See also

Table Of Operator Precedence Table of Type Conversions


sizeof Operator

The sizeof operator is used to get the amount of storage in bytes needed for an object. The sizeof operator takes a single argument, the type name to be specified.

<sizeof> ::= sizeof '(' (<type name> | <expression>) ')'

The sizeof operator returns the size of the specified type.

type mystuct {
   uint a, b
   byte c
}
...
sizeof( uint ) // = 4
sizeof( byte ) // = 1
sizeof( mystruct ) // = 9

See also

Table Of Operator Precedence


Late Binding Operation.

The ~ operation is used for late binding. This operation has a lot in common with the . operator (used to access a field value or method call); however, at compile time it is sometimes difficult to define all methods and fields of an object, whereas while executing a program a particular method of an object is called for being assigned a field/method name, types and values of parameters. The late binding operation is actually applied for COM objects.

<late binding> ::=<object>'~' (<field name> | <method name>'(' [<parameters>] ')')

An object identifier is the left-hand operand of the ~ operation, that is used for maintaining late binding; the right-hand operand is a field/method name, that is used either for setting up a property (e.g. excapp~Visible) or for calling a method (e.g. excapp~Cells(3,2)).
An object can maintain the following kinds of late binding:

  • elementary method call excapp~Quit, with/without parameters;
  • set value excapp~Cells( 3, 2 ) = "Hello World!";
  • get value vis = uint( excapp~Visible );
  • call chain excapp~WorkBooks~Add, equals the following expressions

    tmpobj = excapp~WorkBooks
    tmpobj~Add

A shortcoming of late binding is that the compiler cannot check if either fields/methods or types are specified properly; it causes problems for troubleshooting.

Have a look at the example of using late binding, where the COM library is applied.

include { "olecom.ge"}
....
oleobj excapp
excapp.createobj( "Excel.Application", "" )
excapp.flgs = $FOLEOBJ_INT
excapp~Visible = 1
excapp~WorkBooks~Add
excapp~Cells( 3, 2 ) = "Hello World!"

See also

Fields. Address And Pointer Operation Function Call And Method Call, Function Call Via A Pointer Table Of Operator Precedence


Statements Of a Function Body

A function body contains some statements that are used to interrupt the sequential execution of a program. Some of them contain blocks which also have nested statements.
There are several types of statements, as follows:

Conditional statements:
if-elif-else | Conditional statement.
switch | Case statement.

Loop statements:
while | Simple loop statement.
do-while | Simple loop statement, evaluated at the bottom.
for | Loop statement that provides initialization and increment clauses.
fornum | Loop statement that executes a finite number of iterations and has autoincrement.
foreach | Loop used for searching elements.

Instructions of unconditional transfer of control:
return | Function termination.
break | Loop termination.
continue | Immediate transfer of control to the next loop iteration.
label | Label definition.
goto | Unconditional transfer of control to a label.


Conditional if-elif-else Statement

The statement consists of the following parts:
The if part contains the if keyword, a conditional expression and the block executed if condition is TRUE. If the condition is FALSE, control passes to the next part elif.

The elif part contains the elif keyword, a conditional expression and the block executed if condition is TRUE. The statement is likely to contain some elif parts followed one after another.

The else part contains the else keyword and the block executed if the condition of the if part as well as the condition of all elif parts are FALSE.

The elif and the else operators are optional.

The value of a conditional expression must be numeric. The value is TRUE if it is nonzero.

<if> ::= if <expression><block> {elif <expression> <block>} [else <block>]

//  the if part of the statement
if a == 1
{
   b = 10
}
//the if and the else parts of the statement
if a == 1
{
   b = 10
}
else
{
   b = 0
}
//the statement has all parts: if-elif-else
if a == b+10
{
   b = 10
}
elif a == 2
{
   b = 100
}
elif a == 3
{
   b=1000
}
else
{
   b = 0
}


while, do-while Statement

The while statement is a simple loop. The while statement has the following parts: a keyword, a conditional expression and a loop body (block).

<while> ::= while <expression><block>

The execution of the loop body is repeated until the value of the expression evaluates to FALSE. The loop is never executed, if the value is zero when the test is performed for the first time.

while a
{
   ñ=c+a
   a--
}

The do statement contains the do keyword, a loop body, the while keyword and a conditional expression.

<dowhile> ::= do <block> while <expression>

The execution of the loop body is also repeated until the value of the expression evaluates to FALSE. Unlike the while statement, the test is performed after the execution of the loop body is completed and the iteration occurs at least once.

do{
   c=c+a
   a--
}
while a

See also

return, break, continue Instructions


for and fornum Statements

The for statement consists of the for keyword, a sequence of three expressions separated by commas, a loop body.

<for> ::= for [<expression>] ','<expression>',' [<expression>] <block>

for exp1, exp2, exp3
{
loop body
}

Exp1 is an optional initialization expression. It is usually used for assigning the initial value to the counter variable.
Exp2 is a conditional expression. The loop executes as long as the condition is TRUE.
Exp3 is an optional increment expression. Actually, this expression increments or decrements the value of the counter.

The statement defined above can be performed with the help of the while loop as follows:
exp1
while exp2
{
loop body
exp3
}

for i=0, i<100, i++
{
   a += i
}

If the loop counter i is incremented by one and the highest value of the counter is defined before the loop iteration starts, the fornum statement is used in place of the for statement.

<fornum> ::= fornum <variable name> ['='<expression>] ','<expression><block>

The fornum keyword is followed by a counter variable name, then the assignment operator and the expression (the initial value of the counter) can be used. If there are not any assignment operators, the initial value of the counter remains unchanged. Any integer should be treated as a counter variable. A comma delimited expression is specified,its result defines the loop termination. This expression is evaluated once before the loop iteration starts. The loop executes as long as the value of the counter is less than the value of the expression. Then the loop body follows. By default, the increment operation (value of the counter is incremented by one) is appended to the loop body by the compiler.

fornum i=0, 100 //similar to for i=0, i<100, i++
{
   a += i
}

See also

return, break, continue Instructions


foreach Loop Statement

The foreach loop deals with objects that contain an element list and have the following methods: first(), next(), eof(). The element type and the variable name are specified after foreach. Then the comma delimited expression is specified that returns the object list; and the loop body follows.

<foreach> ::= foreach [<type name>] <variable name> [<array>]','<expression><block>

An index variable will be created before each foreach statement. The expression is evaluated once before the loop iteration starts. The loop passes through each object element sequentially. So, the index variable will contain the next element.

foreach str k, mystrlist
{
   print( k )
}

See also

return, break, continue Instructions


switch Statement

The switch statement enables the execution of one or more statements, that is subject to the specified expression's value. After the keyword, the primary expression follows, which is evaluated and is stored as a switch-value. Then the switch-block appears; unlike the general block, this block contains labels label, the case and default statements.

<switch> ::= switch <expression>'{' {case <expression> {','<expression>} {<label>} <block>} [default {<label>} <block>] '}'

The case statement is followed by expressions separated by commas and the case statement body, which will be executed if any expression equals the switch-value. Transfer of control to the end of the switch statement after the case block execution is complete. The expressions located in the case statement are evaluated and compared for equality sequentially. If all expressions do not equal the switch-value, then control is transferred to the next case or default statement. The default statement does not have any expression lists; nevertheless, if none of the case values matches expression, the default block is executed. The default statement can appear only once and should come after all case statements.

switch a & 0x0f
{
   case 0x01, 0x02
   {
      b = 10
   }
   case 0x03
   {
      b = 100
   }
   case 0x04, k & 0x0f   // The case expression is not required to be a constant
   {
      b = 1000
   }
   default
   {
      b = 0
   }
}

Labels that appear after the case keyword enable you to enter the appropriate case case-block from another case-block.

switch a
{
   case 0
   label a0
   {
      c = 1
   }
   case 1
   {
      if b
      {
         goto a0
      }
      c = 2
   }
}

See also

The label and goto Instructions


return, break, continue Instructions

The return instruction is used either to return a function value or to terminate the execution of a function. The exit may be from anywhere within the function body, including loops or nested blocks. If the function returns a value, the return instruction is required, furthermore it contains the expression of the appropriate type.

<return> ::= return [<expression>]

{
   ...
   fornum i, 100
   {
      if error
      {
         return 0 // terminating the execution of the function
      }
      ...
   }
...
return a + b
}

The break instruction terminates the execution of the loop. break is likely to be located within nested blocks. If a program contains several nested loops, break will exit the current loop.

while b > c
{
   for i = 100, i > 0, i--
   {
      if !myfunc( i )
      {
         break   //terminating the execution of for loop
      }
   }
   b++
}

The continue instruction may occur within loops and attempts to transfer control to the loop expression, which is used to increment or decrement the counter (for the following loops: for, fornum, foreach) or to the conditional expression (for while and do-while loops); moreover, the execution of the loop body is not completely executed. The instruction executes only the most tightly enclosing loop, if this loop is nested.

fornum i, 100
{
   if i > 10 && i < 20
   {
      continue
   }
   a += i//The given expression is not evaluated if i>10 and i<20
}

See also

while, do-while Statement for and fornum Statements foreach Loop Statement


The label and goto Instructions

The label and goto insrustions perform an unconditional transfer of control in the function body.
The appearance of the label instruction in the source program declares a label. The keyword is followed by a name - an identifier label.

<label> ::= label <label name>

The goto instruction transfers control to the specified label.

<goto> ::= goto <label name>

The label has scope limited to the block in which it is declared, therefore the goto instruction transfers control to the label either inside the current block or in blocks of higher levels. Control transferred to the label may occur before the label is declared.

{
   ...
   {
      goto l1//Correct
      ...
label l1
      ...
      goto l2//Correct
   }
   ...
   {
      goto l1//Error
   }
   ...
   goto l1//Error
   ...
label l2
}

See also

switch Statement


func Function Declaration

A function consists of two parts: a declaration and a function body.

<func> ::= <function declaration><function body>

When you declare a function, you specify the keyword func, the type of its return value, its name, its attributes enclosed in angle brackets and its parameters enclosed in parentheses. Only the function name is required.

<function declaration> ::= func [<type name>] <function name> [<function attributes>] ['(' [<parameters declaration>] ')']

When you do not specify the type of its return value, the function does not return any values.
Function attributes:
entry | is identified in functions run automatically before you make the major function call
main | is identified in the major function that will start the program execution

Only the last function main will be called automatically. It will be run after all entry functions have been called.
The functions which have either attribute specified above do not take any parameters.

Each parameter declaration is a comma-delimited series of parameter names with the type identifiers specified after a type name, then followed by a comma or space and a new type name and parameters. If a function takes no parameters, omit the identifier list and the parentheses in its declaration. You can define functions with the same name but with different parameters. In this case, when you call a function the compiler looks for a function with the same name and parameters.

<parameter declaration> ::= <variable name> [<array>]
<parameters declaration> ::= <type name><parameter declaration> { [','] <parameter declaration>} [<parameters declaration>]

When you declare a function that takes array parameters, specify its dimensions and the element type. The dimensions are surrounded by square brackets; if an array is one-dimensional, you can omit square brackets, otherwise a comma is used within brackets (a two-dimensional array needs one comma, a three-dimensional array needs two commas, etc. Array parameters are declared in a similar way to a variable of array type, nevertheless a number of elements in each dimension is not specified. If the element type differs from uint type, the type name is defined using the keyword of.

<array declaration> ::= ['['<natural number> { [','] <natural number>} ']'] [of <type name>]

func uint myfunc( uint a b c byte d, str st1, st2, arr marr[,] of uint )

Function parameters can be used as local variables.

A function body is a lowest-level block. Unlike the simple block, this block is likely to have subfunctions. A block consists of a series of expressions, statements and declarations of local variables.

<function body> ::= '{' (<block command> | <subfunction>) <block command> {<end-of-line> (<block command> | <subfunction>) } '}'

func uint myfunc <main>()
{
   ...
   return 0
}

See also

Subfunction subfunc declaration The program structure


Subfunction subfunc declaration

Subfunctions are defined in the body of the function with the help of the subfunc construction. A subfunction is defined in the lowest level of the embedded block of the body. You can call a subfunction only from the function body as well as from other subfunctions of the given function. It is impossible to define another subfunction and to call itself recursively, because local variables are considered to be static. A subfunction is able to redefine other functions' names. A subfunction is actually called like a function; moreover, a subfunction as well as its parameters are declared in much the same way as the function, except for the lack of attributes. You can use local variables of the function within the subfunction.

<subfunction> ::= subfunc [<type name>] <function name> ['(' [<parameters declaration>] ')'] <block>

func uint myfunc( int par )
{
   int locvar
   subfunc int mysubfunc( int subpar )
   {
      return locvar + par + subpar
   }
   par = mysubfunc( 10 )
}

See also

func Function Declaration


Method method Declaration

You can define different methods for the structured types. Any method is a function associated with an object of the appropriate type, that the method should operate on.
A method is defined by specifying the keyword method followed by the name of the return type (if it is required), an object type and a method name followed by a separating period. Like declaring a function, you should specify method parameters followed by its body.

<method declaration> ::= method [<type name>] <type name>'.'<method name> ['(' [<parameters declaration>] ')']
<method> ::= <method declaration><function body>

Actually, method parameters are declared like function parameters. The parameter this is created automatically within the method; furthermore, this parameter contains the object to which the given method is called. The parameter this has the same type as the object does.

Methods are responsible for object initialization and destruction, getting index and type conversion as well as for other operations. Moreover, such methods as: initialization, destruction, getting index must have their own fixed names:
init | Initialization. This method has no parameters; furthermore, it is called automatically with its variable defined or with its object created using the function new.
delete | Deletion. This method has no parameters; furthermore, it is called automatically if the variable is destroyed when the execution of a function or a block is completed, or if the object that contains objects of the appropriate type is deleted.
index | Getting an index, this method serves the following purposes: for example, it specifies either the i-character of a string or the i-element of one-dimensional array. Uint type is the required parameter. In order to call this method, you should specify it with the index enclosed in square brackets.
array | This method is used to define the size of the array. The method has only one uint parameter that contains the number of dimensions of the array. It is applied for declaring multidimensional arrays.
eof | Tests for the end of a list. This method has no parameters and is applied using the foreach operator.
first | Returns the first element from a list. This method has no parameters and is applied using the foreach operator.
next | Returns the next element from a list. This method has no parameters and is applied using the foreach operator.

method uint str.index( uint i )
{
   return this.sbuf.data + i
}
...
str mystr = "This is a string"
a = mystr[3]     // = 'i'

Type conversion is also declared with the help of the methods. A source type is specified as the object type of the method and a destination type of the object is specified as the method name. If the destination type is structured, the result object must be specified in the parameter.

//The method converts uint number to string representation
method str uint.str( str result )
{
   result.setlen( 0 )
   int2str( result, "%u", this )
   return result
}
...
str mystr
uint a = 10
mystr = str( a )   //Type conversion

See also

func Function Declaration


Redefining operator operations

Gentee enables objects to do new operations using the statements which already exist. Moreover, the statement priority keeps permanent. The operation processing is executed with the help of special function-operators which include the keyword operator. Then you should specify the result type, the operator represented by characters and one or two parameters which are subject to the operation (either unary or binary). The parameters type coincides with the operands type, thus the parameters will contain the operand values. If the operation is considered to be binary, the first parameter represents the left operand and the second parameter represents the right one. To get the structured result, you will need to add the extra parameter.

If you want to describe comparison operators for your type then you can take only ==, < and > operators . Operators !=, >=, <= may not be described and are compiled to ==, < and > automatically.

<operator declaration> ::= operator <type name> <operator> '(' <parameters declaration> ')'
<operator> ::= <operator declaration><function body>

The operator-body is like the function-body

operator str +( str left right result ) //The + operator concatenates two strings.
{
   result = left
   return result += right  //the assignment operator as defined above is used
}
...
str a="One", b="Two

a = a + " " + b   //In this expression the + operator concatenates two strings

See also

Expressions And Operators


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


Properties

Gentee provides you with the property in order to get or set values of the fields of the structured types. Using the properties you can hide a direct access to the fields and perform additional calculations in order to get a field value or set a field value with the help of the assignment operator. A property name must differ from a field name, because a direct access to a field has a higher priority; otherwise, a field value will be got or set.

The get property, that returns a value, must contain no arguments.

type mytype
{
   str val
}

property str  mytype.value
{
   return this.val
}

The set property, that defines a value, must contain one argument. Also, the set property can return a value.

property str mytype.value( str newval )
{
    if *newval : this.val = newval
    else : this.val = "empty"
    return this.val
}

A property name is specified in the same way as a field in order to call a property. The set property is called if it is specified on the left side of the assignment operator; otherwise, the get property is called.

mytype myt

myt.value = "New value"  // set
print( myt.value )       // get

<property declaration> ::= property [<type name>] <type name>'.'<method name> ['(' [<parameters declaration>] ')']
<property> ::= <property declaration><function body>


extern Command

The extern command provides you with preliminary declaration of a function or a method or a statement. The command allows you to call a function before it has been defined. For example, a recursive function call from another function.
The keyword extern is followed by the block that contains function declaration. Each line of the block contains either function or method or operator declaration, excluding their bodies.

<extern> ::= extern '{' {(<function declaration> | <method declaration> | <operator declaration> )<end-of-line>} '}'
<function declaration> ::= func [<type name>] <function name> [<function attributes>] ['(' [<parameters declaration>] ')']
<method declaration> ::= method [<type name>] <type name>'.'<method name> ['(' [<parameters declaration>] ')']
<operator declaration> ::= operator <type name> <operator> '(' <parameters declaration> ')'


Returning variables

Gentee prevents returning local variables from functions and methods if the variables are not of the basic numeric data type. All structural local variables are deleted as soon as the function has finished executing. For example, if the next function is called, the error occurs.

func str func1
{
   return "Result string"
}

In such cases, the result attribute can be used. The attribute enables you to return a result value from functions or methods. Furthermore, using the attribute avoids defining and sending unnecessary local variables. Take advantage of this attribute in order to use the result variable, that will be returned as soon as the function has finished executing. If a function has the result attribute, the return instruction is not required or it must contain no expression.

func str myfunc<result>
{
   result = "Result string"
}
func main<main>
{
   print( myfunc())
}

Note that a function or a method of this type is called after a temprorary variable has been actually created in the calling block. The variable is sent to the function where it is used as the result variable.


Exception handling

Gentee supports throwing and handling exceptions. Taking advantage of exceptions simplifies an error processing. In particular, using exceptions enables us to avoid checking the returned function values for errors.

if myfunc( a )
{
   print( "Error!")
   return 0
}

is equivalent to

myfunc( a )

In addition, it would be better to handle a rollback by using exceptions rather than terminate the program abnormally.

exception | Exception handler definition.
throw | Throwing exceptions.
finally | Termination handling.


Exception handlers - exception

The exception function (command) defines the exception handlers. If a function throws an exception, the last exception handler function will be called. If the exception has not been handled, the previous handler function will be called. One handler-function can be defined in the function. An exception handler will be undefined when the function, where the handler was defined, has completed. An identifier of the exception handler-function is specified as the argument of the exception function.

<exception> ::= exception '('<expression>')'

An exception handler-function must have two arguments. The first argument must be of the uint type and defines an exception code. The second argument can be of any type ( except long, double, ulong ). The function returns the following values:
0 - the exception has not been handled. The previous handler-function will be called.
1 - the exception has been handled. If the handler-function returns this value, functions called after the handler had been defined, will be terminated sequentially. Furthermore, the function, where the given handler was defined, will be also terminated. All the functions will return zero.
2 - proceed with the program execution.

func uint myexcept( uint code, str param )
{
   if code == $MYEXCEPT
   {
      print( param )
      return 1
   }
   return 0
}

func a
{
   ...
   if i < 10 : throw( $MYEXCEPT, "The i value cannot be less than 10" )
   ...
}

func uint b
{
   exception( &myexcept )
   ...
   a()
   print("This message cannot be shown if there is an exception in a()\n")
   return 1
}

func main

{
   print( "The result of b() function = \( b())\n" )
   print("This message is always shown.\n")
}

In case of defining the second handler, the first handler will be undefined.

 // Here we can proceed with all exceptions
func uint myexcept1( uint code, collection param )
{
   ...
}

func uint myexcept2( uint code, collection param )
{
   ...
}

func main

{
   exception( &myexcept1 )
   ...  // All exceptions will be directed to myexcept1
   exception( &myexcept2 )
   // myexcept1 is disable
   // All exceptions will be directed to myexcept2
   ...
}

See also

Exception throwing - throw Termination handling - finally


Exception throwing - throw

The throw function (command) throws an exception. An exception code is required to be specified in the first argument, the type of the second argument must coincide with the type of the second argument in the appropriate handler-function. An exception codes that are less than 256 are reserved.

<throw> ::= throw '(' <expression> ',' <expression> ')'

func uint myexcept( uint code, uint param )
{
   if code == $MYEXCEPT
   {
      print( param->str )
      return 1
   }
   elif code == $MYUINTEXCEPT
   {
      print( "Exception: i = \( param )\n")
      return 1
   }
   return 0
}

func a
{
   ...
   if i < 10 : throw( $MYEXCEPT, "The i value cannot be less than 10" )
   ...
   if i > 100 : throw( $MYUINTEXCEPT, i )
}

See also

Exception handlers - exception Termination handling - finally


Termination handling - finally

In some cases if the exception occurs, additional operations must be performed. For example: to close files, to free the memory, etc. The finally command is used to perform these operations. The command can be used on the first level of block nesting inside the function. The code below this command will be executed even if the exception occurs. In this case, you are able to return the required value.

func a
{
   ...
   if i < 10 : throw( $MYEXCEPT, "The i value cannot be less than 10" )
   ...
   finally
   print("A: This message will be displayed in any case\n")
}

func uint b
{
   uint ret
   exception( &myexcept )
   ...
   a()
   print("This message cannot be shown if there is an exception in a()\n")
   ret = 1
   finally
   print("B: This message will be displayed in any case\n")
   return ret
}

<finally> :: = finally

See also

Exception handlers - exception Exception throwing - throw


Syntax Of the Gentee Language In BNF Form

      You can use ANSI character set from 0 to 255 in a source code.
ANSI character set from 32 to 128 are specified in the diagram defined above, other characters are represented in hexadecimal notation, for example 0x09 - a tab character. Some preprocessor commands are not shown in these diagrams.

<binary digit> ::= '0' | '1'

<decimal digit> ::= <binary digit> | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

<hexadecimal digit> ::= <decimal digit> | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'

<byte> := <hexadecimal digit><hexadecimal digit>

<decimal number> ::= <decimal digit> {<decimal digit>}

<hexadecimal number> ::= '0' ('x' | 'X') <hexadecimal number> {<hexadecimal number>}

<binary number> ::= '0' ('b' | 'B') <binary number> {<binarynumber>}

<character code> ::= '''<any character>'''

<floating point number> ::= <decimal number>'.'[<decimal number>]

<real number> ::= ['-'] (<floating point number> | <floating point number> ('e' | 'E') ['+' | '-'] <decimal number>) ['d' | 'D']

<natural number> ::= <decimal number> | <hexadecimal number> | <binary number> | <character code>

<integer number> ::= ['-'] <natural number> ['l' | 'L']

<number> := <integer number> | <floating point number> | <real number>

<letter> ::= 'A' | 'B' | ... | 'Z' | 'a' | 'b' | ... | 'z' | 0x80 | 0x81 | ... | 0xFF

<space> ::= 0x20

<tabulation> ::= 0x09

<end-of-line> := 0x0D 0x0A

<delimiter> ::= '!' | '"' | '#' | '$' | '%' | '&' | ''' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | '<' | '=' | '>' | '?' | '@' | '[' | '\' | ']' | '^' | '_' | '|' | '}' | '{' | '~' | <tabulation> | <space> | <end-of-line>

<character> ::= <decimal digit> | <letter> | <delimeter>

<name> ::= (<letter> | '_') {<letter> | '_' | <decimal digit>}

<function name> ::= <name>

<variable name> ::= <name>

<type name> ::= <name>

<field name> ::= <name>

<method name> ::= <name>

<attribute name> ::= <name>

<macro name> ::= <name>

<str character> ::= <tabulation> | <space> | '!' | '#' | ... | '[' | ']' | ... | 0xFF

<ext str character> ::= <str character> | '\'

<any character> ::= <ext str character> | '"'

<macrostring element> ::= {<str character>|<end-of-line>| '$'<macro name>}

<const string element> ::= <str character> | <end-of-line> | '\\' | '\"' | '\a' | '\b' | '\f' | '\n' | '\r' | '\t' | '\l' | '\0'<byte> | '\$'<macro name>'$' | '\$"' {<macrostring element>} '"' | '\#' | '\=' ( '\' | '/' | '~' | '^' | '&' | ':') | '\%['[ {<ext str character>} ]']'{<ext str character>}[{<ext str character>}] | '\[' {<any character>}']' | '\<'{<macrostring element>}'>'

<string element> ::= {<ext str character>} | '\('<expression>')'

<const string> ::= '"' { <const string element> | '\!'{<const string element>| '"'}'\!' }'"'

<string> ::= '"' { <string element>| '\!'{<string element>| '"'}'\!' }'"'

<const binary data element> ::= '\h'<space> [ ( '2' | '4' | '8' ) <space>] | '\i'<space> [ ( '2' | '4' | '8' ) <space>] | <hexadecimal digit> {<hexadecimal digit>} { (<space> | ',' | <end-of-line>) <hexadecimal digit> {<hexadecimal digit>} } |  <integer number> { (<space> | ',' | <end-of-line>) <integer number> } | '\'<const string> | '\[' {<any character>}']' | '\$'<macro name>'$' | '\$"' {<macrostring element>} '"' | '\<'{<macrostring element>}'>'

<binary data element> ::= <const binary data element> | '\('<expression>')'

<const binary data> ::= ''' {<const binary data element>} '''

<binary data> ::= ''' {<binary data element>} '''

<const collection> ::= '%{' <constant> {','<constant>} '}'

<collection> ::= '%{' <expression> {','<expression>} '}'

<constant> ::= <number> | <const string> | <const binary data> | <const collection>

<array> ::= [ '[' {','} ']' ] [of <type name>]

<object> ::= <variable name> | <pointer> | <array element> | <field> | <function call> | <method call> | <expression> | <late binding>

<pointer> ::= <expression>'->'<type name> [<array>]

<parameters> ::= <expression> {','<expression>}

<array element> ::= <object>'['<parameters>']'

<field> ::= <object>'.'<field name>

<late binding> ::=<object>'~' (<field name> | <method name>'(' [<parameters>] ')')

<function call> ::= (<function name> | <expression>'->'func ) '(' [<parameters>] ')'

<method call> ::= <object>'.'<method name>'(' [<parameters>] ')'

<lvalue> ::= <object> | <variable name> | <pointer> | <array element> | <field>

<sizeof> ::= sizeof '(' (<type name> | <expression>) ')'

<as operation> ::= <variable name>'as' ((<type name>[<array>]) | <object>)

<operand> ::= <lvalue> | <constant> | <string> | <binary data> | <collection> | <function call> | <method call> | <type name> | <late binding>

<increment operator> ::= '++' | '--'

<assignment operator> ::= '=' | '%=' | '&=' | '*=' | '+=' | '-=' | '/=' | '<<=' | '>>=' | '^=' | '|='

<unary operator> ::= '+' | '-' | '*' | '!' | '~' | '@'

<bynary operator> ::= '==' | '!=' | '>' | '<' | '<=' | '>=' | '&&' | '||' | '&' | '%' | '*' | '/' | '+' | '-' | '<<' | '>>' | '^' | '%==' | '%!=' | '%>' | '%<' | '%<=' | '%>=' | '@'

<operator> ::= <increment operator> | <assignment operator> | <unary operator> | <bynary operator>

<assignment expression> ::= <lvalue><assignment operator><expression>

<lvalue expression> ::= '&'<lvalue> | '&'<function name> | <increment operator><lvalue> | <lvalue><increment operator>

<question> ::= '?''(' <expression>',' [<expression>] ',' [<expression>] ')'

<expression> ::= <operand> | <assignment expression> | <lvalue expression> | <expression><bynary operator> [<end-of-line>] <expression> | '('<expression>')' | <unary operator><expression> | <as operation> | <sizeof> | <question>

<variable declaration> ::= <variable name> ['['<expression> { [','] <expression>} ']'] [of <type name>]

<variable list> ::= <variable declaration> ['='<expression>','<variable list>] | <variable declaration> [[',']<variable list>]

<variables declaration> ::= <type name><variable list><end-of-line>

<if> ::= if <expression><block> {elif <expression> <block>} [else <block>]

<while> ::= while <expression><block>

<dowhile> ::= do <block> while <expression>

<for> ::= for [<expression>] ','<expression>',' [<expression>] <block>

<fornum> ::= fornum <variable name> ['='<expression>] ','<expression><block>

<foreach> ::= foreach [<type name>] <variable name> [<array>]','<expression><block>

<return> ::= return [<expression>]

<label> ::= label <label name>

<exception> ::= exception '('<expression>')'

<throw> ::= throw '(' <expression> ',' <expression> ')'

<finally> :: = finally

<goto> ::= goto <label name>

<switch> ::= switch <expression>'{' {case <expression> {','<expression>} {<label>}  <block>} [default {<label>} <block>] '}'

<block contents> ::= <block command> {<end-of-line><block command>}

<block> ::= '{'<block contents>'}'

<block command> ::= {<label>} (<block> | <expression> | <variables declaration> | <if> | <for> | <fornum> | <while> | <dowhile> | <foreach> | <switch> | break | continue | <return>)

<parameter declaration> ::= <variable name> [<array>]

<parameters declaration> ::= <type name><parameter declaration> { [','] <parameter declaration>} [<parameters declaration>]

<attributes> ::= '<'<attribute name> { [','] <attribute name>} '>'

<function attributes> ::= <attributes>

<field attributes> ::= <attributes>

<type attributes> ::= <attributes>

<subfunction> ::= subfunc [<type name>] <function name> ['(' [<parameters declaration>] ')'] <block>

<function body> ::= '{' (<block command> | <subfunction>) <block command> {<end-of-line> (<block command> | <subfunction>) } '}'

<function declaration> ::= func [<type name>] <function name> [<function attributes>] ['(' [<parameters declaration>] ')']

<func> ::=  <function declaration><function body>

<method declaration> ::= method [<type name>] <type name>'.'<method name> ['(' [<parameters declaration>] ')']

<method> ::= <method declaration><function body>

<property declaration> ::= property [<type name>] <type  name>'.'<method name> ['(' [<parameters declaration>] ')']

<property> ::= <property declaration><function body>

<operator declaration> ::= operator <type name> <operator> '(' <parameters declaration> ')'

<operator> ::= <operator declaration><function body>

<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>

<macro declaration> ::= <macro name> ['=' (<constant>|<name>) ]

<define> ::= define [<attributes>] '{'<macro declaration> {<end-of-line><macro declaration>} '}'

<macro expression> ::= <macro> | <constant> | '!'<macro expression> | '('<macro expression>')' | <macro expression> ( '&&' | '||' | '==' | '!=' ) <macro expression>

<ifdef> ::= ifdef <macro expression> '{' ... '}' { elif <macro expression> '{' ... '}' } [ else '{' ... '}']

<file name> ::= '"' {<str character>} '"'

<include> ::= include '{'<file name> {<end-of-line><file name>} '}'

<imported function declaration> ::= [ <type name> ] <function name> '(' [ <type name> { ','<type name> } ] ')'  [ '->' <function name>]

<import> ::= import <file name> [<attributes>] '{' <imported function declaration> { <end-of-line><imported function declaration> } '}'

<field declaration> ::= <field declaration> [<field attributes>] [<array declaration>]

<field declaration> ::= <type name><field declaration> {[','] <field declaration>}<end-of-line>

<type> ::= type [<type attributes>] '{'<field declaration>{<field declaration>} '}'

<array declaration> ::= ['['<natural number> { [','] <natural number>} ']'] [of <type name>]

<global variable declaration> ::= <variable name> [<array declaration>]['=' <constant> ]

<global variable declaration> ::= <type name><global variable declaration> {[','] <global variable declaration>}<end-of-line>

<global> ::= global '{' {<global variable declaration>} '}'

<public> ::= public

<private> ::= private

<extern> ::= extern '{' {(<function declaration> | <method declaration> | <operator declaration> )<end-of-line>} '}'

<command> ::= <define> | <func> | <method> | <text> | <operator function> | <include> | <type> | <global> | <extern> | <import>

<program> ::= <command> {<end-of-line><command>}

See also

Syntactical description


Table of Type Conversions

The table provides information about types which have conversion functions. Source types are listed in the rows, destination types are listed in the columns. The mark allocated in the cell shows that there are conversion functions for the specified types. If you would like to know about the possibility to convert data from int type to float type, you should find the row that contains float and the column with int. There is a mark in the obtained cell; therefore, you can use the function: float( <int> ).
 | sbyte | byte | short | ushort | int | uint | float | long | ulong | double | buf | str
sbyte |  |  |  |  |  |  |  |  |  |  |  |
byte |  |  |  |  |  |  |  |  |  |  |  |
short |  |  |  |  |  |  |  |  |  |  |  |
ushort |  |  |  |  |  |  |  |  |  |  |  |
int |  |  |  |  |  |  |  |  |  |  |  |
uint |  |  |  |  |  |  |  |  |  |  |  |
float |  |  |  |  |  |  |  |  |  |  |  |
long |  |  |  |  |  |  |  |  |  |  |  |
ulong |  |  |  |  |  |  |  |  |  |  |  |
double |  |  |  |  |  |  |  |  |  |  |  |
buf |  |  |  |  |  |  |  |  |  |  |  |
str |  |  |  |  |  |  |  |  |  |  |  |


Quick Launch

Let’s consider the easiest way of launching programs developed in Gentee. Currently there is no a special shell for entering and launching Gentee programs, therefore you will need a text editor and Windows Explorer, or a file manager. Use the “.g” extension when saving programs entered in a text editor, since it will be easier to launch them using the method described below.

Let’s consider an example. In a file manager or Explorer, open the directory, to which Gentee was installed (as a rule, it is C:\Program Files\Gentee) and select the Tutorial subdirectory, in which you will see a list of examples. To launch an example, double-click on it, or press Enter. In the same way the files with .ge extension are launched ( compiled Gentee programs ).

You can create shortcuts in Start->Programs or Desktop for frequently used Gentee programs. It is enough to specify a file with “.g” or “.ge” extension as an executable file. When using shortcuts, launching becomes much easier.

See also

Launch from Command Line


Launch from Command Line

Compilation and execution of a Gentee program is performed with the help of the console application gentee.exe.

gentee.exe [switches] <source file> [arguments]

source file is an required parameter and it should specify name of the compilation file or a file with bytecode to be executed.

switches - options. The following options are available during compilation process.
-r – Launch the program after the compilation is accomplished.
-v – Do not save bytecode to the file. This option can be used together with the previous one, if you don’t need a compiled file.
-l – Do not link the standard library.
-s – Do not display service message during compilation or running.
-i – A combination of -r -v -s switches. Gentee works like an interpretator.
-n - Ignore the command '#!' in the first string of the file.
-o <output file> – Specify a name for the compiled file. In this case, next part should be the name of the output file output file. This feature is used if you want the file with bytecode to have a name (or destination) different from the source file. By default, the compiled bytecode is stored in the file with .ge extension.

-d – If this option is specified, all other command line parameters are considered as define definitions. Here you can specify necessary macros of the compilation. It is necessary to prefix the quotation mark with '\'. Macros’ definitions should be separated by semicolons. By default, all components after the filename are used as command line parameters, when application is launched.

If you specified a file with executable bytecode as an input file, all parameters after executable file’s name are considered as command line parameters.

gentee.exe -r -v myfile.g
gentee.exe -r myapp.g "command line agrument" 10 20
gentee.exe -s myapp.ge "command line agrument"

See also

How to create an EXE file Error codes and message codes


Using '#!' command

Under Linux, '#!' in the first line is used to start the compiler. Under Windows, you can also use the first line in a file to start any programs, including those used for compiling with the necessary parameters. If you click such a .g file or press Enter, the specified command line will be executed. It allows you to avoid using additional batch files ( .bat ).
For example,

#!gentee.exe -s -l -i hello.g
#!gentee.exe -r -v "%1"

You can specify both absolute and relative paths to the program and the file you want to start. You can specify %1 as the full name of the current file. If the path contains spaces, you should enclose it in double quotation marks.
For example,

#!"C:\My Application\my.bat" "%1"
#!ge2exe.exe -e "%1"

The last example will immediately create and start an EXE file.


How to create an EXE file

If you want to launch Gentee programs as exe files, then use the ge2exe program. It allows to create an .exe file from a source file (.g file) or a compiled bytecode (.ge file). Such .exe file is executed without any extra modules. It can be useful, when you wish to use the program on other computers. GE files are created when compiling programs in Gentee.

ge2exe.exe [switches] <source file> [output file]

switches - options. You can specify the following options:
-e – launch the .exe file after creation.
-d – do not include gentee.dll to the created .exe file. In this case, for launching the program gentee.dll is required. This option may be useful if you have several programs in one directory.
-w – wait for keystroke after the .exe file is created.
-i - link .ico file. It must be the next argument.
-i "c:\data\myicon.ico"
-r - link .res file. It must be the next argument.
-r "c:\data\myres.res"
-c - make a console application. Default for .g and .ge files.
-g - make a gui application. Default for .gw and .gwe files.

source file is a required parameter, and should point the name of the file with bytecode or source code. The following extensions are supported: .G, .GW, .GE, .GWE .

output file is an accessory parameter, in which you can point a name for the created .exe file. By default, if this parameter is not specified, the executable will have the same name as the source file, but with extension exe.

ge2exe.exe -r myapp.ge
ge2exe.exe myapp.ge c:\output\app.exe

Important notice for Windows 95,98,ME users!

It is required unicows.dll for creating EXE files. Unfortunately, it is not in the Windows 95/98/ME installations. So, if you don't have unicows.dll on your computer then you can download it from Microsoft site and install it.
http://www.microsoft.com/downloads/details.aspx?FamilyID=73ba7bd7-ed06-4f0d-80a4-2a7eeaee17e2&displaylang=en

Additional modules

Portions Copyright © 2005 Alexander Pashkov ( EXELink.dll )
Web: http:\\scriptcom.narod.ru

See also

Quick Launch Launch from Command Line


Gentee API functions

There is an option for software engineers to run programs in Gentee in their own applications. To do that, it is enough to connect the gentee.dll file. It contains several importable functions, which are responsible for compilation and execution of the programs. In the Examples subdirectory, there are two identical projects written in Delphi and MS Visual C/C++. They illustrate basic features of working with Gentee from external programs.

ge_call | Calling the function from the bytecode
ge_compile | Program compilation
ge_deinit | End of working with gentee.dll
ge_execute | Compilation and program run
ge_freebcode | Deallocation of structure with the resulting bytecode
ge_getid | Object’s identifier from the bytecode
ge_init | Initialization of gentee.dll
ge_load | Launch bytecode

See also

Examples MS Visual C/C++ and Delphi


Examples MS Visual C/C++ and Delphi

There are two identical projects written in Delphi and MS Visual C/C++In the Examples in the subdirectory, where the 'Gentee programming language' is installed. These examples illustrate Gentee’s basic capabilities of integration with applications written in other languages. Both projects contain all incoming texts required for compilation.

See also

Gentee API functions


Error codes and message codes

This messages and errors are displayed in case of need by console compiler and interpreter, and also transferred to the message-handler function when using gentee.dll.
Messages of the virtual machine
0x0001 | Start executing
0x0002 | End executing
Messages of the compiler
0x0003 | Start compiling
0x0004 | End compiling
0x0005 | Loading the file for compiling
Errors of the virtual machine
0x0100 | Object has been already used
0x0101 | This is not GE execute code
0x0102 | Wrong CRC of GE execute code
0x0103 | This GE version is not supported
0x0104 | Unknown loading command in GE data
0x0105 | Unknown run-time command
0x0106 | Undefined name
0x0107 | Stack is overflow
0x0108 | Internal error
0x0109 | Unknow exception error
0x010A | Object is not a type
Errors of the compiler
0x0200 | Cannot open file
0x0201 | Cannot read file
0x0202 | Cannot write file
0x0400 | Must be the name of the identifier
0x0401 | The type was not defined
0x0600 | There is not the such attribute
0x0601 | The wrong count of parameters
0x0602 | The value must have a numeric type
0x0603 | Unknown Gentee language command
0x0604 | Unexpected end of file found in command
0x0605 | Must be left curly here
0x0606 | Unacceptable macro value
0x0607 | Undefined macroname
0x0608 | Cannot use expression here
0x0609 | Incompatible type of the macro
0x060A | Must be the string value here
0x060B | Unsupported operation
0x060C | Must be an expression here
0x060D | Function for this operation or method was not defined
0x060E | Object with this name has been already defined
0x060F | Unacceptable name of the identifier
0x0610 | There is not the such field in the structure
0x0611 | This field name has already been defined
0x0612 | The value has the different type from the definition of the function
0x0613 | Such method or operator has already been defined
0x0614 | Such method or operator must return the value
0x0615 | The type of the returned value is wrong
0x0616 | There is not RESULT parameter in this method or operator
0x0617 | This operator cannot be overrided
0x0618 | This atribute requires the value
0x0619 | The attribute is compatible with 'uint' type just
0x061A | The attribute can be specified one time just.
0x061B | Declared formal parameter list is different from the previous definition
0x061C | It is impossible to inherit from the specified type
0x0800 | There is not left parenthesis or bracket
0x0801 | Syntax error
0x0802 | Unknown lexem
0x0803 | Unexpected operand in expression
0x0804 | Must be an operand here
0x0805 | Main or Entry function must not have parameters
0x0806 | Variable with the such name has already been defined
0x0807 | Syntax error. There is not right parenthesis or bracket
0x0808 | The type of the return value is different from the definition
0x0809 | It is impossible to use keyword here
0x080A | Label was not defined
0x080B | The operand must be l-value
0x080C | Label has already been defined
0x080D | A logic expression must be here
0x080E | This command can be used in 'for', 'while' operators
0x080F | A comma must be here
0x0810 | keyword 'while' must be here
0x0811 | Subfunc can be defined in the main body of the function
0x0812 | 'return' must be in the function
0x0813 | The name of the method is wrong. Must be 'typename.methodname'
0x0814 | The name of the operator is wrong
0x0815 | The expression must return value
0x0816 | Must be the right curly here
0x0817 | The count of parameters in '?' operator is wrong
0x0818 | The types of parameters in '?' operator must be same
0x0819 | The variable must have 'uint' type
0x081A | The type of the variable does not have 'index' method
0x081B | The type must be specified here
0x081C | The expression must return 'uint' value
0x081D | The unsigned integer must be specified here
0x081E | The type of the variable does not have 'array' method
0x081F | The type of the variable does not have 'oftype' method
0x0820 | The type cannot have more then one dimension
0x0821 | The variable has the different dimension
0x0822 | The value must be between 4 and 65535
0x0823 | Syntax error in 'ifdef' or 'elif' condition
0x0824 | The type of the index value must be 'uint'
0x0825 | Unacceptable type
0x0826 | Unacceptable variable
0x0827 | Type doesn't have methods for 'foreach' operation
0x0828 | The type of the variable is different from the type of the object's item
0x0829 | 'text' function cannot return a value
0x082A | Cannot use '&' with 'text' function
0x082B | The type of the value is different from the type of the variable
0x082C | Cannot use 'finally' here
0x082D | Result function (method) cannot return a numeric type
0x082E | Result function (method) cannot has 'result' parameter
0x082F | There is not the such 'property'
0x0830 | Unacceptable operator for 'property'
0x0A00 | Unknown character
0x0A01 | Unexpected end of file found in comment
0x0A02 | The name of the identifier is too long
0x0A03 | Unknown string command
0x0A04 | Unknown numeric format
0x0A05 | The name of the macro must be specified in the string
0x0A06 | Unknown binary data command
0x0A07 | Unexpected end of file found in string
0x0A08 | Unexpected end of file found in binary data
0x0A09 | The name of the source code name is not defined
0x0A0A | Unexpected end of file found in expression or operator
0x0A0B | Unacceptable auxiliary character in '=' command
0x0A0C | The name of the macro or string must be defined after '$'
0x0A0D | Error in \@[...]. The name is too long
0x0A0E | Error in \@[...]. Unexpected end of file


Introduction

Welcome to Gentee Programming Language! This tutorial will help you master our programming language by using easy-to-understand examples.

You should have some familiarity with computers. But it is not essential to have extensive experience in programming or to know any other computer languages. In fact, these lessons were written under the assumption that you have little or no programming skills.

The tutorial begins with basic concepts and then builds on them with more complex lessons. If a lesson is too simple for you, skip over it! If you're a novice, take things step-by-step.

This tutorial does not concentrate primarily on the syntax and semantics of Gentee Programming Language. (Information about this can be found in the documentation.) Instead, the tutorial concentrates on the development of language skills by developing software solutions to practical computing problems. Furthermore, each lesson includes a self-study exercise for independent work. We feel that programming skills are best acquired through practice. Therefore, we recommend that you complete the exercises.

Each lesson features source code that will help you understand how to develop programming solutions. If developing solutions seems daunting, carefully examine the source code for hints about how the program works. These source programs are located in the Tutorial subdirectory of the Gentee distribution kit.

File names are created according to the following rule: lesson<the number of a lesson>.<the number of an exercise or an example>.g. Note that the examples and the exercises of each lesson share the same numbering.

If you encounter difficulty, send us an e-mail and we will try to help you troubleshoot the problem. If your problem provides a useful lesson for others, we will seek your permission to disassemble the program and release it to others to provide them with better understanding.


Lesson 1

There is a tradition in programming tutorials to show the code that prints "Hello, World!" on the computer screen. We will adhere to that tradition by showing you the Gentee code that produces "Hello World:"

Example 1

func hello <main>
{
   print( "Hello, World!" )
   getch()
}

To understand how the code displays the results printed on your screen, you need to understand certain concepts.

The "Hello World" printed on the screen is called a "function." A function is a type of procedure or routine that performs a specific task. Some programming languages make a distinction between a function, which returns a value, and a procedure, which performs a specific task but does not return a value In the case of Gentee, functions are denoted by the operation set that performs any task.

Functions can be called from other ones. Functions are described by the keyword func in Gentee. The function with the name hello and the attribute main have just been mentioned, the attribute means that this function will be run after loading the program.

print( "Hello, World!" )

print is a function call outputting the specified string.

A string is a series of characters manipulated as a group. A character string is often specified by enclosing the characters in quotes. For example, WASHINGTON would be a name, but "WASHINGTON" would be character strings. In Gentee, strings are enclosed in double quotes. In other words, the quote marks help you define a string.

After we designate a character string, we call another function getch that results in a keystroke delay.

More information about this coding can be found in the documentation. In the lessons you can also find information about other functions and methods.

Now, let's talk about strings. There is a command character '\', that performs some actions depending on the following characters. This example demonstrates some of them:

\n represents a new line.
\\ represents the symbol: backslash '\'.
\@ is the undo operation '\' as a command character.

In addition to this, Gentee saves line feeds within the string. A line feed is a code that moves the cursor on a display screen down one line. In the example below, the following strings are equivalents.

"Hello, World!
Hello, World!"

"Hello, World!\nHello, World!"

Exercise 2

Make a program "Hello, World!" that prompts the user to press any key.


Lesson 2

You will get acquainted with numbers in this lesson. We will first try to make a program to calculate the area of a rectangle and of a circle. We will use numbers with double precision (double type). Double precision refers to a type of floating-point number that has more precision, or more digits to the right of the decimal point, than a single-precision number.

To begin with, create a framework of the function.

func main<main>
{
   while 1
   {
      print("Enter the number of the action:
1. Calculate the area of a rectangle
2. Calculate the area of a circle
3. Exit\n")
      switch getch()
      {
         case '1'
         {
            print("Specify the width of the rectangle: ")
            print("Specify the height of the rectangle: ")
         }
         case '2'
         {
            print("Specify the radius of the circle: ")
         }
         case '3', 27 : break
         default : print("You have entered the wrong value!\n\n")
      }
   }
}

There are two new statements here: while and switch.

The while statement repeats the execution of a code, while the conditional expression is nonzero. In this case, the condition equals 1, that means an endless loop and the command break ,as defined below, causes an exit from the loop.

A loop is one of the three basic logic structures in computer programming. The other two logic structures are selection and sequence.

The switch operator evaluates an expression and looks for the value through the values. case. While the program is waiting for the keystroke, a user thinks of further actions. Now let's take a look at the following line:

case '3', 27 : break

Notice that the possible values separated by commas are enumerated in case. 27 determines the key code Esc. As for the symbol ':', it is denoted by the following line enclosed in braces. In other words, this fragment is equivalent to the following one:

case '3', 27 { break }

The use of braces is often required by Gentee, a usage of the symbol ':' helps you escape piling characters in simple tasks.

To perform calculations we use a string type of a variable for the return values and a double type of two variables in order to store values. You can start by appending:

str     input
double  width height

Variables of the same type are separated by a comma or a single space.

Now you can perform calculations and get answers. So, to calculate the area of a rectangle we could construct code like this:

print("Specify the width of the rectangle: ")
width = double( conread( input ))
print("Specify the height of the rectangle: ")
height = double( conread( input ))
print("The area of the rectangle: \( width * height )\n\n")

The conread function reads data input by a user. The \(...) operation within the string evaluates the expression enclosed in brackets and inserts data into the string.

To calculate the area of a circle, we can create another example similar to the code, above:

print("Specify the radius of the circle: ")
width = double( conread( input ))
print("The area of the circle: \( 3.1415 * width * width )\n\n")

Exercise 2

Write a program that calculates the perimeter of a rectangle and of a circle. Use a separate function for the perimeter of each shape.


Lesson 3

Example 1

Now we will analyze an example that finds the greatest common divisor of two numbers (GCD).

We take advantage of Euclid's Algorithm for the task solution. It works like this:

GCD( x, y ) = x if y equals 0 and
GCD( x, y ) = GCD( y, x MOD y ) if y is nonzero.

x MOD y is the remainder of values.
In other words, dividing two numbers we compute the remainder of the values but if the remainder is nonzero, the second number and the remainder of the values must be considered, etc.

The following fragment provides an obvious example of recursion, that's used to have a function call itself from within itself.
This function is written like this:

func uint gcd( uint first second )
{
   if !second : return first
   return gcd( second, first % second )
}

% is used to divide two numbers and returns the remainder.
uint is a type designating a positive integer.
if is a conditional statement shown in the following example:

if condition {
}
elif condition {
}
else {
}

Note: An infinite number of elif blocks can be used. If the condition is TRUE, statements in braces following this condition will be executed.

Finally, it is time to write the main function that can receive the data from the user and call gcd. The function contains the following loop:

while 1
{
   first = uint( congetstr( "Enter the first number ( enter 0 to exit ): ", input ))
   if !first : break
   second = uint( congetstr( "Enter the second number: ", input ))
   print("GCD = \( gcd( first, second ))\n\n")
}

congetstr is a function provided by standard libraries, it outputs a text to the screen and receives the data from the user.

Example 2

Calculate a factorial n! for n from 1 to 12. A factorial determines the product of numbers up to the given number inclusive.

The following program demonstrates its task solution:

func uint factorial( uint n )
{
   if n == 1 : return 1
   return n * factorial( n - 1 )
}

func main<main>
{
   uint    n

   print("This program calculates n! ( 1 * 2 *...* n ) for n from 1 to 12\n\n")
   fornum n = 1, 13
   {
      print("\(n)! = \(factorial( n ))\n")
   }
   getch()
}

The fornum loop is executed while the counter variable "n" is considered less than the value of the second expression. The loop counter increases by increments of 1 at each step. fornum is a special case of the for operator - more on that later.

for counter = expression,expression,change of the value of counter
{
}

Exercise 3

Now we need to calculate the Fibonacci numbers.

These are a series of whole numbers in which each number is the sum of the two preceding numbers. Beginning with 0 and 1, the sequence of Fibonacci numbers would be 0,1,1, 2, 3, 5, 8, 13, 21, 34, etc. using the formula: n = n(-1) + n(-2), where the n(-1) means "the last number before n in the series" and n(-2) refers to "the second last one before n in the series."

We will calculate until the last number exceeds 2000000000. Use a recursive function.
X0 = 1
X1 = 1
...
Xn = Xn-1 + Xn-2

Exercise 4

Perform the previous task without the use of recursion.


Lesson 4

Example 1

Calculate primes using "The Sieve of Eratosthenes".

Now we will explain the task.

Primes are products of two numbers. In other words, a prime is divisible only by itself or 1. So, calculating primes by means of "The Sieve of Eratosthenes" is done like this:
We start with a list of candidates containing numbers from 2 to the definite number. 2 is a prime. We remove all even numbers from the list. Now, we will take 3 and remove all the numbers that are products of it. After this, we find the next number from the candidate list. This number is 5, then we remove the fifth numbers from the list, etc. Therefore, when the candidate list is empty, the result list will contain all the primes.

Let's break the problem into two steps. The first step takes advantage of the algorithm, and the second step outputs the results to the screen.

str   input
uint  high i j

print("This program uses \"Sieve of Eratosthenes\" for finding prime numbers.\n\n")
high = uint( congetstr("Enter the high limit number ( < 100000) : ", input ))
if high > 100000 : high = 100000

arr  sieve[ high + 1 ] of byte

fornum i = 2, high/2 + 1
{
   if !sieve[ i ]
   {
      j = i + i
      while j <= high
      {
         sieve[ j ] = 1
         j += i
      }
   }
}

To begin with, a user should enter the number which is defined as the final candidate in the list. We want all primes below 100000 in order to not use a lot of resources.

arr  sieve[ high + 1 ] of byte

sieve is a description of an array of bytes. And array is a series of objects, all of which are the same size and type. Each object in an array is called an array element. For example, you could have an array of integers or an array of characters or an array of anything that has a defined data type. The important characteristics of an array are that (1) Each element has the same data type (although they may have different values). (2) The entire array is stored contiguously in memory.

The first element in the array is the 0th element, therefore let's set 1 to this number. Actually, arrays and variables are zero-based. So, if an element of the array equals 0, then this based number is not removed. If we remove it, we'll set 1 to this number.

For the fornum loop we use only half of the numbers. Why do we do this? Think it over. Then we apply the algorithm. As you can see, it takes up several strings. Let us jump into an example that illustrates how it works:

j += i

This is an extension of the j variable to i. Similar operations are applied for the multiplication, the division, the subtraction.

The numbers has already been removed; let's now jump to the second step.
It is certainly possible that the numbers are output to the screen, nevertheless let's save a file.

j = 0
input.setlen( 0 )

fornum i = 2, high + 1
{
   if !sieve[ i ]
   {
      int2str( input, "%8u", i )
      if ++j == 10
      {
         j = 0
         input += "\l"
      }
   }
}
input.write( "prime.txt" )
shell( "prime.txt" )

To find out more about the int2str function, read the documentation. In this case each number is extended to eight symbols by spaces. Furthermore, after outputting each tenth number we start a new line. The j variable performs it.
A combination of carriage return '\r' and newline '\n' is used for line feed in text files. In Gentee there's only '\l' command which executes it.

The write method writes the string to the file, and the function shell opens this specified file in the appropriate application.


Lesson 5

This lesson focuses on files.

Example 1

Set or remove the attributes of the files a read-only file. This program accepts command line parameters. The files can be stored in templates, using the following operators: '*' and '?'. The '*' operator defines any sequence of characters, '?' represents a single character.
Thus,
c:\temp\*.* - all files in the folder c:\temp
c:\temp\*.exe - all files with the extension exe in the folder c:\temp
c:\temp\a*.* - all files beginning with 'a' in the folder c:\temp
c:\temp\ab?*.* - all files beginning with 'ab' and one other character in the folder c:\temp

So, we start with command line. It is fairly easy, because of two functions: argc returns the number of arguments, argv returns the required parameter. The first parameter must be the word on or off for setting or removing the attribute, the second parameter must be the template for file processing. So, we can do it like this:

if argc() > 1
{
   if argv( temp, 1 ) %== "on" : mode = 1
   elif argv( temp, 1 ) %== "off" : mode = 2
   argv( path, 2 )
}

The '%==' operator produces a line-by-line comparison ignoring the characters' case. Here, you can write ON as well as Off.

If the parameters have not been indicated by the time the program starts or you typed ones that are not valid, give a chance to input necessary information on the console.

if !mode
{
   mode = conrequest("Choose an action (press a number key):
1. Turn on readonly attribute
2. Turn off readonly attribute
3. Exit\n", "1|2|3" ) + 1

   if mode == 3 : return
   congetstr( "Specify a filename or a wildcard: ", path )
}

Here the user has to type: 1 to set the attribute, 2 to remove it and 3 to exit the program. The conrequest function waits for the keystroke, then returns the number of the selected variant from 0.
For example,

conrequest("Press 'Y' or 'N'", "Yy|Nn" )

OK. Now we proceed to the task solution. The ffind structure searches for the specified filename. Let's describe and initialize the variable fd of type ffind.

 fd.init( path, $FIND_FILE | $FIND_RECURSE )

$FIND_FILE points to the search of specified filenames.
$FIND_RECURSE indicates the search of specified filenames in all subdirectories.

For instance,

fd.init( "c:\\temp.txt", $FIND_FILE | $FIND_RECURSE )

with the specified flag $FIND_RECURSE will search for the filename: temp.txt on the entire C: drive.

The foreach operator is used for file searching:

foreach finfo cur,fd
{
   attrib = getfileattrib( cur.fullname )
   if mode == 1 : attrib |= $FILE_ATTRIBUTE_READONLY
   else : attrib &= ~$FILE_ATTRIBUTE_READONLY

   setfileattrib( cur.fullname, attrib )
   print("\(cur.fullname)\n")
}

finfo is a type that stores information about files. More information about this can be found in Help.
cur is a variable of the specified type which contains the stored information about any file that has been found.

Now, I would like to say a few words about loop content. We obtain the current file attributes

attrib = getfileattrib( cur.fullname )

According to conditions we set or remove the attribute of the file a read-only file. Other attributes are saved.

if mode == 1 : attrib |= $FILE_ATTRIBUTE_READONLY
else : attrib &= ~$FILE_ATTRIBUTE_READONLY

We write the modified attributes of the file.

setfileattrib( cur.fullname, attrib )


Lesson 6

Now we try to automate the EXE files created using the ge2exe program, which is integrated into the compiler. This lesson describes the procedure mentioned above, making it easier for users to create the EXE files.

Example 1

. Let INI-file be a file, which contains the information about programs in the Gentee language. We have to help users choose a program from the given list, compile it and create the EXE file, if necessary.

We start with the description of the INI-file format. Each section denotes a program and consists of the following fields:
Name is the name of a program.
Src is the .g file of a program.
Exe - to create the EXE file or not (If the field contains a 1 or a 0).
Run - to run the program after successful compilation or not.
Nodll - If the field contains a 1, the gentee.dll file is not attached to the executable file. In this case the program starts if only the gentee.dll file is available.
Output - If you want to change the last file name or store it in the other directory, you should enter the specified file name and its path here.

Note that the Src is a required field.

[Lsn2]
Name = Lesson 2
Src  = lesson2.1.g
Run  = 1
Exe  = 0

The INI-file can be changed; it`s up to you. Moreover, you can add elements. Take a look at the lesson6.1.ini file used as an example in the Tutorial subdirectory.

The ini.ge library is required to deal with the INI-file. So, let`s include the library by using the include command. To illustrate this, assume that these examples are located in the subdirectory Tutorial, so we use the relative path. If you would like to carry this example to another directory, you should enter the absolute path.

include : $"..\lib\ini.ge"

The string with the initial dollar sign '$' does not contain any command characters, however it may contain macros. It is interesting to note that the use of such strings makes it easier to define the path to the files, because there is no need to double the '\' sign.

Let's write two auxiliary functions.

func uint  openini( ini retini )

The openini function reads data from the lesson6.1.ini - file; but if the file is not available, the error message is displayed. If you want to get the error code, take a look at the source program.

func uint  idaction( ini retini, str section )

This function is considered to be significant. It calls the program that can compile and create the exe-file. The first argument is the file object ini, the second one is the name of the section that should be launched.

The following statements read the field values.

retini.getvalue( section, "Src", src, "" )
if !*src
{
   congetch("ID '\(section)' is not valid. Press any key...\n")
   return 0
}
run = retini.getnum( section, "Run", 1 )
exe = retini.getnum( section, "Exe", 0 )
nodll = retini.getnum( section, "Nodll", 0 )
retini.getvalue( section, "Output", outname, "" )

Note that the last argument of the getvalue and the getnum functions defines the value, if this field isn't defined in the INI-file.

Using the options from the INI-file, the following code generates command lines in order to start up the compiler and ge2exe. The process function makes the programs start up. The "." directive, as the second argument of the process function, indicates that gentee.exe and ge2exe.exe will use the current directory as their working directory.

name = "..\\gentee.exe"
if exe
{
   process( "\(name) \(src}", ".", &result )
   name = "..\\ge2exe.exe"
   if run : name += " -e"
   if nodll : name += " -d"
   src.fsetext( src, "ge" )
   if *outname : src += " \( outname )"
   process( "\(name) \(src)", ".", &result )
}
else
{
   if run : name += " -r"
   if *outname : name += " -o \(outname}"
   process( "\(name) \(src}", ".", &result )
}

Let us jump into an example that illustrates the function body, which displays a list of possible programs and receives the program name chosen by a user:

ini   tini
arr   sections of str
str   name src section

openini( tini )

tini.sections( sections )
while 1
{
   print( "-----------\n" )
   foreach  str cur, sections
   {
      tini.getvalue( cur, "Src", src, "" )
      if !*src : continue

      tini.getvalue( cur, "Name", name, src )
      print("ID: \(cur)".fillspacer( 20 ) + name + "\n" )
   }
   print( "-----------\n" )
   congetstr("Enter ID name (enter 0 to exit}: ", section )
   if section[0] == '0' : break

   idaction( tini, section )
}

First, we read the INI-file and get the section list contained in a string array. After the program list is displayed in a window, a user should choose a program name. Then, we call the idaction function with the required program name.

Here, the following string is described in detail.

print("ID: \(cur)".fillspacer( 20 ) + name + "\n")

The fillspacer method appends a specified number of space characters onto the end of the string. As you can see, we call the method on the string enclosed in double quote marks. Note, that in Gentee a string enclosed in double quote marks is the same object as a variable of type str. Furthermore, we can call methods on functions and other methods, which return strings.
For example, the expression given below appends ten space characters onto the end of the string, thus increasing the string's length to 30 characters.

 "ID: \(cur)".fillspacer( 20 ).fillspacel( 30 )

Exercise 2

Write a program using lesson6.1.g, that gets a program-section name from a command line and runs it. If no command-line argument is specified, this program must work like the program discussed above.

Tip: my program consists of 14 lines. For more details about this, read lesson6.2.g.


Lesson 7

This lesson presents one type of function, the text function. As its name suggests, this type of function deals with texts. Unlike other functions, a text with built-in code serves as the basis for text functions.

Example 1

Display a color palette, which is frequently used for creating an HTML page. Save data as an HTML file.

First, determine the number of colors displayed in one line using the define command.

define {
   lcount = 12
}

Note that such constant quantities are called macros. The dollar sign '$' is used before the name in order to run them.
Let's tackle the last point first.

func color<main>
{
   str out

   out @ colorhtm()
   out.write( "color.htm" )
   shell( "color.htm" )
}

out @ colorhtm()

As you can see, the result of the colorhtm text function is output to the out string. Using the following commands, we save the obtained string to the file which is opened in the browser window. In our example, ellipses are substituted for the title and the end of the html file.

text  colorhtm
...
\{
   int vrgb i j k
   uint cur

   subfunc outitem
   {
      str  rgb

      int2str( rgb, "%06X", vrgb )
      @ item( rgb )
      if ++cur == $lcount
      {
         @"</TR><TR>"
         cur = 0
      }
   }
   for i = 0xFF, i >= 0, i -= 0x33
   {
      for j = 0xFF, j >= 0, j -= 0x33
      {
         for k = 0xFF, k >= 0, k -= 0x33
         {
            vrgb = ( i << 16 ) + ( j << 8 ) + k
            outitem()
         }
      }
   }
   for vrgb = 0xFFFFFF, vrgb >= 0, vrgb -= 0x111111 : outitem()
   for vrgb = 0xFF0000, vrgb > 0, vrgb -= 0x110000 : outitem()
   for vrgb = 0x00FF00, vrgb > 0, vrgb -= 0x001100 : outitem()
   for vrgb = 0x0000FF, vrgb > 0, vrgb -= 0x000011 : outitem()
}
...
\!

The \{...} command is used to insert the code into a text. outitem minorant function is defined like thisas:

int2str( rgb, "%06X", vrgb )
@ item( rgb )

Here, using the local variable named vrgb, the string is created that contains the hexadecimal representation, then another text function item is called for outputting the cell with the indicated color. The unary operator @ is used to output into the current string or, if there is no string to the console. Then, we determine the total number of cells in the row and add a new row to the table where approriate.

We use three embedded color cycles for searching possible values. Red, green or blue color components are affected by color cycling. Then these color components are arranged in the vrgb variable and we call the minorant function described above.

The next four color cycles display additional palette entries for gray, red, green and blue colors.
The \! command indicates the termination of a text function. By default, a text function works until the end of the file.

Let's take an example - a text function of cell entries.
We want a function that works like this:

text  item( str rgb )
<TD ALIGN=CENTER><TABLE BGCOLOR=#\(rgb) WIDTH=60><TR><TD>  </TD></TR></TABLE>
<FONT FACE="Courier">\(rgb)</FONT>
</TD>
\!

As you can see, this is an HTML text that outputs the rgb color parameter. It is used as the background color of a table cell and for the display of its value output under the table cell.

Exercise 2

Create a HTML file that contains the multiplication table.


Lesson 8

This lesson provides you with a little more practice with the text function.

Example 1

Create a month calendar, selected by a user, in HTML format.

We're betting that this example will make a lot more sense to you. So, how would we do this? Let's use the main function from the previous example and modify it; that is, a user enters the year required for creating a calendar.

 congetstr( "Enter a year: ", year )
out @ calendar( uint( year ))
out.write( "calendar.htm" )
shell( "calendar.htm" )

Now, we describe a variable of datetime type in the calendar text function and set January 1 of the specified year into this variable. Then we output the title of the HTML file and start creating the calendar.

text  calendar( uint year )
\{ datetime  stime
   stime.setdate( 1, 1, year ) }
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Calendar for year \(stime.year) </TITLE></HEAD>
<BODY BGCOLOR=#FFFFFF><CENTER>
<FONT SIZE=+3 FACE="Verdana"><B>\(stime.year)</B></FONT>
<TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0>

Notice that this calendar contains three columns and four rows. The first day of the week is stored with the help of the firstday variable for the customer. dayofweek returns the day number for the current date value. The nameofmonth function returns the name of the month in a user language.

\{firstday = firstdayofweek()
dayofweek = stime.dayofweek
fornum i = 0, 4
{
   @"<TR>"
   fornum j = 1, 4
   {
      month = i * 3 + j
      @"<TD WIDTH=33%><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=1 BGCOLOR=#000000 WIDTH=100%>
      <TR><TD BGCOLOR=#FFFFFF ALIGN=CENTER>
      <FONT FACE=\"Verdana\">\(nameofmonth( stemp,  month ))
      </FONT><PRE>"
      // Âûâîä íàçâàíèé äíåé íåäåëè
      ...
      // Âûâîä äíåé
      ...
   }
}
}

Now that we have defined it, we can use abbrnameofday function to obtain the abbreviated day name. It is essential to add missing space characters, because the calendar includes characters which have the identical width. So, let's use each day name with four characters.

fornum k = firstday, firstday + 7
{
   @"  \( abbrnameofday( stemp, k ).setlen( 2 ))"
}
@"  \l"
@"    ".repeat( ( 7 + dayofweek - firstday ) % 7 )

If dayofweek function has the value 0, any Sunday is highlighted using red color. Our attention is turned to line feeds added after the last day of the week. The number of strings output is stored in the lines variable in the following way:

uint day = 1
uint lines
while day <= daysinmonth( year, month )
{
   if !dayofweek : @"<FONT COLOR=#FF0000>"
   @str( day++ ).fillspacel( 4 )
   if !dayofweek : @"</FONT>"

   dayofweek = ( dayofweek + 1 ) % 7
   if dayofweek == firstday
   {
      @"  \l"
      lines++
   }
}

Finally, the space characters are inserted into the last string and the missing rows are output in order to create the months with the identical height.

@"    ".repeat( ( 7 + firstday - dayofweek ) % 7 )
while lines++ < 7 :  @"  \l"
@"</PRE></TD></TR></TABLE></TD>"

Frankly speaking, this task is difficult to comprehend because it provides a wealth of HTML texts and extra formatting. On the other hand, we finally succeed in writing this program.


Lesson 9

This lesson focuses on file processing. Let's find the duplicate files on your computer. Moreover, we try to make this task enjoyable and useful, i.e. we will find the duplicate files using their contents, but their names are not required. Well, I suppose you will be astonished by the results, when these operations have been completed.

Example 1

Find all files which have the same contents either in the required folder or in a drive.

Actually, task performance takes much time. Let's think of the algorithm that will make this task easy to perform. If the files differ in size, they are not duplicate. So, from this assumption, first we can get names and sizes of all compared files, which will be sorted by size, after that it will be possible to compare them by size.

Let's declare the structure for data storage with help of the type command. We will store only a file name instead of its whole path in order to save memory. The index of the parent directory in the directory array will be stored in the field owner instead of full name.

type  finf
{
   str   name
   uint  size
   uint  owner
}

We need the following global variables:

global
{
   arr dirs  of finf
   arr files of finf
   arr sizes of uint
   str output
}

dirs - processed directory array.
files - files array.
sizes - array that contains files indices will be sorted.
output - string for result output.
The functions written below are responsible for appending directories and files to the appropriate arrays.

func uint newdir( str name, uint owner )
func uint newfile( str name, uint size owner )

To find out more about these functions, read the source code. Functions append an element to the array and fill the element fields.

The scanfolder function is used to find all directories and files by the specified path. If the directory has been found, the element will be appended to the dirs array; then this element is considered to be parent and the scanfolder function calls itself. If the file has been found, the element will be appended to the files array. To make this task easier, we don't take files which have size more than 4GB, condition !cur.sizehiserves this purpose particularly.

func scanfolder( str wildcard, uint owner )
{     ...
      if cur.attrib & $FILE_ATTRIBUTE_DIRECTORY
      {
         scanfolder( cur.fullname + "\\*.*", newdir( cur.name, owner ))
      }
      elif !cur.sizehi : newfile( cur.name, cur.sizelo, owner )
      ...
}

The scaninit function prepares the first call scanfolder using the starting path. Modifying these functions, you can use various masks and specify size limits of the compared files for file searching.

func scaninit( str folder )
{
   str wildcard

   folder.fdelslash()
   @"Scanning \( folder )\n"
   scanfolder( (wildcard = folder ).faddname( "*.*" ), newdir( folder, 0 ))
}

After file scanning we will sort obtained data. So, instead of sorting the files array, we offer you the better way for process speed-up: to create a new array that contains indices of the files and sort it. Actually, while sorting elements get moved faster, thus elements of small size will be a better choice.

func int sortsize( uint left right )
{
   return int( files[ left->uint ].size ) - int( files[ right->uint ].size )
}

func sortfiles
{
   uint i

   @"Sorting...\n"
   sizes.expand( *files )
   fornum i, *sizes : sizes[ i ] = i

   sizes.sort( &sortsize )
}

The sortfiles function fills the sizes array with indices of the files. First, an index equals to the sequence number. Then, the sizes array will be sorted with help of the sortsize function. Such parameters as left and right are pointers to data. If elements of the array were structures, they would be used as objects; however, the element of the sizes array is uint, so we use the ->uint operation. This expression: files[ index ].size returns the size of a specified file. The function returns a positive number if the size of the left file is greater than the size of the right one, or a negative number if the size of the left file is less than the size of the right one, or zero if the sizes of both files are equal.

The getdir and getfile functions retrieve the full path of a file using the value of the owner field. getdir passes recursively through the first parent directory and makes up the full path as it comes back.

func str getdir( uint id, str ret )
func str getfile( uint id, str ret )

Let's jump to discussion of the main comparison function. In the loop we look through all sorted files, where the file of the least size is the first one.

func compare
{
   ...
   fornum i, *sizes - 1
   {
      id = sizes[ i ]

      if !*files[ id ].name : continue

The files that are considered to be duplicate are ignored in this example. Names of duplicate files will be nulled.

      found = 0
      next = sizes[ j = i + 1 ]

      while files[ id ].size == files[ next ].size
      {

In the given loop the current file is compared with the files of the same size that come next. Furthermore, we miss the obtained duplicate files. Comparison is made using the isequalfiles function from the standard library. In case of duplicate files, we output a message to the string output.

         if *files[ next ].name &&
            isequalfiles( getfile( id, idname ), getfile( next, nextname ))
         {
            if !found
            {
               output @ "\lSize: \(files[ id ].size) ========\l\( idname )\l"
            }
            count++
            ( output @ nextname ) @"\l"

            found = 1
            files[ next ].name.clear()
         }
         if ++j == *sizes : break
         next = sizes[ j ]
      }

This fragment outputs partial results. i & 0x3F defines the output of the result after each 64th file.

     if i && !( i & 0x3F )
      {
         @ "\rApproved files: \(i) Found the same files: \(count)"
      }
   }
   ...
}

Using these functions

func init
func search
func main<main>

is not a difficult task. There can be a great number of files and directories, so we reserve a place for some elements in the init function in advance. Moreover, we append one empty parent element to the dirs array in order to start directory numbering at 1. We consider that the owner field equals to zero either if the directory is root. In other words, the directory has no zero index.

Exercise 2

Write a program for searching duplicate files on all local hard drives.


Lesson 10

This lesson will be useful for those users who would like to know about key pressing emulation.

Example 1

Launch an editor, then paste a text from the clipboard, print a text in the editor, copy the whole text to the clipboard and close the editor without saving it to a file. The operations listed above will be performed automatically.

First, we specify the following three libraries that will be used in the example: threads, data input, clipboard operations. You may not use threads, however it is a good opportunity for you to get to know about them. A thread is a function operated at the same time as the main process. I consider that the term "thread" is defined in a simple way,nevertheless I tried to make it easy to understand.

include
{
   $"..\lib\input.ge"
   $"..\lib\thread.ge"
   $"..\lib\clipboard.ge"
}

Well, let's get started with the main function.

func lesson10<main>
{
   thread   mythread
   str      data

   mythread.create( &notepad, 700 )
   clipboard_settext( "Hello!\l" )

   process( "notepad.exe", 0->str, &ret )

   congetch("\(clipboard_gettext( data ))\n=============\nPress any key...")
}

We declare the variable of thread type and create the thread used for key pressing emulation. In the parameter the delay time between operations will be specified in milliseconds. If the delay time is not set, the program will be terminated rapidly and you cannot have a chance to observe operations thoroughly.

Then we copy the word Hello! to the clipboard, launch the editor Notepad and wait for the program to be terminated. If you want the process to be launched but don't want to wait for its termination, enter zero in the third parameter of the process function. When an editor window has been closed, we will receive the text from the clipboard and output it to a console.

Let's jump to the thread function notepad.

func uint notepad( uint param )
{
   ...

First, it is necessary to set a half a second delay time for Notepad launching. Within this lesson, all sleep functions will be skipped. Using the sendvkey function, the shortcut keys Shift-Insert paste a text from the clipboard.

   sleep( 500 )
   sendvkey( $VK_INSERT, $SVK_SHIFT )

When the date and time are obtained, they will be set in the editor with help of the sendstr function.

   sleep( param )
   dt.gettime()
   getdatetime( dt, date, time )
   sendstr( "Date: \(date)\lTime: \(time)" )

We highlight the whole text with the shortcut keys Ctrl-A and press Ctrl-Insert for copying it to the clipboard.

   sleep( 3 * param )
   sendvkey( 'A', $SVK_CONTROL )
   sendvkey( $VK_INSERT, $SVK_CONTROL )

The last thing we should do is to close the program by pressing Alt-F4 without saving data to the file. The shortcut keys Alt-F4 are usually used to close a window, therefore while the program executes, do not switch to any other windows, otherwise the current window will be closed.

   sleep( param )
   sendvkey( $VK_F4, $SVK_ALT )
   sleep( param )
   sendvkey( $VK_RIGHT, 0 )
   sleep( param )
   sendvkey( $VK_RETURN, 0 )
   return 1
}

You have already noticed that this program is rather compact, however it performs the task completely. If you would like to deal with any automatization, you could always have an opportunity to modify this example. Therefore, there is no need for you to do some extra exercises.


Lesson 11

Exercise 1

Calculate the frequency of a word in a file specified by a user. In order to make the task easy, let us assume that a word consisits of letters of English alphabet only and its length does not exceed more than 32 symbols.

To begin with, write down the file2words function, which will read the file, search out words and increment the entry counter in the associative array. The associative array (hash table) will be used for storing and searching words that have been already found. The hash table will be passed to the function by means of this parameter in order to be reused and to process the results.

func uint file2words( str filename, hash words )
{
   ...
   data.read( filename )
   print( "Read \( filename )...
Size = \( *data )
Processing...\n" )

We check file data symbol by symbol and define the word length. First, we store the current position in the len and calculate the length of the word.

   while i < *data
   {
      len = i

      while ( data[i] >= 'A' && data[i] <= 'Z' ) ||
         ( data[i] >= 'a' && data[i] <= 'z' )
      {
         i++
      }
      len = i - len

If a word length is less than 32 symbols, but more than zero, we assign this word to the stemp variable. Then we increment the counter value of the obtained word in the hash array. If this word has not been included in the result list, it will be added automatically. Furthermore, we increment the counter of total amount of processed words.

      if len && len < 32
      {
         stemp.copy( data.ptr() + i - len, len )
         words[ stemp ]++
         count++
      }
      i++
   }
   return count

Let us use the results function for data processing and data outputting. We insert all obtained words from the hash array into the string array awords that will be sorted out then.

func results( hash words, uint count )
{
   ...
   foreach cur, words.keys
   {
      awords += cur
   }
   awords.sortstr()

We output the words and their entry frequency into the temporary string. We store the string into the words.txt file and open it in order to be browsed.

   foreach acur, awords
   {
      result += "\(acur): \( words[\(acur)])\l"
   }
   result += "==================================
Total words: \( count )
Different words: \( *awords )\l"
   result.write("words.txt")
   shell("words.txt")

The name of the file being processed will be obtained from the command line with help of the main function or a user will be requested to input it. Then the file should be processed and the result - be outputted.

   uint count
   hash words
   str  filename

   if argc() : argv( filename, 1 )

   while !fileexist( filename )
   {
      if *filename : @"File \(filename) does not exist!\n"
      congetstr( "Specify the filename to calculate words: ", filename )
   }

   count = file2words( filename, words )
   results( words, count )

Exercise 2

Calculate the frequency of words found in all .g files in the current directory.


Lesson 12

Example 1

Write an elementary program that parses and calculates expressions.

We define the lexem type with two fields. An element type will be stored in the id field, a value (if an element is an number) - in the dval field. To find out the information about element types, go to the define command. Besides, we take the oper array with the allowable operations as well as the priority array with their precedence. The precedence of operators affects evaluation of arithmetic expressions, for example in order to calculate the result value in the expression: 1+2*3 multiplication should precede addition.Operations in arrays are arranged in the same order as their define definitions. Null element indicates an error. Moreover, we create the assignment operator of two variables of the lexem type.

operator lexem =( lexem left right )

The getlexem function will retrieve an element of the expression from the string. Let's define whether or not an element is an operation. We start with the first symbol entered into the oper array.

ptr = expr.ptr()

fornum i = 1, *oper
{
   if oper[i] == ptr->byte
   {
      expr.del(0, 1)
      return lex.id = i
   }
}

Then we check if an element is a number or not. Now we skip through the number parsing. There are two additional checking operations there. In the first case if a number contains '.', it is supposed to be a decimal point. If the point occurs later, the number parsing will be interrupted with an error. This method is used to process numbers written in the form 1E-5, 2.45E+10, 34E5. The expression xE(+|-)y defines the number x * ( calculates 10 raised to the power of y ).

   if ptr->byte >= '0' && ptr->byte <= '9'
   {
      str  stemp

      ptr++
      while  ptr->byte >= '0' && ptr->byte <= '9' : ptr++

      if ptr->byte == '.'
      {
         ptr++
         while  ptr->byte >= '0' && ptr->byte <= '9' : ptr++
      }

      if ptr->byte == 'E' || ptr->byte == 'e'
         ...

We specify a numeric data type of a number and assign a value to it.

result = $NUM_DOUBLE
stemp.copy( expr.ptr(), ptr - expr.ptr() )
lex.dval = str2double( stemp )

The ptr variable is served as a pointer to the current character. After the element of the expression is obtained, it will be deleted from the beginning of the string. Thus, the parsing of the next element starts at the beginning of the string.

expr.del( 0, ptr - expr.ptr())

The calculate function performs parsing and calculation of an expression. It contains the calc subfunction. Instead of passing any arguments, the subfunction is used to work with the local variables defined in the calculate function. The calc subfunction deals with the number stack vals as well as with the operation stack opers. An operation is popped from the stack and applied to two values or one value (for unary minus) from the number stack. It works like this:

curoper = opers.top()->lexem
if lex.id == $OPER_RPARENTH && curoper.id == $OPER_LPARENTH
{
   opers.pop()
   break
}
elif priority[ curoper.id ] < priority[ lex.id ] : break

The next operation of the expression is stored in the lex variable. The top operation of the stack is put down in curoper. If the right parenthesis follows, we must first perform operations before the left parenthesis. If the top operation has a lower priority than the priority of the next one, we will stop calculations. For example, while performing multiplication '*' in the expression 1 + 2 * 3, the stack contains 1 2 values; as for addition +, numbers 1 and 2 can not be added, because of the higher priority of multiplication.

Now we proceed to the main part of calculations. The parsing process is carried out until the expr string is empty. We get the element with help of getlexem and stop calculations if error occurs. We push the number in the stack of values. prevlex contains the previous element, we check the sequence of two operations or values that follow one after another.

   while *expr.trimspace()
   {
      getlexem( expr, lex )

      if lex.id == $LEX_ERR : return $LEX_ERR
      elif lex.id == $NUM_DOUBLE
      {
         if prevlex == $NUM_DOUBLE || prevlex == $OPER_RPARENTH : return $LEX_ERR
         vals.push()->lexem = lex
      }

If the right parenthesis follows, we will call the calc subfunction used for calculating the expression followed by the left parenthesis and will reduce the parenth value where a number of left parentheses has been stored. We can perform the stack operations, if a new operation has a lower priority than the previous operation does; furthermore, if there is neither unary minus nor the left parenthesis. After that, we push the operation into the opers stack.

         if lex.id == $OPER_RPARENTH
         {
            if !parenth || !calc() : return $LEX_ERR
            parenth--
         }
         else
         {
            uint top

            top as opers.top()->lexem
            if ( top && priority[ lex.id ] <= priority[ top.id ] &&
                  lex.id != $OPER_UMINUS && lex.id !=  $OPER_LPARENTH )
            {
               if !calc() : return $LEX_ERR
            }
            opers.push()->lexem = lex
         }

Finally, we work out the operations left in the stack, the top value in vals will be a result.

   calc()
   if vals.top() : lex = vals.top()->lexem

   return lex.id

So, we request a user to input an expression into the main function and call the calculate function for the calculation. If a user presses Enter, we will exit the program.

   while 1
   {
      congetstr( "Enter a mathematical expression: ", expr )
      if !*expr : break

      if !calculate( expr, result ) : @"There is an error in the expression\n"
      else : @"Result = \( result.dval )\n"
   }


Lesson 13

This lesson focuses on the internet. In addition, you will get to know how to find a substring in a string.

Example 1

Find out the position of a domain and obtain the total number of search results using Google. The program provides an opportunity to use several search queries and domain names. The domain names are viewed on the first five search pages.

We use the global array words in order to store the queries and the domains array - for the required domains. You can use any selection of words within the domain name. Do a search of the domains by entering these words.

arr  words of str = %{
   "q=free programming language",
   "q=gentee+programming+language"
}
arr  domains of str = %{
   "programming",
   "gentee.com",
   "php.net"
}

Let us have a look at the getresults function. This function searches through the string, that contains the source of the search result page, for the total number of results. First, we review the search page in order to define location of the substring where the total number of results is listed. Then we assign the required substring to the pattern variable. We need to get the result followed by the substring.

uint     offset end
spattern sp
str      pattern = "of about <b>"

out.clear()
sp.init( pattern, $QS_IGNCASE )
offset = sp.search( input, 0 )
offset += *pattern
if offset < *input
{
   if ( end = input.findchfrom( '<', offset )) < *input
   {
      out.substr( input, offset, end - offset )
   }
}

The variable of spattern type is used for search purposes. At first, we initialize the search pattern with the help of the init method; second, applying the search method we do a search.

The displayed function, that is analogous to the previous function, is applied for searching the specified substring-domains in result pages. Let us the pattern pattern be served for the next search result and the dp pattern be used to find out the substring in the URL address.

spattern sp dp
str      pattern = "<p class=g><a class=l href=\""

sp.init( pattern, $QS_IGNCASE )
dp.init( domains[id], $QS_IGNCASE )
url.clear()

while ( offset = sp.search( input, offset )) < *input
{
   ret++
   offset += *pattern
   if ( end = input.findchfrom( '"', offset )) < *input
   {
      str stemp
      stemp.substr( input, offset, end - offset )
      if dp.search( stemp, 0 ) < *stemp
      {
         url = stemp
         return page * 10 + ret
      }
   }
}

id is an index of a domain name which is contained in the domains array. The URL address, that contains the required domain name, is specified in the urlargument. This function returns the position of the domain name in search results.

Let us have a look at the main function googlesearch. To begin with, use the inet_init function in order to initialize the internet library, then create a loop that searches through the words array for a query. You obtain the search result page with the help of the http_get function in the resultstring. getresults provides us with the total number of found records.

inet_init()

fornum iword, *words
{
   str  result stemp
   print("\nSearching \(words[ iword ])\nPage 1.")
   if !http_get( "http://www.google.com/search?\(words[ iword ])",
                        result->buf, 0, $HTTPF_STR ) : break
   getresults( result, stemp )
   output += "   Search: \(words[ iword ])\lAll pages: \(stemp)\l"

Next step: we want to search through domains for the positions of the required domains on the first five search result pages. These positions will be stored in the pos array.

fornum id = 0, *domains : pos[ id ] = 0
page = 0
while 1
{
   fornum id = 0, *domains
   {
      if !pos[ id ]
      {
         pos[ id ] = displayed( result, id, page, urls[ id ] )
      }
   }
   if ++page == 5 : break
   print("Page \( page + 1 ).")
   if !http_get( "http://www.google.com/search?\(words[ iword ])&start=\(page * 10 )",
   result->buf, 0, $HTTPF_STR ) : break
}

The next Google search result is downloaded by calling the http_get function.Finally, we output the obtained data into the file. So, the program has been completed.

      output += "\lResults for 1-5 pages\l"
      fornum id = 0, *domains
      {
         output += "\( domains[ id ]): \(?( pos[ id ], str( pos[id] ) +
                  "  \(urls[id])",
                       "Not found"))\l"
      }
      output += "==========================================\l"
   }
   inet_close()
   output.write("search.txt")
   shell("search.txt")


 Introduction

This section describes examples illustrating the use of a GUI library. We will try to show you how windowed applications are created step by step.
The entire source code is available in the Tutoirial\GUI subdirectory of the Gentee installation folder. It is recommended to study the examples in the order they are given because many moments will be skipped if they are described in previous programs. Along with the source code, you can find the runme.g file in this directory. It is used to create and run the program of a certain version Day1, Day2, etc.. You will have to specify the number of the day to run it. Once compiled, the created exe file will be automatically launched. Thus, you can run different versions one by one and follow changes made in them step by step. The runme.g program is configured to create exe files that do not require gentee.dll. If you want to reduce the size of applications and use gentee.dll, specify the -d parameter when you run ge2exe.
Besides, you may need a resource editor and a resource compiler. As a rule, they come together with almost all common programming languages. As alternative free software, we can recommend:
Resource editor ResEd
Resource compiler GoRC

Calculator

A calculator application that can calculate mathematical expressions.

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Calculator

Let us create a program that will calculate mathematical expressions of the following type: 2.34 * 5 / ( 56 + 7 ). It will work with both real and whole numbers. Besides, let us make it work with additional variables. For example, in case with 3.1415 * a * a, we will have to change only the value of a to calculate the area of the circle with the corresponding radius. Another useful feature of the calculator will be displaying the result in the decimal and hexadecimal forms simultaneously.

Day 1 | Creating and linking dialog resources
Day 2 | Calculating an expression and displaying the result
Day 3 | Linking variable
Day 4 | Saving data. The calculator is ready.
Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Day 1

Let us start writing our application from creating an icon for it calculator.ico. You can use any icon editor for that. Then we need to create a resource file with dialog boxes and the icon. With ResEd mentioned in the Introduction, we will created the resource file calculator.rc. It will contain the main dialog box, the "About" dialog box and the icon. We will make our calculator keyboard-oriented without numeric and functional buttons in the main dialog box. We will have the field for entering expressions at the top, the fields for variable values to the left and two fields to display results in the decimal and hexadecimal forms to the right.
Use any resource compiler, for example GoRC, to create the file calculator.res out of calculator.rc. It is this file that we will use further on.
And now we will create the file calculator.gt with necessary descriptions.
Let us describe the text resources of our program.

<english language default type = keys>

   aboutver = Calculator v1.0 Freeware

   caption = Calculator

   ...

The description of linked resources (an icon and two dialog boxes) follows this.

<appres resource >

   <icon = 3000 icon>

   <about = IDD_ABOUT dialog cmdproc = aboutproc >

   <main = IDD_MAIN dialog cmdproc = mainproc >

</appres>

Besides, we need to specify the font for the name of the program in the "About" dialog box.

<fonts fonts>

   <head name = "Arial" size = 10 bold></head>

</fonts>

And we will also describe the items of the dialog boxes that are not standard control elements.

<dlgitem>

   <url class = GWurl text = url></>

   <email class = GWurl text = email  shell = emailshell ></email>

   <about class = static font = fonts/head></about>

</dlgitem>

Now we can get down directly to writing the program calculator.gt. We include calculator.gt into our program and specify the values of some items present in the dialog boxes.

global {

   str  gtstr = "\<calculator.gt>"

}

define

{

   IDC_ABOUTHEAD = 1003

   IDC_ABOUT     = 1005

   IDC_EXPR      = 1006

}

Let us take the event handler of the "About" dialog box.

func uint aboutproc( uint wnd id ctl codedlg )

{

   switch id

   {

      case 0

      {

         langsetwin( wnd )

         SetFocus( GetDlgItem( wnd, $IDOK ))

         dlgsubst( wnd )

         setdlgtext( wnd, $IDC_ABOUTHEAD, "aboutver".getlang())

      }

      case $IDOK,$IDCANCEL

      {

         EndDialog( wnd, 1 )

         return 1

      }

   }

   return 0

}

If id equals zero, the dialog box is initiated. We use langsetwin to specify text resources and dlgsubst to change the items described in calculator.gt as dlgitem/.... We define a similar handling function for the main dialog box. We also add handling a click on the "About" button

case $IDC_ABOUT : showdialog( "appres/about" )

We finish our source code with the main function. gtapp is a global variable of the gt type that should contain all necessary data.
After you launch this example, you will see a dialog box where only the "About" and "Exit" buttons function. A click on the "About" button will open the "About" dialog box.

See also

Calculator

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Day 2

As a warm-up, let us specify the icon for the main dialog box. We add it during the initialization

setwinicon( wnd, "appres/icon" )

Now we need to link the expression calculation module expression.g. We will not dwell on its content. A simpler variant is taken in detail in example 12. We will need only the calculate function calculating the expression passed to it. Let us define the calcexpr subfunction in the main handler. This subfucntion will take the expression from the IDC_EXPR field for entering expressions and calculate it. The result will be written to the IDC_DRES field in the decimal form and to the IDC_HRES field in the hexadecimal form.

subfunc calcexpr

{

   lexem result

   str   expr stemp

   uint  dres hres

   dres = GetDlgItem( wnd, $IDC_DRES )

   hres = GetDlgItem( wnd, $IDC_HRES )

   getwintext(GetDlgItem( wnd, $IDC_EXPR ), expr)

   setwintext( dres, "" )

   setwintext( hres, "")

   switch ( calculate( expr, result ))

   {

      case $NUM_LONG

      {

         setwintext( dres, str( result.lval ))

         long2str( stemp, "%I64X", result.lval )

         setwintext( hres, stemp )

      }

      case $NUM_DOUBLE : setwintext( dres, "\( result.dval )")

   }

}

All we have to do is call this function each time the expression is changed. If the expression is not correct, the result fields will remain empty. We add calling calcexpr to the main event handler.

case $IDC_EXPR

{

   if codedlg == $CBN_EDITCHANGE : calcexpr()

}

We have the program that already allows us to enter mathematical expressions and get results.

See also

Calculator

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Day 3

Today we have to find a way to save and load data and also link the variables A,B,...G to calculate expressions.
We add expressions and variables that will be loaded by default to calculator.gt. We will store the values of variables together with each expression. Once we select an expression, all variables will be changed.

<|data>

   <_ = "" A = 0 B = 0 C = 0 D = 0. E = 0. F = 0. G = 0.>

   <_ = "a*b" A = 10 B = 20 C = 0 D = 0. E = 0. F = 0. G = 0.>

   <_ = "2*a*b" A = 3.1415 B = 20. C = 0 D = 0. E = 0. F = 0. G = 0.>

</data>

The first expression calculates the area of a rectangle and the second one calculates the circumference of a circle with the radius of B.
Let us add the identifiers of the main window and the expression list, as well as the string array for storing states, to global variables. We will use 8 strings for each expression (the expression string and 7 strings for variables).

uint dlg exprwnd

arr  data of str

Let us start from the varset function. It takes strings from the fields for entering variables and converts then into the values of variables. register is a global array from expression.g where variables are stored. We also use the global variable dlg - it is the identifier of the main window. We will use the point or its absence to tell the type of a variable. If there is no point, the variable is a whole number.

func varset( uint num )

{

   str stemp

   getwintext( GetDlgItem( dlg, $IDC_VA + num ), stemp )

   if stemp.findch( '.', 0 ) < *stemp

   {

      register[ num ].id = $NUM_DOUBLE

      register[ num ].dval = str2double( stemp )

   }

   else

   {

      register[ num ].id = $NUM_LONG

      register[ num ].lval = str2long( stemp )

   }

}

Below you see the loadcur function that loads the expression selected from the drop-down list and its variables.

uint i

uint cur = combo_getcurrent( exprwnd ) << 3

setwintext( exprwnd, data[ cur ] )

fornum i = 0, 7

{

   setwintext( GetDlgItem( dlg, $IDC_VA + i ), data[ cur + i + 1 ] )

   varset( i )

}

There is one more function to be loaded - varload. It will be called each time the program is started and it will be responsible for the primary initialization of the drop-down expression list and variables.

gtitems gtis

str     stemp

uint    i

fornum i, *data >> 3

{

   combo_add( exprwnd, data[ i << 3 ] )

}

combo_setcur( exprwnd, 0 )

loadcur()

Let us define the gt2arr function that will fill the data array of strings with GT data. We will call this function at the very beginning of the program.

gtitems gtis

str     stemp

uint    i count

foreach cur, gtapp.find("data").items( gtis )

{

   count = *data

   data.expand( 8 )

   cur.get( data[ count ] )

   fornum i = 0, 7

   {

      cur.getattrib( "".appendch( 'A' + i ), data[ count + i + 1 ])

   }

}

There are some minor changes in the main handler left to be made. Let us add loading data during the initialization.

dlg = wnd

exprwnd = GetDlgItem( dlg, $IDC_EXPR )

varload()

Let us add changing the expression and variables when some other item is selected from the drop-down list.

case $IDC_EXPR

{

   if codedlg == $CBN_EDITCHANGE : calcexpr()

   if codedlg == $CBN_SELCHANGE

   {

      loadcur()

      calcexpr()

   }

}

And finally we will recalculate the expression each time variables in the edit field are modified.

if id >= $IDC_VA && id < $IDC_VA + 7 && codedlg == $EN_CHANGE

{

   varset( id - $IDC_VA )

   calcexpr()

}

See also

Calculator

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Day 4

In this part we will finish creating the calculator. Let us modify the dialog box a bit first. We need to add the 'Save' button to save the current state and the 'Help' button. Let us take the appendexpr function. It adds the current state to the data array. On exit, we will also save the current state and variables, but they will be written at the very beginning as zero state. The last parameter will point to the type of saving.

func appendexpr( uint last )

{

   uint cur i

   if last

   {

      cur = *data

      data.expand( 8 )

   }

   getwintext( exprwnd, data[ cur ] )

   fornum i, 7

   {

      getwintext( GetDlgItem( dlg, $IDC_VA + i ), data[ cur + i + 1 ] )

   }

   combo_add( exprwnd, data[ cur ] )

}

We will also need the function to convert data to the GT text format and save data to a file.

func saveexpr

{

   uint i k

   str  filename stemp = "<|data>\l"

   for  i, i < *data, i += 8

   {

      stemp += "<_ = \"\( data[i] )\""

      fornum k = 0, 7

      {

         stemp += " \("".appendch( 'A' + k ))=\( data[ i + k + 1 ])"

      }

      stemp += ">\l"

   }

   stemp += "</data>"

   stemp.write( getmodulepath( filename, "calculator.dat"))

}

We add calling the corresponding functions when the 'Save' and 'Help' buttons are clicked to the main handler.

case $IDC_SAVE : appendexpr( 1 )

case $IDC_HELP : helpcontents()

case $IDCANCEL

{

   appendexpr( 0 )

   saveexpr()

   EndDialog( wnd, 1 )

   return 1

}

All there is left to do is read calculator.dat and define the name of the CHM file at the beginning of the rpogram.

gtapp += data.read( getmodulepath( stemp, "calculator.dat"))

helpfile( "calculator.chm" )

See also

Calculator

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


Introduction

Functions that you can use while writing programs in Gentee are described in this section.

Built-in functions

These functions are implemented in the module gentee.dll and are an integral part of the virtual machine.

Standard library

These functions are included in the standard library. By default, it is added in the process of compiling Gentee programs. You can use these functions without any additional description.

Libraries

Additionally linked libraries are described in this section. They are linked with the help of the command include with the corresponding .ge file specified. After that you can use the functions of the linked library. All libraries are stored in the Lib subfolder of the Gentee installation folder.

include
{
   $"..\Lib\registry.ge"
   $"..\Lib\ini.ge"
}


Mathematical functions

abs | Absolute value for integers
acos | Arc cosine
asin | Arc sine
atan | Arc tangent
ceil | Smallest double integer not less than given
cos | Cosine
exp | Exponential function
fabs | Absolute value
floor | Largest double integer not greater than given
ln | Natural logarithm
log | Common logarithm
modf | Splitting into whole and fractional parts
pow | Raising to power
sin | Sine
sqrt | Square root
tan | Tangent


Working with memory

alloc | Memory allocation
free | Memory deallocation
mcmp | Comparison
mcopy | Copying
mlen | Size till zero
mmove | Memory move
mzero | Filling with zeros


Working with strings

The following built-in functions are used to work with strings

double2str | Converting from double
float2str | Converting from float
int2str | Converting from int or uint
long2str | Converting from long or ulong
str2double | Converting into double
str2int | Converting into int
str2long | Converting into long


Other functions

argc | Get the number of parameters
argv | Get a parameter
call | Calling a function by its address
callback | Creating callback function
fastsort | Sorting strings and numbers
getch | Waiting for a keystroke
getid | Getting the code of an object by its name
gettext | Get the string of a text function
sizeof | Type size
sort | Sorting
type_delete | Delete an object
type_hasdel | Whether an object should be deleted
type_hasinit | Whether an object should be initialized
type_init | Initialize an object


Buffer - binary data

It is possible to use variables of the buf type for working with memory. This type can be defined in the language as binary data.

  • Operations
  • Methods

    Operations

    Operations defined for the variable of buf type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    Variable description buf name[i] - allocate a memory block of i bytes during initialization and initiate it with zeros.
    [] buf[i] byte Getting byte i from the buffer.
    * * buf uint Get the size of the memory being used.
    = buf = buf buf Copying data from one buffer into another.
    += buf += buf
    buf += byte
    buf += sbyte
    buf += short
    buf += ushort
    buf += int
    buf += uint
    buf += str
    buf += ulong
    buf += long         		buf Adding data to the buffer.
    + buf + buf buf Putting two buffers together and creating a resulting buffer.
    == buf == buf uint Comparison operations.
    != buf != buf uint -
    < buf < buf uint -
    > buf > buf uint -
    <= buf <= buf uint -
    >= buf >= buf uint -

    Methods

    buf.alloc | Memory allocation
    buf.append | Data addition
    buf.clear | Clearing data
    buf.copy | Copying
    buf.crc | Calculating the checksum
    buf.del | Data deletion
    buf.expand | Expansion
    buf.free | Memory deallocation
    buf.getmultistr | Getting data from a string array
    buf.insert | Data insertion
    buf.read | Reading from a file
    buf.replace | Overwriting data
    buf.setmultistr | Writing data into a string array
    buf.write | Writing to a file
    buf.writeappend | Appending data to a file
    Initializing the search pattern | Creating data search pattern
    Data search | Searching through the buffer for the specified data


Strings

Variables of the str type allow you to work with strings.

  • Operations
  • Methods
  • Methods for working with file names
  • Functions

    Operations

    Operations defined for the variable of str type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    [] str[i] byte Getting byte i from the string.
    * * str uint Get the size of a string.
    = str = str str Copying data from one string to another.
    += str += str
    str += byte
    str += sbyte
    str += short
    str += ushort
    str += int
    str += uint
    str += float
    str += long
    str += ulong
    str += double         		str Adding data to the string.
    + str + str str Putting two strings together and creating a resulting string.
    == str == str uint Comparison operations.
    != str != str uint -
    < str < str uint -
    > str > str uint -
    <= str <= str uint -
    >= str >= str uint -
    %== str %== str uint Case-insensitive comparison operations.
    %!= str %!= str uint -
    %< str %< str uint -
    %> str %> str uint -
    %<= str %<= str uint -
    %>= str %>= str uint -
    @ str @ str
    str @ textfunc(...)         		str Adding another string or the result of a text function to a string.

    Methods

    str.append | Data addition
    str.appendch | Äîáàâèòü ñèìâîë
    str.char2oem | Converting from the Windows encoding into the DOS encoding
    str.clear | Clearing a string
    str.copy | Copying
    str.crc | Calculating the checksum
    str.del | Deleting a substring
    str.eqlen | Comparison
    str.fill | Filling a string
    str.fillspacel | Filling with spaces
    str.findch | Finding a character
    str.findchfrom | Finding a character with an offset
    str.findchnum | Finding character number i
    str.insert | Insertion
    str.islast | Checking the final character
    str.lines | Splitting into lines
    str.lower | Converting to lowercase
    str.lowersub | Converting a substring to lowercase
    str.oem2char | Converting from DOS into Windows
    str.print | Output
    str.ptr | Get the pointer to data
    str.quote | Enclosing by quotation marks
    str.read | Reading from a file
    str.repeat | Repeating a string
    str.replace | Replacing in a string
    str.replacech | Replace a character
    str.reserve | Reserving space
    str.search | Substring search
    str.setlen | Setting a size
    str.setlenptr | Determining the size
    str.split | Splitting a string
    str.substr | Getting a substring
    str.trim | Trimming a string
    str.trimrspace | Deleting spaces on the right
    str.trimspace | Deleting spaces on both sides
    str.trimsys | Deleting spaces and special characters on both sides
    str.upper | Converting to uppercase
    str.uppersub | Converting a substring to uppercase
    str.write | Writing to a file
    Initializing the search pattern | Creating data search pattern
    String search | Find a string in another string

    Methods for working with file names

    str.faddname | Adding a name
    str.fappendslash | Adding a slash
    str.fdelslash | Deleting the final slash
    str.ffullname | Getting the full name
    str.fgetdir | Getting the directory owner's name
    str.fgetdrive | Getting the name of a disk
    str.fgetparts | Getting name components
    str.fnameext | Getting the name of a file
    str.fsetname | Modifying the name of the file
    str.fsetparts | Compounding or modifying the name
    str.fsetext | Modifying the extension
    str.fsplit | Getting the directory and name of a file
    str.fwildcard | Wildcard check

    Functions

    char2str | Converting the code of a character into a string
    hex2strl | Converting an integer in the hexadecimal form
    hex2stru | Converting an integer in the hexadecimal form
    print | Printing


Arrays

Variables of the arr type allow you to work with arrays.

  • Operations
  • Methods

    Operations

    Operations defined for the variable of arr type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    Variable description arr name[i]
    arr name[i,j,...]
    arr name[i,j,...] of type         		- Array description. If no item type is specified, uint is used.
    [] arr[i]
    arr[i,j,...]         		item type Get item i.
    * * arr uint Get the number of items.
    += arr of str += str
    arr of uint += uint         		arr Add a string to an array of strings.
    Add a number to a numeric array.
    foreach The option of using in the foreach operator.

    foreach cur, myarr
{
   ...
}

    Methods

    arr.clear | Clearing an array
    arr.cut | Reducing an array
    arr.del | Deleting items
    arr.expand | Adding items
    arr.insert | Inserts elements
    arr.move | Move an item
    arr.ptr | Pointer to data
    arr.reserve | Reserving position
    arr.sort | Sorting an array
    arr.sortstr | Sorting strings


Collections

Variables of the collection type are used to initialize arrays and structures; furthermore, you can apply them to pass a variable number of arguments of different types to functions.

  • Operations
  • Methods

    Operations

    Operations defined for the variable of collection type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    * * collection uint Gets the amount of elements in the collection.
    = collection = collection collection Collection copying.
    += collection += anytype collection Appends an element to the collection. An element of any type are required.

    Methods

    collection.append | Appends a collection
    collection.clear | Clear a collection
    collection.gettype | Gets an element type of a collection
    collection.ptr | Gets a pointer to a collection element
    collection.val | Gets a value of a collection element


Stack

Variables of the stack type allow you to work with a stack.

  • Operations
  • Methods

    Operations

    Operations defined for the variable of stack type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    Variable description stack name
    stack name of òèï         		- Stack description. If no item type is specified, uint is used.
    [] stack[i] item type Getting the item i.
    * * stack uint Get the number of items.

    Methods

    stack.clear | Clearing a stack
    stack.pop | Extracting an item
    stack.push | Adding an item
    stack.top | Getting the top item


Associative arrays - hash tables

Variables of the hash type allow you to work with associative arrays or hash tables. Each item in such an array corresponds to a unique key string. Items are addresses by specifying the corresponding key strings.

  • Operations
  • Methods

    Operations

    Operations defined for the variable of hash type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    Variable description hash name
    hash name of type         		- Hash array description. If no item type is specified, uint is used.
    [] hash["key string"] item type Getting an item by a key string. In case there is no item, it will be created automatically.
    * * hash uint Get the number of items.
    foreach Looking through all items with the help of the foreach operator.

    foreach cur, myhash
{
   ...
}

    foreach Looking through all keys with the help of the foreach operator.

    foreach cur, myhash.keys
{
   ...
}

    Methods

    hash.clear | Clearing a hash array
    hash.create | Creating an item with this key
    hash.del | Deleting an item
    hash.find | Finding an item
    hash.ignorecase | Ignoring the letter case of keys
    hash.sethashsize | Set the size of a value table


Function for working with time

  • Types
  • Operations
  • Methods
  • Functions for working with time of files
  • Functions

    Types

    An object of the datetime type is used to work with time. This type can contain information about date and time. The filetime type is used to work with time of files.
    type datetime {
    ushort | year
    ushort | month
    ushort | dayofweek
    ushort | day
    ushort | hour
    ushort | minute
    ushort | second
    ushort | msec
    }

    Fields

    year | Year.
    month | Month.
    dayofweek Weekday. Counted from 0.
    0 is Sunday, 1 is Monday...
    day | Day.
    hour | Hours.
    minute | Minutes.
    second | Seconds.
    msec | Milliseconds.

    Operations

    Operations defined for the variable of datetype type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    = datetime = datetime datetime Operations for setting time.
    += datetime += uint datetime Adding days to a date.
    -= datetime -= uint datetime Subtracting days from a date.
    - datetime - datetime datetime Difference between two dates as days and time. All values are positive numbers.
    -= datetime -= datetime datetime -
    == datetime == datetime uint Comparison operations.
    != datetime != datetime uint -
    < datetime < datetime uint -
    > datetime > datetime uint -
    <= datetime <= datetime uint -
    >= datetime >= datetime uint -
    = filetime = filetime filetime Operations for setting time for files.
    == filetime == filetime uint Operation for comparing time of files.
    != filetime != filetime uint -
    < filetime < filetime uint -
    > filetime > filetime uint -
    <= filetime <= filetime uint -
    >= filetime >= filetime uint -

    Methods

    datetime.dayofyear | Day in the year
    datetime.dayofweek | Weekday
    datetime.gettime | Getting the current date and time
    datetime.setdate | Specifying a date

    Functions for working with time of files

    datetimetoftime | Converting date from datetime into filetime
    ftimetodatetime | Converting date from filetime into datetime
    getfiledatetime | Getting date and time as strings

    Functions

    abbrnameofday | Weekday name
    days | Number of days between dates
    daysinmonth | The number of days in a month
    firstdayofweek | The first day in a week
    getdateformat | Converting date into a string
    getdatetime | Getting date and time as strings
    gettimeformat | Converting time into a string
    isleapyear | Leap year check
    nameofmonth | Month name


Function for working with the console

congetch | Displaying text and waiting for a keystroke
congetstr | Getting a string after text is displayed
conread | Getting a string from the user
conrequest | Displaying a multiple choice request on the console
conyesno | Displaying a question on the console


Function working with files

close | Close a file
copyfile | Copy a file
copyfiles | Copy files and directories
createdir | Create a directory
deletedir | Delete a directory
deletefile | Delete a file
delfiles | Delete files and directories
direxist | Checking if a directory exists
fileexist | Checking if a file exists
getcurdir | Getting the current directory
getdrives | Getting disk names
getdrivetype | Get the type of a disk
getfileattrib | Get file attributes
getfileinfo | Get information about file
getftime | Get the time of a file
getmodulename | Get the name of the running file
getmodulepath | Get the path to the running file
getsize | Get the size of a file
gettempdir | Get the temporary directory
isequalfiles | Check if files are equal
movefile | Rename, move a file or a directory
open | Open a file
read | Reading a file
setattribnormal | Setting the attribute $FILE_ATTRIBUTE_NORMAL
setcurdir | Setting the current directory
setfileattrib | Set file attributes
setftime | Set the time of a file
setpos | Set the current position
verifypath | Verifying and creating a path
write | Writing to a file
File search | Searching for files and directories and going through them


Other functions

destroy | Destroying an object
exit | Exit
getenv | Get an environment variable
localeuser | Identifier of user locale
max | Determining the largest of two numbers
min | Determining the smallest of two numbers
new | Creating an object
process | Starting a process
setenv | Set an environment variable
setidvm | Filling an idvm structure
shell | Opening a file in the associated application


Windows API functions

This table contains Windows API functions the standard library stdlib.ge imports from kernel32.dll, user32.dll and shell32.dll. The green color indicates the names of functions the non-Unicode version of which is imported. As a rule, the names of such function end with A in dll. For example, GetModuleFileName indicates that actually the function GetModuleFileNameA is imported, but you must call it GetModuleFileName.

CharLowerBuff
CharToOemBuff
CharUpperBuff
CloseHandle
CompareFileTime
CopyFile
CreateDirectory
CreateFile
CreateProcess
DeleteFile
ExitProcess
FileTimeToLocalFileTime		FileTimeToSystemTime
FindClose
FindFirstFile
FindNextFile
FreeLibrary
GetDriveType
GetCurrentDirectory
GetDateFormat
GetExitCodeProcess
GetFileAttributes
GetFileTime
GetFileSize
GetFullPathName		GetLocaleInfo
GetLocalTime
GetLastError
GetModuleHandle
GetModuleFileName
GetPrivateProfileString
GetProcAddress
GetTimeFormat
IsDBCSLeadByte
LoadLibrary
MessageBeep
MoveFile
MulDiv
MultiByteToWideChar
OemToCharBuff		ReadFile
RemoveDirectory
SetCurrentDirectory
SetFileAttributes
SetFilePointer
SetFileTime
ShellExecute
SystemTimeToFileTime
WaitForSingleObject
WideCharToMultiByte
WriteFile
WritePrivateProfileString


Internet

This library contains functions and methods for working with the Internet. For using this library, it is required to specify the file internet.ge (from Lib subfolder) with include command.

  • Methods
  • Data types
  • Functions

    Methods

    ftp.close | Terminates the FTP connection
    ftp.command | Sends a command
    ftp.createdir | Creates a new directory
    ftp.deldir | Deletes a directory
    ftp.delfile | Deletes a file
    ftp.getcurdir | Retrieves the current directory
    ftp.getfile | Retrieves a file
    ftp.getsize | Retrieves the file size
    ftp.gettime | Retrieves the file time
    ftp.lastresponse | The last response from the FTP server
    ftp.list | List of files
    ftp.open | Establishes an FTP connection
    ftp.putfile | Stores a file on the FTP server
    ftp.rename | Renames a file
    ftp.setattrib | Sets the attributes
    ftp.setcurdir | Sets the current directory
    socket.close | Closing a socket
    socket.connect | Opening a socket
    socket.isproxy | Connecting via a proxy or not
    socket.recv | Getting a response
    socket.send | Sending a request
    socket.urlconnect | Creating and connecting a socket to a URL
    str.iencoding | Recoding a string
    str.ihead | Getting a header
    str.ihttpinfo | Processing a header
    str.iurl | Parsing a URL address

    Data types

    ftp | Type applied for FTP
    httpinfo | HTPP header data
    socket | Structure for sockets
    inetnotify | Type for handling messages

    Functions

    http_get | Getting data via the HTTP protocol
    http_getfile | Downloading a file via the HTTP protocol
    http_head | Getting a header via the HTTP protocol
    http_post | Sending data via the HTTP protocol
    inet_close | Closing the library
    inet_error | Getting an error code
    inet_init | Library initialization
    inet_proxy | Using a proxy server
    inet_proxyenable | Enabling/disabling a proxy server
    inetnotify_func | Function for handling messages


Working with CSV data

Variables of the csv type allow you to work with data in the csv format.

string1_1,"string1_2",string1_3
string2_1,"string2_2",string2_3

For using this library, it is required to specify the file csv.ge (from Lib subfolder) with include command.

  • Operations
  • Methods

    Operations

    You should use the foreach operator to look through a csv object and get data from it.
    Operation Syntax Return type Comments
    foreach Looking through all items with the help of the foreach operator. An element in an object of the csv type is an array of strings arr of str. Each string is split into separate elements by the separator and these elements are written into the passed array.

    csv mycsv
uint i k
...
foreach item, csv
{
   print( "Item: \(++i)\n" )
   fornum k = 0, *item
   {
      print( "\(item[k])\n")
   }
}

    Methods

    csv.append | Adding a data string
    csv.clear | Clearing data
    csv.read | Reading data
    csv.settings | Setting parameters
    csv.write | Writing data


Working with DBF files

This library is used to work with dbf files. The formats dBase III and dBase IV are supported. To be able to work, you should describe a variable of the dbf type. For using this library, it is required to specify the file dbf.ge (from Lib subfolder) with include command.

  • Operations
  • Methods
  • Methods for working with fields

    Operations

    Operations defined for the variable of dbf type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    * * dbf uint Get the number of records in the database.
    foreach Looking through all records with the help of the foreach operator. The current record is different for each iteration.

    foreach cur,base
// cur - number of the current record
{
   ...
}

    Methods

    dbf.append | Adding a record
    dbf.bof | First record check
    dbf.bottom | Last record check
    dbf.close | Closing a database
    dbf.create | Creating a database
    dbf.del | Settings clearing the deletion mark
    dbf.empty | Creating an empty copy
    dbf.eof | Checking if a record is defined in the database
    dbf.geterror | Getting an error code
    dbf.go | Moving to a record
    dbf.isdel | Getting the record deletion mark
    dbf.open | Opening a database
    dbf.pack | Packing a database
    dbf.recno | Getting the number of the current record
    dbf.skip | Moving to another record
    dbf.top | Moving to the first record

    Methods for working with fields

    dbf.f_count | Number of fields
    dbf.f_date | Getting a date
    dbf.f_decimal | Getting the size of the fractional part in a numerical field
    dbf.f_double | Getting a numerical value
    dbf.f_find | Getting the number of a field by its name
    dbf.f_int | Getting the value in the form of a number
    dbf.f_logic | Getting a logical value
    dbf.f_memo | Get the value of a memo field
    dbf.f_name | Field name
    dbf.f_offset | Field offset
    dbf.f_ptr | Pointer to data
    dbf.f_str | Getting a value
    dbf.f_type | Field type
    dbf.f_width | Field size
    dbf.fw_date | Writing a date
    dbf.fw_double | Writing a numerical value
    dbf.fw_int | Writing a numerical value
    dbf.fw_logic | Writing a logical value
    dbf.fw_memo | Writing a value into a memo field
    dbf.fw_str | Writing a value


Working with INI files

This library allows you to work with ini files. Variables of the ini type allow you to work with them. For using this library, it is required to specify the file ini.ge (from Lib subfolder) with include command.

  • Methods
  • Functions

    Methods

    ini.delkey | Deleting an entry
    ini.delsection | Deleting a section
    ini.getnum | Getting the value in the form of a number
    ini.getvalue | Getting a value
    ini.keys | Get entries in a section
    ini.read | Reading from a file
    ini.sections | Getting the list of sections
    ini.setnum | Writing a value in the form of a number
    ini.setvalue | Writing a value
    ini.write | Saving a file

    Functions

    inigetval | Get the value of an entry
    inisetval | Writing the value of an entry


Working with the Registry

This library allows you to work with the Windows Registry. For using this library, it is required to specify the file registry.ge (from Lib subfolder) with include command.

  • Methods
  • Functions

    Methods

    buf.regget | Getting a value
    str.regget | Getting the value in the form of a string
    buf.regset | Writing a value
    str.regset | Writing a string

    Functions

    regdelkey | Deleting a registry key
    regdelvalue | Deleting the value of a key
    reggetmultistr | Getting a string sequence
    reggetnum | Getting a numerical value
    regkeys | Getting the list of keys
    regsetmultistr | Writing a string sequence
    regsetnum | Writing a number
    regvaltype | Getting the type of a registry value
    regvalues | Getting the list of values in a key
    regverify | Creating missing keys


Threads

This library allows you to create threads and work with them. The methods described above are applied to variables of the thread type. For using this library, it is required to specify the file thread.ge (from Lib subfolder) with include command.

  • Methods
  • Functions

    Methods

    thread.create | Creating a thread
    thread.getexitcode | Getting an exit code
    thread.isactive | Checking if a thread is active
    thread.resume | Resuming a thread
    thread.suspend | Stopping a thread
    thread.terminate | Terminating a thread
    thread.wait | Waiting till a thread is exited

    Functions

    exitthread | Exiting the current thread
    sleep | Pausing the current thread


Trees

Variables of the tree and treeitem (tree item) types allow you to work with "trees". For using this library, it is required to specify the file tree.ge (from Lib subfolder) with include command.

  • Operations
  • Methods
  • Methods for tree items

    Operations

    Operations defined for the variable of tree type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    Variable description tree name[i]
    tree name of type         		- Tree description. If no item type is specified, uint is used.
    * * tree
    * treeitem         		uint Get the number of items.
    foreach The option of using in the foreach operator. A description of an additional variable of the treeitems type is required. The foreach operator is used for variables of the treeitem type and goes through all child items of this object.

    treeitems tis
...
foreach treeitem cur, ti.items( tis )
{
   ...
}

    Methods

    tree.clear | Clearing a tree
    tree.del | Deleting an item
    tree.leaf | Adding a "leaf"
    tree.node | Adding a "node"
    tree.root | Root item

    Methods for tree items

    treeitem.changenode | Changing the parent of an item
    treeitem.child | Getting the first child
    treeitem.data | Getting
    treeitem.getnext | Getting the next item
    treeitem.getprev | Getting the previous item
    treeitem.getroot | Getting the root item
    treeitem.isleaf | Leaf
    treeitem.isnode | Node
    treeitem.isroot | Root
    treeitem.lastchild | Getting the last child
    treeitem.move | Moving an item
    treeitem.parent | Getting the parent


Clipboard

These functions are used to work with the Windows clipboard. For using this library, it is required to specify the file clipboard.ge (from Lib subfolder) with include command.

clipboard_gettext | Getting a string
clipboard_settext | Copying a string


Keyboard

These functions are used to emulate the work of the keyboard. For using this library, it is required to specify the file input.ge (from Lib subfolder) with include command.

sendstr | Typing a string
sendvkey | Pressing a key


XML file processing

This library is used for XML file processing and XML tree building. Neither a multibyte-character set nor a document type description <!DOCTYPE .....> are handled in the current version. For using this library, it is required to specify the file xml.ge (from Lib subfolder) with include command.
Variables of either the xml and the xmlitem type (an XML tree item) are used for processing XML documents.
An XML tree item can be of two types: a text item and a tag item. There are several types of tag items:

  • tag item that contains other items <tag ...>.....</tag>;
  • tag item that contains no other items <tag .../>;
  • tag item of processing instruction <?tag ...?>.
A tag item may contain attributes.

The sequence of operations for processing an XML document:
  • process a document (build an XML tree) with the help of the xml.procfile method or the xml.procstr method;
  • add entity definitions, using the xml.addentity method if necessary;
  • search for the required items in the XML tree using the following methods: xml.getroot, xmlitem.chtag, xmlitem.findtag, xmlitem.getnext, etc.;
  • use the foreach statement in order to process similar elements if necessary;
  • gain access to tag attributes with the help of the xmlitem.getattrib method and get a text using the xmlitem.gettext method.
  • Operations
  • Methods
  • Methods of XML tree items

    Operations

    Operations defined for the variable of xml type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    foreach The option of using in the foreach statement. Defining an optional variable of the xmltags type is required. The foreach statement is used for variables of the xmlitem type and goes through all child tag items of the current tag.

    xmltags xtags
...
foreach xmlitem cur, curtag.tags( xtags )
{
   ...
}

    Methods

    xml.addentity | Add an entity description
    xml.getroot | Get the root item of the XML document tree
    xml.procfile | Process an XML file
    xml.procstr | Process an XML string

    Methods of XML tree items

    xmlitem.chtag | Get a tag item with the help of a "path"
    xmlitem.findtag | Search for a tag item by the name
    xmlitem.getattrib | Get a tag attribute
    xmlitem.getchild | Get the child item
    xmlitem.getchildtag | Get the child tag item
    xmlitem.getchildtext | Get the child text item
    xmlitem.getnext | Get the next item
    xmlitem.getnexttag | Get the next tag item
    xmlitem.getnexttext | Get the next text item
    xmlitem.getparent | Get the parent item
    xmlitem.gettext | Get a text of the current item
    xmlitem.isemptytag | Determine if the item is a tag item that contains no child items
    xmlitem.ispitag | Determine if the item is a tag of processing instruction
    xmlitem.istag | Determine if the item is a tag item
    xmlitem.istext | Determine if the item is a text item


Data Access Using ODBC

This library is applied for running SQL queries on a database using ODBC. For using this library, it is required to specify the file odbc.ge (from Lib subfolder) with include command.
The queries with parameters are not supported by the current version.

The object of the odbc type provides connection to a database.
The objects of the odbcquery type are used to run SQL queries and move the cursor through a result set. This object has got the arr fields[] of odbcfield array that contains result set fields odbcfield; furthermore, the number of elements of the array equals the number of the fields.
The objects of the odbcfield type make it possible to get the required information of the field as well as the field's value (depending on the current position of the cursor in the result set).

The sequence of operations for working with the database:

  • create an ODBC connection to the database using the odbc.connect method;
  • create a new ODBC query using the odbc.newquery method. Note that several queries are likely to be created for one connection;
  • run a SQL query using the odbcquery.run method; the query may retrieve the result set (the SELECT command) or no data (the INSERT command, the UPDATE command etc.);
  • move the cursor through the result set using the following methods: odbcquery.first, odbcquery.next etc. if necessary. The access is gained to the fields through the fields array odbcquery.fields[i], where i - a field number begining from 0, or with the odbcquery.fieldbyname method;
  • use the odbcfield.getstr method, the odbcfield.getuintmethod etc. in order to get field values;
  • run the next SQL query after processing if necessary;
  • disconnect from the database using the ODBC method odbc.disconnect.
There are some peculiarities to keep in mind when working with ODBC drivers:
while running a SQL query with the help of multiple sequential statements of the "INSERT ..." type, only some of the query statements are being executed (there can be from 300 to 1000 statements used for the "SQL server" driver) and no error message is displayed. In this case, you had better divide such queries into several parts;
some types of drivers do not make it possible to calculate the total number of messages received by the SQL query.

  • Methods
  • SQL query methods.
  • Field methods

    Methods

    odbc.connect | Create a database connection
    odbc.disconnect | Disconnect from a database
    odbc.geterror | Get the last error message.
    odbc.newquery | Create a new ODBC query

    SQL query methods.

    odbcquery.active | Check whether a result set exists after the SQL query execution
    odbcquery.close | Close a result set
    odbcquery.fieldbyname | Find a field based on a specified field name
    odbcquery.first | Move the cursor to the first record in the result set
    odbcquery.geterror | Get the last error message
    odbcquery.getrecordcount | Get the total number of records in a result set
    odbcquery.last | Move the cursor to the last record in the result set
    odbcquery.moveby | Move the cursor to a position relative to its current position
    odbcquery.next | Move the cursor to the next record in the result set
    odbcquery.prior | Move the cursor to the prior record in the result set
    odbcquery.run | SQL query execution
    odbcquery.settimeout | Set query timeout

    Field methods

    odbcfield.getbuf | Get the field's value as a value of the buf type (the binary data)
    odbcfield.getdatetime | Get the field's value as a value of the datetime type
    odbcfield.getdouble | Get the field's value as a floating-point number of the ulong type
    odbcfield.getindex | Get the field index number
    odbcfield.getint | Get the field's value as an integer of the int type
    odbcfield.getlong | Get the field's value as an integer of the long type
    odbcfield.getname | Get the field's name
    odbcfield.getnumeric | Get the field's value as a fixed point number of the numeric type
    odbcfield.getstr | Get the field's value as a string of the str type
    odbcfield.gettype | Get a type of the field's value
    odbcfield.getuint | Get the field's value as an unsigned integer of the uint type
    odbcfield.getulong | Get the field's value as an unsigned integer of the ulong type
    odbcfield.isnull | Determine if the field contains the NULL value


Working with COM Object

The COM library is applied for working with the COM/OLE objects, the IDispatch interface and maintains late binding operations. For using this library, it is required to specify the file olecom.ge (from Lib subfolder) with include command.

This library also contains the support of the VARIANT type, used for data transmitting from/to COM objects.

Variables of the oleobj type are used for working with the COM objects; furthermore, each variable of this type has one appropriate COM object. A COM objects method is called with the help of the ~ late binding operation. There are two ways of binding a COM object with a variable , as follows:
1. The createobj method is used for creating a new COM object:

oleobj excapp
excapp.createobj( "Excel.Application", "" )

2. Binding a variable with the existing COM object (child) is returned by another COM object method call:

oleobj workbooks
workbooks = excapp~WorkBooks

The oleobj object can maintain the following kinds of late binding:

  • elementary method call excapp~Quit, with/without parameters;
  • set value excapp~Cells( 3, 2 ) = "Hello World!";
  • get value vis = uint( excapp~Visible );
  • call chain excapp~WorkBooks~Add, equals the following expressions

    oleobj workbooks
workbooks = excapp~WorkBooks
workbooks~Add

The method call can return only the VARIANT type, and the appropriate assignment operators and type cast operators are used to convert data to basic Gentee types. Parameters of the COM objects methods call as well as the assigned values are automatically converted to the appropriate VARIANT types. The following Gentee types can be used - uint, int, ulong, long, float, double, str, VARIANT.

Use the release method in order to release the COM object; otherwise, the COM object is released when the variable is deleted; also the object is released when the variable is bound with another COM object.
Have a look at the example of using the COM object

include { "olecom.ge"}
func ole_example

{
   oleobj excapp
   excapp.createobj( "Excel.Application", "" )
   excapp.flgs = $FOLEOBJ_INT
   excapp~Visible = 1
   excapp~WorkBooks~Add
   excapp~Cells( 3, 2 ) = "Hello World!"
}

The oleobj object has properties, as follows:

  • uint flgs are flags. Flags value can be set or obtained; the property can contain the $FOLEOBJ_INT flag, i.e. when transmitting data to the COM object the unsigned Gentee type of uint is automatically converted to the signed type of VARIANT( VT_I4 )
  • uint errfunc is an error handling function. A function address can be assigned to this property, so using the COM object this function will be called as long as an error occurs; furthermore, this function must have a parameter of the uint type, that contains an error code.
All child objects automatically inherit the flgs property as well as the errfunc property.

VARIANT is a universal type that is used for storing various data and it enables different programs to exchange data properly. This type represents a structure consisted of two main fields: the first field is a type of the stored value, the second field is the stored value or the pointer to a storage area. The VARIANT type is defined as follows:

type VARIANT {
   ushort vt
   ushort wReserved1
   ushort wReserved2
   ushort wReserved3
   ulong  val
}

vt is a type code of the contained value ( type constants VT_*: $VT_UI4, $VT_I4, $VT_BSTR ... );
val is a field used for storing values
The library provides only some of the operations of the VARIANT type, however, you can use the fields of the given structure
The example illustrates creation of the VARIANT( VT_BOOL ) variable:

VARIANT bool
....
bool.clear()
bool.vt = $VT_BOOL
(&bool.val)->uint = 0xffff// 0xffff - VARIANT_TRUE

 There are all possible operations with the VARIANT variable below
Type of the left-hand operand | Operator | Type of the right-hand operand | Result type
VARIANT | = | ulong | VARIANT( VT_UI8 )
VARINAT | = | long | VARIANT( VT_I8 )
VARIANT | = | uint | VARIANT( VT_UI4 )
VARIANT | = | int | VARIANT( VT_I4 )
VARIANT | = | float | VARIANT( VT_R4 )
VARIANT | = | double | VARIANT( VT_R8 )
VARIANT | = | str | VARIANT( VT_BSTR )
VARIANT | = | VARIANT | is equal to the type of the right-hand operand
str | = | VARIANT( VT_BSTR ) | str
oleobj | = | VARIANT( VT_DISPATCH ) | oleobj

There are possible functions used for conversion:
Function name | Possible converting types of VARIANT
ulong | VT_UI8
long | VT_I8
uint | VT_UI4, VT_UI2, VT_UI1, VT_I4, VT_I2, VT_I1, VT_BOOL
int | VT_UI4, VT_UI2, VT_UI1, VT_I4, VT_I2, VT_I1, VT_BOOL
float | VT_R4
double | VT_R8
str | VT_BSTR

This example shows VARIANT operations

uint val
str  res
oleobj ActWorkSheet
VARIANT vval

....
vval = int( 100 )        //VARIANT( VT_I4 ) is being created
excapp~Cells(1,1) = vval //equals excapp~Cells(1,1) = 100

vval = "Test string"     //VARIANT( VT_BSTR ) is being created
excapp~Cells(2,1) = vval //equals excapp~Cells(1,1) = "Test string"

val = uint( excapp~Cells(1,1)~Value ) //VARIANT( VT_I4 ) is converted to uint
res = excapp~Cells(2,1)~Value         //VARIANT( VT_BSTR ) is converted to str
ActWorkSheet = excapp~ActiveWorkSheet //VARIANT( VT_DISPATCH ) is converted to oleobj

  • Methods
  • VARIANT Methods

    Methods

    oleobj.createobj | Creating COM object
    oleobj.getres | Result of the last operation
    oleobj.iserr | Enables to define whether or not an error occurs while working with a COM object
    oleobj.release | Releasing the COM object

    VARIANT Methods

    variant.arrcreate | Creating the SafeArray array
    variant.arrfromg | Assigning a value to an element of the SafeArray array
    variant.arrgetptr | Obtaining a pointer to an element of the SafeArray array
    variant.clear | Clearing a variable
    variant.isnull | Enables to define whether or not a variable is NULL


 Introduction

Documentation on the GUI library is being currently developed! The source code of the GUI library is located in the Sources\GUI subdirectory.

Like other programming languages, the Gentee programming language allows you to work with windowed Windows API functions. You can import all necessary functions from the corresponding DLLs (gdi32.dll, shell32.dll, etc.) and call them from programs written in the Gentee language. The purpose of this library is to make it easier to develop windowed application for Windows.
The technology implemented in the library is based on the description of windows and data with the help of the GT language.
It would be better to start studying the library from the Tutorial section where we have tried to dwell on creating windowed applications.

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Functions

Common functions and variables for working with the library.

  • Main functions
  • Variables

    Main functions

    gui_init | Initialization
    gui_deinit | Finishing work

    Variables

    appwin | Main window identifier.
    gtapp | The variable of the gt type with the description of the application resources.

    Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Window Functions

Common functions for working with windows.

createwin | Create a window
getwinfont | Get window font
getwinrect | Get the coordinates and size of the window
getwinfullrect | Get the coordinates and size of the window
getwintext | Get window text
setwinicon | Set an icon
setwintext | Set window text
winenum | Window enumeration
winexdata | Get an additional structure
winloop | Message loop
winregister | Registering window class
winsubclass | Set an additional event handler
Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Dialog boxes.

Here you can find all function for working with dialog boxes.

dlgbox | Create a dialog box
dlgdisable | Make the dialog item unavailable
dlgenable | Set the availability of the dialog item
getdlgtext | Get the text of a dialog item
setdlgtext | Set the text of a dialog item
showdialog | Load a dialog box from a resource
Copyright © 2004-2005 Gentee, Inc. All rights reserved.


Introduction

GT (Gentee Text) is a language for describing various data and it is used to store and process information in its text form.

What benefits do you get by using GT?

If you describe your text with the help of GT, you can export it into various formats (HTML, XML, RTF, etc.) without modifying the main text. You will only have to modify the corresponding functions in Gentee. On the other hand, to localize a document for another language, it is enough just to translate GT text without modifying the converting Gentee functions.
This site and documentation in the CHM format are generated from one source in the GT language.

Let us point out some characteristic features:

Simplicity

The structures of the language are very simple, which makes it easier to learn it and work with it.

Macros

The GT language has convenient means for defining and inserting macros. Each object has a name considered a macro. Macros allow you to avoid the unnecessary duplication of text and make it easier to input and correct data.

Integration with the Gentee programming language

Gentee provides you with a library for working with GT data including the automatic detection and building the hierarchy of objects. At the same time, the GT language allows you to call Gentee functions. Thus, you can call Gentee functions for formatting, converting or exporting data in the necessary format. The GT language itself does not allow you to work with data.

Hierarchic structure

All data is presented in the form of a tree where each object may contain other objects. There are built-in means for describing lists, associated arrays (arrays with keys) and trees (hierarchic structures).


Description of the GT language

Language objects are described in the following way:

<name [attributes]>
[Child objects]
[Object text]
</name>

The name of an object must start from a letter character and may include digits and '_'. All names in GT are case-insensitive. name and NAME represent the same name.
Attributes are additional fields for this object. They can contain a value enclosed by single or double quotes.

<name1 attr1 attr2 = no
   attr3 = "Last Name">
</name1>

The text of an object starts from the first character other than a space and not equal to '<'. It may also be enclosed by single or double quotes. All child objects must be enumerated before the text and they also may have embedded objects. All spaces and line breaks before </name> will be ignored. If you wish, you may specify no name and close such an object with </>.

If an object has no child objects, it can be described in the following way:

<name = "object text" [attributes]>

Text must be enclosed by single or double quotes.

The following structure is used for comments:

<- Comment ->

Each object is a macro and you can put it into the text of other objects or attributes. The service character '#' is used for that. Let us take an example:

<name1>
   <name2 field = 'Attribute of "name2"'>
      <name3 = "Text of name3">
   "Text of name2"
   </name2>
"Text of name1"
</name1>

#name1# - the substitution of Text of name1
#name1/name2/name3# - the substitution of Text of name3
#name1/name2.field# - the substitution of Attribute of "name2"

As you can see from the example, the character '/' is used to specify the embedment while the character '.' is used to get the value of the attribute.

While inserting an attribute into the text of its own object, you can omit the name of the object - #.object_name#

<name field1 = "attribute 1" field2 = "attribute 2">
Text = #.field1# + #name.field2#
</name>

The result of #name# will be Text = attribute 1 + attribute 2.

If you need to use a name that already contains a macro, it must be enclosed by square brackets.
#name[#subname#]#
In this case the value of #subname# will be obtained and substituted first and then the resulting name will be found.

The following combinations of the service character are possible:
## | Displaying a service character
#; | Line break and carriage return
#0XX | Displaying any character with this code
#- | Deleting previous characters like tab, space,carriage return and line feed
#<- -> | Comment
#" | Double quotes
#' | Single quotes

The service character can be redefined. To do it, describe it before the name of the object. The redefinition of a service character also affects child objects. It means that the service characters of child objects will coincide with the service characters of their parent object.

<$objname field = Àòðèáóò>
Text = $.field$
</name>

It is possible to use the following service characters: '#', '$', '&', '%', '!', '@', '^'. The character '*' before the name of an object means no service character.

You can specify parameters in the text of objects. In this case it will look like this:
#objname( parameters )

Parameters are divided with a comma and can be enclosed by single or double quotes. Use numerical macros to include parameters in the text.

#i# - where i is the number of parameters starting from 1. If a non-existing parameter is specified, an empty string will be inserted.

<name1>
   <name2 = "Hello, #1#!">
Text = #name1/name2( world )
</name1>

The full name of an object is its name with the complete embedment path. It is impossible to define two objects with the same full name.

Such a description is possible:

<name1>
   <name2 = "Object name1/name2">
Object name1
</name1>
<name2>
   <name2 = "Object name2/name2">
Object name2
</name2>

and this one will result in an error:

<name1>
Object name1
</name1>
<name1>
Object name1
</name1>

If you want to redefine an already existing object, you should place the character '|' before its name. All child objects will also be redefined in this case.

<name1>
Object name1
</name1>
<|name1>
Redefined object name1
</name1>

If you have objects with the same content, you can describe them with one object by enumerating their name in parentheses.

<(name1, name2, name3)>
</>

You can also create objects without specifying their names. To do it, you should use '_' as the name of the object.

<_>
Parent object
   <_ = "The first child object">
   <_>
      "The second child object"
   </>
</>

See also

Commands of the GT language Predefined features


Commands of the GT language

You can specify the command include as an object. Unlike the name of an object, the name of a command must start with a colon.

The command include inserts data from the specified file before starting to parse it, that is, when it is loaded. It can be useful for breaking large files into parts.

<:include = "c\myData\data1.gt">
<:include = "c\myData\data2.gt">

Besides, this command allows you to insert the content of a file into several places.

<object1>
<:include = "c\myData\data.gt">
</>
<object2>
<:include = "c\myData\data.gt">
</>

See also

Description of the GT language


Predefined features

Attributes

Since objects are inserted with the help of their full names, it becomes rather inconvenient if an object is embedded several levels deep. You can specify the attribute alias to such an object a new name. If alias is specified with no value, you can address this object using its regular name.

<name1>
   <name2 alias = name4>
      <name3 = "Object name1/name2/name3" alias>
      Object name1/name2
   </name2>
Object name1
</name1>

Further on, you can use
#name3# instead of #name1/name2/name3# and
#name4# instead of #name1/name2#

Types

By default, object data are considered a string, but you can use the attribute type to define it as a list (list), keys (keys) or a tree (tree).

List
Each line will be the corresponding array item. Strings can be enclosed by quotes.

<name1 type = list>
   First line
   "Second
 line"
   'Third line'
</name1>

Keys
Each line must contain a key and a value.

<name1 type = keys>
first = First line
second = Second line
thrid = "Third
 line"
</name1>

Tree
A tree also consists of lines. Square brackets are used to specify a node or a group. The first line after a square bracket will be the name of the group. For an empty name, you should use "".

<name1 type = tree>
   Item 1
   [ Group 1
      Item in group 1
      [ Group 2
         Item in group 2
      ]
   ]
</name1>

GT API Functions allow you to work with objects of this type as with arrays ( arr ), hash tables ( hash ) or trees ( tree ) respectively. If you want to get an item of a list or keys in the GT language, specify its number (beginning from 1) in the list or its key
#name1( 1 ) - the first item in the list of the object name1.
#name2( namekey ) - the item with key namekey in the object name2.
If an item can use parameters in its turn and you want to use them, you should start it from number two.

<name1 type = list>
   #2# number 1
   #2# number 2
</name1>

In this case, using
#name1( 1, Item ) will give you Item number 1.

See also

Description of the GT language GT API methods gtitem.getobj gttextapi.htm


Calling Gentee functions

The GT language allows you to call text functions in the Gentee language. Calling them does not differ from inserting objects with parameters. Text functions must look like this:

text myname( gtitem, arr of str )

The first parameter specifies the object from which the function is called, the second parameter stores an array of string parameters that were specified during the process of calling the function.

text myname( gtitem gti, arr par of str )
Hello, \{
   @par[0]
}!\!

Substituting #myname( world ) will result in Hello, world!.

Parentheses must be present when Gentee functions are called. If there is an object and a Gentee function with the same name, the Gentee function will be called. Suppose you have the function myname and the object myname.

<myname>
   Object myname
</myname>

Here is what you will get if you call the following functions:
#myname( world ) - Hello, world!.
#myname() - Hello, !.
#myname# - Object myname.

See also

GT API methods Description of the GT language Gentee functions


Gentee functions

Ready-made text functions you can use while describing GT data are listed here. They are called like this:

#name_func( parameter1, parameter2, ... )

  • Functions

    Functions

    gtcsv | Display a CSV list to a template
    gtcsvpar | Display a CSV list to a template
    gtexe | Get the name of the exe file
    gtexepath | Get the path to the exe file
    gtfullname | Get the full name of an object
    gtif | Return the second parameter if the first one is defined
    gtifnot | Return the second parameter if the first one is not defined
    gtifval | Return the second parameter, if the object is not empty
    gtis | Get the first defined object
    gtlist | Display a list according to a template
    gtlistpar | Display a complex list
    gtname | Get the object name
    gtnl | Replace new-line characters
    gtnotempty | Get the first no empty parameter
    gtread | Read from a file
    gtrepeat | Repeat input
    gtsub | Get a substring
    gttree | Display a tree according to a template
    gttreegi | Display a tree according to a template


GT API methods

In order to work with GT data, you should use variables of the gt type. Such a variable is a tree of objects of the gtitem type. Each of them stores information about the corresponding object with GT data. To be able to use all these methods, you need to enable the library gt.ge from the subdirectory Lib of the Gentee installation folder.

  • Operations
  • Methods
  • Methods for working with GT objects
  • Functions

    Operations

    Operations defined for the variable of gt type are listed below. The second column contains possible statements where typename is a variable or an expression of the specified type.
    Operation Syntax Return type Comments
    += gt += str gt Adding GT data to an existing GT object.
    foreach Using in the foreach operator. The description of an additional variable of the gtitems type is required. The foreach operator is used for variables of the gtitem type and goes through all child items of this object.

    gtitems gtis
...
foreach gtitem cur, gti.items( gtis )
{
   ...
}

    Methods

    gt.find | Find an object
    gt.get | Get the text of an object
    gt.getval | Get a numerical value
    gt.modify | Modify the data of an object
    gt.process | Process a text
    gt.read | Read GT data
    gt.root | Root item

    Methods for working with GT objects

    gtitem.child | Get a child object
    gtitem.del | Delete an object
    gtitem.get | Get the text
    gtitem.find | Searching for an attribute
    gtitem.getattrib | Get the value of an attribute
    gtitem.getattribclear | Get the value of the attribute
    gtitem.getfullname | Get the full name
    gtitem.getgt | Get an object of the gt type
    gtitem.getobj | An object of the predefined type
    gtitem.gettreeitem | Get a tree item
    gtitem.getvalattrib | The numerical value of an attribute
    gtitem.insert | Processing and inserting data
    gtitem.ischild | A check for embedded objects
    gtitem.iscomment | Comment or not
    gtitem.isroot | Whether it is a root object
    gtitem.key | Get the value of a key
    gtitem.list | Get a list item
    gtitem.listcount | The number of items in a list
    gtitem.modify | Modify the data of an object
    gtitem.modifyattrib | Modify the attribute of an object
    gtitem.modifyattribnot | Change the attribute to 0 or 1
    gtitem.move | Move an object
    gtitem.name | Object name
    gtitem.parent | Object owner
    gtitem.tostr | Convert into a string
    gtitem.value | The text of an object
    gtitem.valueattrib | The text of an attribute

    Functions

    gttext Insert a function into the text


gt.find

Get the object of the gtitem type with the specified name.
gtitem gt.find(
str objname
)

Parameters

objname The full name of the object

Return value

The object with the specified name or 0 if it is not found

See also

GT API methods


gt.get

The method gets the text of the object with all insertions.
uint gt.get(
str | objname,
str | output
)
uint gt.get(
str | objname,
str | output,
arr | params of str
)

Parameters

objname | The full name of the called object.
output | The string for writing the result.
params of str | Passed parameters.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gt.getval

Get the numerical value of the object or its attribute.
uint gt.getval(
str objname
)

Parameters

objname The full name of the object or the attribute.

Return value

The numerical value of the specified object.

See also

GT API methods


gt.modify

The method modifies the value of the object or the attribute.
uint gt.modify(
str | objname,
int | value
)
uint gt.modify(
str | objname,
str | value
)

Parameters

objname | The full name of the called object.
value | The new text or numerical value.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gt.process

The method parses the specified string and make a substitution in it.
uint gt.process(
str | in,
str | out
)

Parameters

in | String for parsing.
out | Result string.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gt.read

Load GT data from a file.
uint gt.read(
str filename
)

Parameters

filename Filename.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gt.root

Get the root item of the gtitem type of the specified GT object.

gtitem gt.root()

Return value

Root item

See also

GT API methods


gtcsv

The functions outputs the each item of CSV string with the specified template. The template is used for eth each items of the string.
gtcsv(
str | par1,
str | par2,
str | par3
)

Parameters

par1 | The input CSV formatted string.
par2 | A template for each items.
par3 | A common result template. It is not obligative.

Example

<itema>
    Item 1, Item 2, Item 3
</itema>
<pattern1>
   '<B>#1#</B><BR>
'
</pattern1>
<pattern2>
   '<P>#1#</P>
'
</pattern2>
Result of #gtcsv( #itema#, pattern1, pattern2 )
-----------------
<P><B>Item 1</B>
<B>Item 2</B>
<B>Item 3</B>
</P>


gtcsvpar

The functions outputs a CSV string with the specified template. The template is used for all string items. The first parameter - the first string item, etc.
gtcsvpar(
str | par1,
str | par2,
str | par3
)

Parameters

par1 | Input CSV formatted string.
par2 | A template for the output all string items.

Example

<itema>
    Item 1, Item 2, Item 3
</itema>
<pattern1>
   '<B>#1#</B><I>#2#</I>#3#'
</pattern1>
Result of #gtcsvpar( #itema#, pattern1 )
-----------------
<B>Item 1</B><I>Item 2</I>Item 3


gtexe

Get the full name of the currently running application.

gtexe()

Example

<itema>
    The current process: #gtexe()
</itema>


gtexepath

Get the path to the currently running application.

gtexepath()

Example

<itema>
    The path of the current process: #gtexepath()
</itema>


gtfullname

The full object name is returned. It is possible to return the full names of parent objects.
gtfullname(
str par1
)

Parameters

par1 An optional parameter equal to '/'. Each '/' character means getting the parent's name.

Example

<itema>
   <itemb>
      #gtfullname() -> itema/itemb
      #gtfullname(/) -> itema
   </itemb>
</itema>


gtif

If the object par1 is defined, par2 is returned. Otherwise, nothing is return.
gtif(
str | par1,
str | par2
)

Parameters

par1 | Conditional object
par2 | The returned string if the first object is defined.

Example

<itema>
This is a string.
</itema>
<itemb>
   #gtif( itema, "There is 'itema'") -> There is 'itema'
   #gtif( itemc, "There is 'itemc'") ->
</itemb>


gtifnot

If the object par1 is not defined, par2 is returned. Otherwise, nothing is returned.
gtifnot(
str | par1,
str | par2
)

Parameters

par1 | Conditional object
par2 | The returned string if the first object is not defined.

Example

<itema>
This is a string.
</itema>
<itemb>
   #gtifnot( itema, "There is not 'itema'") ->
   #gtifnot( itemc, "There is not 'itemc'") -> There is not 'itemc'
</itemb>


gtifval

The function returns the second parameter if the object is defined, not empty and is not '0'. Otherwise it returns the thrid parameter.
gtifval(
str | par1,
str | par2,
str | par3
)

Parameters

par1 | The name of the object.
par2 | The result string if the object is defined, no empty and is not '0'.
par3 | The other result string.

Example

<itema = 0>
<itemb = 'Item B'>
#gtifval( itema, 'OK', 'Empty or Zero') -> Empty or Zero
#gtifval( itemb, #itemb# ) -> Item B


gtis

The text of the first found object is returned.
gtis(
str ...
)

Parameters

... A sequence of parameters with object names.

Example

<itema>
This is A object.
</itema>
<itemb>
This is B object.
</itemb>
<itemc>
   #gtis( itema, itemb ) -> This is A object.
   #gtis( itemx, itemb, itema ) -> This is B object.
</itemc>


gtitem.child

The method returns the child object with the specified name
gtitem gtitem.child(
str name
)

Parameters

name The name of the embedded object

Return value

The child object or 0 if it is not found

See also

GT API methods


gtitem.del

The method deletes the specified object.

gtitem.del()

See also

GT API methods


gtitem.find

Searching for the attribute of this object.
uint gtitem.find(
str attrib
)

Parameters

attrib Attribute name.

Return value

Either the index of the attribute or 0, if the attribute is not found, is returned

See also

GT API methods


gtitem.get

Get the text with substitutions from the specified object.
uint gtitem.get(
str output
)

Parameters

output Result string.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gtitem.getattrib

Get the value of the specified object attribute.
uint gtitem.getattrib(
str | attrib,
str | output
)
uint gtitem.getattrib(
str | attrib,
str | output,
uint | mode
)

Parameters

attrib | Attribute name.
output | Result string.
mode
$GTG_OVER | Overwrite
$GTG_OVEREXIST | Overwrite if the string is not empty
If it is called without this parameter, the string will be added.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gtitem.getattribclear

The method gets the value of the attribute from the object. The string for getting the result will be cleared before the method is called.
uint gtitem.getattribclear(
str | attrib,
str | output
)

Parameters

attrib | Attribute name.
output | Result string.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gtitem.getfullname

Get the full name of the specified object.
str gtitem.getfullname(
str result
)

Parameters

result Result string.

Return value

The function returns the parameter result.

See also

GT API methods


gtitem.getgt

Get the object of the gt type to which this object belongs.

gt gtitem.getgt()

Return value

The object of the gt type.

See also

GT API methods


gtitem.getobj

If you have specified one of predefined types for the object, you can get the corresponding Gentee type (arr, hash, tree) and work with it.

uint gtitem.getobj()

Return value

The variable of the corresponding type or 0 in case of an error

See also

GT API methods Predefined features


gtitem.gettreeitem

The object of the gtitem type is a tree item stored in a variable of the gt type. This function returns the pointer to the treeitem structure, which will allow you to work with the object as with a tree item.

treeitem gtitem.gettreeitem()

Return value

The variable of the corresponding type or 0 in case of an error

See also

GT API methods


gtitem.getvalattrib

The method returns the numerical value of the attribute of the current objects.
int gtitem.getvalattrib(
str attrib
)

Parameters

attrib Attribute name.

Return value

Numerical value. If there is no such attribute, 0 is returned.

See also

GT API methods


gtitem.insert

The method processes text GT data and inserts the received objects into the current one.
gtitem gtitem.insert(
str data
)

Parameters

data Text GT data for insertion.

Return value

The last added object or 0 in case of an error.

See also

GT API methods


gtitem.ischild

The method determines if the specified object has child objects.

uint gtitem.ischild()

Return value

It returns 1 if the object embeds other objects and 0 if it does not.

See also

GT API methods


gtitem.iscomment

The method return 1 if the object is a comment.

uint gtitem.iscomment()

Return value

Returns 1 if the object is a comment and otherwise returns 0.

See also

GT API methods


gtitem.isroot

The method determines if the specified object is a root one.

uint gtitem.isroot()

Return value

It returns 1 if the object is a root one

See also

GT API methods


gtitem.key

For this method to be used, the object must be defined with the attribute type = keys. This method gets the value of the object with the specified key. The result is added to the existing string data.
str gtitem.key(
str | key,
str | out
)

Parameters

key | Key name
out | Result string.

Return value

The function returns the parameter out.

See also

GT API methods Predefined features


gtitem.list

For this method to be used, the object must be defined with the attribute type = list. This method gets the value of the item with the specified number from the list of the object. The result is added to the existing data.
str gtitem.list(
uint | num,
str | out
)

Parameters

num | The number of the item in the list starting from 0.
out | Result string.

Return value

The function returns the parameter out.

See also

GT API methods Predefined features


gtitem.listcount

For this method to be used, the object must be defined with the attribute type = list. The method returns the number of items in the list.

uint gtitem.listcount()

Return value

The number of items.

See also

GT API methods Predefined features


gtitem.modify

The method modifies the text of the object.
uint gtitem.modify(
str value
)

Parameters

value New text.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gtitem.modifyattrib

The method modifies the value of the attribute of this object.
uint gtitem.modifyattrib(
str | attrib,
int | value
)
uint gtitem.modifyattrib(
str | attrib,
str | value
)

Parameters

attrib | Attribute name.
value | The new text or numerical value of the attribute.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gtitem.modifyattribnot

If the value of the attribute is equal to 0 or if it is not defined, the method changes this value to 1. In all other cases, the method sets the value of the attribute to 0.
uint gtitem.modifyattribnot(
str attrib
)

Parameters

attrib Attribute name.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gtitem.move

The method inserts the specified object into its parent object.
uint gtitem.move(
gtitem after
)

Parameters

after The object after which the item must be inserted. Specify 0 if it should be inserted in the first place. The objects must belong to one and the same parent.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

GT API methods


gtitem.name

The method returns the name of the object. The retuned string must not be modified.

str gtitem.name()

Return value

The name of the object.

See also

GT API methods


gtitem.parent

The method returns the owner of the specified object.

gtitem gtitem.parent()

Return value

The owner of this object or 0 if it has no owner.

See also

GT API methods


gtitem.tostr

The method converts the object into a string.
str gtitem.tostr(
str ret
)

Parameters

ret Result string.

Return value

The function returns the parameter ret.

See also

GT API methods


gtitem.value

The method returns the text of this object without making substitutions. The retuned string must not be modified.

str gtitem.value()

Return value

Object text.

See also

GT API methods


gtitem.valueattrib

The method gets the text of the attribute without substitutions.
str gtitem.valueattrib(
str | attrib,
str | ret
)

Parameters

attrib | Attribute name.
ret | Result string.

Return value

The function returns the parameter ret.

See also

GT API methods


gtlist

The function displays the items of the list according to the template.
gtlist(
str | par1,
str | par2
)

Parameters

par1 | The name of the object with the list. The object must have the attribute type = list.
par2 | The name of the object with a template for displaying items

Example

<itema type = list>
    Item 1
    Item 2
    Item 3
</itema>
<pattern>
   '<LI>#1#
'
</pattern>
<itemc>
   '<UL>
#gtlist( itema, pattern )
</UL>'
</itemc>
Result of #itemc#
-----------------
<UL>
<LI>Item 1
<LI>Item 2
<LI>Item 3
</UL>


gtlistpar

The functions outputs a list with the specified template. Strings of the list can be divided by commas.
gtlistpar(
str | par1,
str | par2
)

Parameters

par1 | The name of the list object. It must have the attrib type = list.
par2 | A template for outputing list items.

Example

<itema type = list>
    Item 11, Item 12, Item 13
    Item 21, Item 22, Item 23
</itema>
<pattern1>
   '<B>#1#</B><I>#2#</I>#3#
'
</pattern1>
Result of #gtlistpar( #itema#, pattern1 )
-----------------
<B>Item 11</B><I>Item 12</I>Item 13
<B>Item 21</B><I>Item 22</I>Item 23


gtname

The object name is returned. It is possible to return the names of parent objects.
gtname(
str par1
)

Parameters

par1 An optional parameter equal to '/'. Each '/' character means getting the parent's name.

Example

<itema>
   <itemb>
      #gtname() -> itemb
      #gtname(/) -> itema
   </itemb>
</itema>


gtnl

The function replace new-string characters to the specified string.
gtnl(
str | par1,
str | par2
)

Parameters

par1 | Output string.
par2 | A string for replacing new-line characters.

Example

<itema = 'String 1
String 2
String 3'>
#gtnl(#itema#, <BR>) -> String 1<BR>String 2<BR>String 3


gtnotempty

Get the first no empty string.
gtnotempty(
str ...
)

Parameters

... A sequence of parameters

Example

<itema = ''>
<itemb = 'Item B'>
#gtnotempty(#itema#, #itemb#) -> Item B


gtread

Inserting the contents of one or several files.
gtread(
str ...
)

Parameters

... A sequence of file names that must be read and inserted where the function is called.

Example

#gtread( "c:\files\myfile1.txt", "c:\files\myfile2.txt" )


gtrepeat

The function displays the string the specified number of times.
gtrepeat(
str | par1,
str | par2
)

Parameters

par1 | Repeated string
par2 | An optional parameter determining the number of repetitions

Example

#gtrepeat( ABC, 3 ) -> ABCABCABC
#gtrepeat( ABC ) -> ABC


gtsub

Get the substring of the specified string.
gtsub(
str | par1,
str | par2,
str | par3
)

Parameters

par1 | Initial string
par2 | If there are two parameters, the second one is the size of the substring. If there are three parameters, the last one is the shift of the substring (starting from 0).
par3 | The size of the substring to be obtained. An optional parameter. If it is not specified, the substring begins at 0 and has the size of par2.

Example

#gtsub( ABCDEF, 1, 3 ) -> BCD
#gtsub( ABCDEF, 4 ) -> ABCD


gttext

This text function can be called from other text functions. Once it is called, all necessary substitutions will be made in the parameter string and the result will be written into the current output field.
text gttext(
gt | gti,
str | pattern
)

Parameters

gti | The variable of the gt type.
pattern | Text to be processed.

See also

GT API methods


gttree

Display the tree according to the template for each embedment level.
gttree(
str | par1,
str | ...
)

Parameters

par1 | The name of the object with the tree. The object must have the attribute type = tree.
... | The sequence of template objects for each embedment level.

Example

<itema type = tree>
    Item 1
    [Group 2
      Item 2 1
      Item 2 2
    ]
    [Group 3
      Item 3 1
      Item 3 2
    ]
</itema>
<pattern1>
   '<B>#1#</B><HR SIZE=1><UL>
#2#
</UL>'
</pattern1>
<pattern2>
   '<LI>#1#
'
</pattern2>
Result of #gttree( itema, pattern1, pattern2 )
-----------------
<B>Item 1</B><HR SIZE=1><UL>
</UL>
<B>Group 2</B><HR SIZE=1><UL>
<LI>Item 2 1
<LI>Item 2 2
</UL>
<B>Group 3</B><HR SIZE=1><UL>
<LI>Item 3 1
<LI>Item 3 2
</UL>


gttreegi

Display the tree according to the template for groups and final items.
gttreegi(
str | par1,
str | par2,
str | par3
)

Parameters

par1 | The name of the object with the tree. The object must have the attribute type = tree.
par2 | The name of the object for displaying groups.
par3 | The name of the template object for displaying final items.

Example

<itema type = tree>
    Item 1
    [Group 2
      Item 2 1
      Item 2 2
    ]
    [Group 3
      Item 3 1
      Item 3 2
    ]
</itema>
<pattern1>
   '<B>#1#</B><HR SIZE=1><UL>
#2#
</UL>'
</pattern1>
<pattern2>
   '<LI>#1#
'
</pattern2>
Result of #gttreegi( itema, pattern1, pattern2 )
-----------------
<LI>Item 1
<B>Group 2</B><HR SIZE=1><UL>
<LI>Item 2 1
<LI>Item 2 2
</UL>
<B>Group 3</B><HR SIZE=1><UL>
<LI>Item 3 1
<LI>Item 3 2
</UL>


 createwin

The function creates a window.

uint createwin(
uint | exstyle,
str | class,
str | name,
uint | style,
uint | left,
uint | top,
uint | width,
uint | height,
uint | parent,
uint | menu,
uint | param
)

Parameters

exstyle | Extended window styles.
class | The class of the created window.
name | Window text.
style | Window style.
left | the X coordinate of the upper left corner.
top | the Y coordinate of the upper left corner.
width | Window width.
height | Window height.
parent | Parent window identifier.
menu | Menu identifier or child identifier.
param | Additional parameter.

Return value

The identifier of the created window or 0 in case of an error.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 dlgbox

Creating a modal or child dialog box.

uint dlgbox(
uint | hinst,
uint | dlgid,
uint | wnd,
uint | cmdfunc,
uint | idfunc,
uint | child
)

Parameters

hinst | The identifier of the module with the resource.
dlgid | The name of the dialog box being loaded or its numeric identifier.
wnd | Owner window.
cmdfunc | Event handling function. It can be 0.
idfunc | Command handling function.
child | Specify 0 to create a modal window and 1 to create a child window.

Return value

The identifier of the child dialog box or the code of a return from the modal window.

See also

Dialog boxes.

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 dlgdisable

The function cancels the possibility of working with the dialog item.

dlgdisable(
uint | dlg,
uint | id
)

Parameters

dlg | Handle of the dialog window.
id | Handle of the dialog control.

See also

Dialog boxes.

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 dlgenable

The function sets or cancels the possibility of working with the dialog item.

dlgenable(
uint | dlg,
uint | id,
uint | enable
)

Parameters

dlg | Handle of the dialog window.
id | Handle of the dialog control.
enable | Specify 1 if you want to make the item available and 0 otherwise.

See also

Dialog boxes.

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 getdlgtext

The function gets the text of the dialog item.

str getdlgtext(
uint | dlg,
uint | id,
str | ret
)

Parameters

dlg | Handle of the dialog window.
id | Handle of the dialog control.
ret | Result string.

Return value

The function returns the parameter ret.

See also

Dialog boxes.

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 getwinfont

The function returns the font of the this window.

uint getwinfont(
uint wnd
)

Parameters

wnd Handle of the window.

Return value

Font identifier

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 getwinfullrect

The function returns the coordinates and the size of the entire window area.

RECT getwinfullrect(
uint | wnd,
RECT | rect
)

Parameters

wnd | Handle of the window.
rect | Variable to get the result.

Return value

The function returns the parameter rect.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 getwinrect

The function returns the coordinates and the size of the client part of the window.

RECT getwinrect(
uint | wnd,
RECT | rect
)

Parameters

wnd | Handle of the window.
rect | Variable to get the result.

Return value

The function returns the parameter rect.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 getwintext

The function gets the text of the window.

str getwintext(
uint | wnd,
str | ret
)

Parameters

wnd | Handle of the window.
ret | Result string.

Return value

The function returns the parameter ret.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 gui_deinit

This function finishes working with the GUI library. Called at the end of a program.

gui_deinit( )

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 gui_init

The function initializing the GUI library. Called at the beginning of a program. You should load all resource descriptions into the gtapp global variable before calling gui_init. The format of the resource description in the GT language is described in the corresponding sections.

gui_init( )

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 Language support

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 setdlgtext

The function sets the text of the dialog item.

uint setdlgtext(
uint | dlg,
uint | id,
str | ret
)

Parameters

dlg | Handle of the dialog window.
id | Handle of the dialog control.
ret | The text to be set.

Return value

If error occurs, function returns 0.

See also

Dialog boxes.

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 setwinicon

The function sets an icon for the window.

setwinicon(
uint | wnd,
str | iconres
)

Parameters

wnd | Handle of the window.
iconres | Icon resource name

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 setwintext

The function sets the text of the window.

uint setwintext(
uint | wnd,
str | ret
)

Parameters

wnd | Handle of the window.
ret | The text to be set.

Return value

If error occurs, function returns 0.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 showdialog

Opening a dialog box. The dialog box will be loaded from the GT resource specified as a parameter.

uint showdialog(
str name
)

Parameters

name The name of the dialog box resource.

Return value

Handle of the dialog window.

See also

Dialog boxes.

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 subhead

GUI

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 winenum

Enumerating child windows for the specified window.

uint winenum(
uint | wnd,
dword | idfunc,
dword | param
)

Parameters

wnd | Handle of the window.. If it equals 0, all top level windows will be enumerated.
idfunc | The function that will be called for each window. The function must look like this func uint myfunc( uint wnd param). The function must return 1. The enumeration will be stopped if the function returns 0.
param | Additional parameter.

Return value

0 is returned in case of an error or if enumeration is forced to be stopped.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 winexdata

The function gets a pointer to a structure for storing additional information about the window. The type of the structure is specified when the window class is registered.

uint winexdata(
uint wnd
)

Parameters

wnd Handle of the window..

Return value

The pointer to additional data.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 winloop

The main function for handling the message loop for the main window of the application.

winloop(
uint | wnd,
uint | accel
)

Parameters

wnd | Handle of the window.
accel | The identifier of the table with loaded hot keys. It can be 0.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 winregister

Window class registration function. All parameters before idfunc are compatible with the fields of the WNDCLASS structure.

uint winregister(
uint | classname,
uint | style,
uint | icon,
uint | cursor,
uint | back,
uint | idfunc,
uint | exdata
)

Parameters

classname | Window class name. Passed using the method ptr() - "myclass".ptr().
style | Class styles.
icon | Class icon.
cursor | Class cursor,
back | Background brush
idfunc | The pointer to the event handling function.
exdata | The name of the type (structure) each window of this class will have. This type can be used to store additional information about a window.

Return value

If error occurs, function returns 0.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


 winsubclass

The function defines an additional event handler for this window.

uint winsubclass(
uint | wnd,
uint | idfunc
)

Parameters

wnd | Handle of the window..
idfunc | The pointer to the handling function.

Return value

Returns 1.

See also

Window Functions

Copyright © 2004-2005 Gentee, Inc. All rights reserved.


ge_call

Call the function from the bytecode. To use this function, specify the GEF_VM flag, when calling ge_init. The bytecode should be previously loaded with the help of the ge_load function.
DWORD __cdecl ge_call(
DWORD | id,
DWORD* | result,
... |
)

Parameters

id | Identifier of the called function. Can be obtained by ge_getid function.
result | Pointer to the memory space, to which the result will be written.
... | Required parameters of the function.

Return value

Returns “0” in case of error.

See also

Gentee API functions ge_getid


ge_compile

This function allows to compile programs in Gentee.
DWORD WINAPI ge_compile(
BYTE* | filename,
BYTE* | fileout,
sbcode* | bcode,
DWORD | cflag,
BYTE* | args
)

Parameters

filename | Filename for compilation. As this parameter, you can specify text of the program to be compiled. At that, the text should begin with the name of the program, enclosed in angle brackets: <Program_name>.
fileout | Filename for recording the resulting bytecode. If “0,” filing will not be performed.
bcode Structure pointer sbcode. If not “0,” the structure will contain the resulting bytecode, which can be loaded by ge_load or filed. After finishing the work, delete the bytecode with the help of the function ge_freebcode.
type sbcode {
uint | data
uint | size
byte | reserved[ 9 ]
}

Fields

data | Resulting bytecode pointer.
size | Bytecode’s size.

cflag Compilation flags.
COMPILE_NOSTD Do not link the standard library.
args | args,Compiler’s arguments. They are intended for detecting macros from the command line. Macros should be separated by semicolon. This parameter may equal zero.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Gentee API functions


ge_deinit

This function is called when work with module gentee.dll is finished.

See also

Gentee API functions


ge_execute

This function compiles and runs a Gentee program without saving the bytecode to the file.
DWORD WINAPI ge_execute(
BYTE* | filename,
BYTE* | args
)

Parameters

filename | Filename for compilation. As this parameter, you can use program’s text instead of filename. At that, the text should begin with program’s name enclosed in angle brackets: <Program’s name>.
args | Command line arguments for launching resulting bytecode. The arguments should be separated by the “0” symbols. The last argument should be followed by two zeros.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Gentee API functions ge_compile


ge_freebcode

Delete the bytecode returned by the ge_compile function.
void WINAPI ge_freebcode(
sbcode* bcode
)

Parameters

bcode Structure sbcode containing bytecode.

See also

Gentee API functions ge_compile


ge_getid

Get the objects identifier by its name.
DWORD WINAPI ge_getid(
BYTE* name
)

Parameters

name Object’s name.

Return value

Returns object’s identifier or “0,” if the object was not found.

See also

Gentee API functions ge_call


ge_init

This function should be called before beginning to work with gentee.dll.
void WINAPI ge_init(
sgeinit* geinit
)

Parameters

geinit Structure pointer sgeinit.

See also

Gentee API functions sgeinit


ge_load

This function executes specified bytecode.
DWORD WINAPI ge_load(
BYTE* | bytecode,
DWORD | loadflag,
BYTE* | args
)

Parameters

bytecode | Executed bytecode pointer.
loadflag Bytecode launching flags. If flags are not used, the bytecode will be loaded to memory without execution.
GLOAD_FILE | Load the bytecode from the file. bytecode contains filename.
GLOAD_ENTRY | Load the bytecode and execute the functions with flags entry.
GLOAD_MAIN | Same as GLOAD_ENTRY and execute function with flag main.
GLOAD_CMDARGS | Get arguments from the command line of the current process.
args | Command line arguments for launching the resulting bytecode. The arguments should be separated by the “0” symbol, the last argument should be followed by two zeros. Arguments are defined automaticaly if GLOAD_CMDARGS is specified.

Return value

The result of the bytecode’s work.

See also

Gentee API functions ge_compile


messagefunc

You should define a function of the following type, if you want to manually handle and lead the messages of the compiler and execution period core.

int (CALLBACK* messagefunc)( smess*)

The next structure’s pointer is used as a parameter, while the function itself should return “0.”
type smess {
DWORD | code
LPSTR | text
LPCSTR | filename
DWORD | line
DWORD | pos
DWORD | iscompile
}

Fields

code | Error code or message code.
text | Message text.
filename | Name of the file, in which the error occurred.
line | Number of the line, in which the error occurred.
pos | Position in the line, in which the error was detected.
iscompile | If “1,” than it is compiler’s error. If “0,” it is a run-time error.

See also

Gentee API functions ge_init Error codes and message codes


sgeinit

This structure’s pointer is transferred at initialization gentee.dll.
type sgeinit {
uint | size
uint | flags
messagefunc | message
printfunc | print
exportfunc | export
pstempdata | temp
}

Fields

size | Sgeinit structure size.
flags Additional flags.
GEF_NOSYSOUT | Don’t show service messages.
GEF_CONSOLE | connection of dll is performed from a console application.
GEF_VM | All tasks perform on one virtual machine. If this flag isn’t selected, each call ge_load will create its own virtual machine.
message | A function of messagefunc type for handling of compiler’s messages and program run module. If “0,” then the default function is used.
print A function for outputting messages’ texts. You can view all compiler messages or program’s functioning results in any preferable mode.

void (CALLBACK* printfunc)( char* )

If the field equals “0,” the a default output mode is used.

export A function for exporting functions from your program. Specify this field, if you want to call functions of your application from Gentee programs.

pvoid (CALLBACK* exportfunc)( char* ))

The parameter contains the name of the function, and you should return a pointer for that function. In a Gentee program, you should describe these functions with the help of the import command. At that, use empty string as a dll file.

import ""
{
   ...
}

temp | The pointer to the temporary directory information. It can be 0. See also stempdata

See also

Gentee API functions ge_init messagefunc


stempdata

The pointer to this structure can be specified in the structure sgeinit.
type stempdata {
DWORD | tempid
PVOID | tempfile
BYTE* | tempdir
}

Fields

tempid | The number of the temporary directory
tempfile | The handle of the open temp file
tempdir | The full name of the temporary directory.

See also

Gentee API functions


abbrnameofday

Get the short name of a weekday in the user's language.
str abbrnameofday(
str | ret,
uint | dayofweek
)

Parameters

ret | The string for getting the result.
dayofweek | The number of the weekday. 0 is Sunday, 1 is Monday...

Return value

The function returns the parameter ret.

See also

Function for working with time


abs

The absolute value for integers |x|.
uint abs(
int x
)

Parameters

x An integer.

Return value

The absolute value.

See also

Mathematical functions


acos

Calculating the arc cosine.
double acos(
double x
)

Parameters

x A value for calculating the arc cosine.

Return value

The arc cosine of x within the range [ 0; PI ].

See also

Mathematical functions


alloc

The function allocates the memory of the specified size.
uint alloc(
uint size
)

Parameters

size The size of memory space to be allocated.

Return value

The pointer to the allocated memory space or 0 in case of an error.

See also

Working with memory


argc

The function returns the number of parameters in the command line.

uint argc()

Return value

The number of parameters passed in the command line.

See also

Other functions


argv

The function returns the parameters of the command line.
str argv(
str | ret,
uint | num
)

Parameters

ret | A variable of the str type to write the return value to.
num | The number of the parameter to be obtained beginning from 1.

Return value

The function returns the parameter ret.

See also

Other functions


arr.clear

Clear an array. The method removes all items from the array.

arr.clear()

See also

Arrays


arr.cut

Reduce an array. All items exceeding the specified number will be deleted.
arr.cut(
uint count
)

Parameters

count The number of items left in the array.

See also

Arrays


arr.del

Remove items or an items from an array.
arr.del(
uint num
)

Parameters

num The number of item starting from 0.

arr.del(
uint | from,
uint | to
)

Parameters

from | Íîìåð ïåðâîãî óäàëÿåìîãî ýëåìåíòà ñ 0.
to | The number of the last item being deleted.

See also

Arrays


arr.expand

Add items to an array.
uint arr.expand(
uint count
)

Parameters

count The number of items being added.

Return value

The number of items in the array.

See also

Arrays


arr.insert

Inserts elements into the array at the specified index.
arr.insert(
uint | from,
uint | count
)

Parameters

from | Index of the first inserted element starts at zero.
count | The amount of elements are required to be inserted.

arr.insert(
uint index
)

Parameters

index Index of the element needs to be inserted.

See also

Arrays


arr.move

Move an item in an array.
arr.move(
uint | from,
uint | to
)

Parameters

from | The current index of the item starting from zero.
to | The new index of the item starting from zero.

See also

Arrays


arr.ptr

Get the pointer to data stored in an array.

uint arr.ptr()

Return value

The pointer to the array data.

See also

Arrays


arr.reserve

Reserve a position in an array. It is possible to add and remove items in arrays when the program is running. If the number of items is not known beforehand, but it can be large, it is better to reserve positions for items that will be added from the beginning.
arr arr.reserve(
uint count
)

Parameters

count The number of items being reserved.

Return value

Returns the object which method has been called.

See also

Arrays


arr.sort

Sort array items according to the sorting function. The function must have two parameters containing pointers to two compared items. It must return int less than, equal to or greater than zero if the left value is less than, equal to or greater than the first one respectively.
arr arr.sort(
uint sortfunc
)

Parameters

sortfunc Sorting function.

Return value

Returns the object which method has been called.

See also

Arrays


arr.sortstr

Sort the string array arr of str. The method sortstri sorts strings without taking into account the case of letters.

arr.sortstri()

arr.sortstr()

See also

Arrays


asin

Calculating the arc sine.
double asin(
double x
)

Parameters

x A value for calculating the arc sine.

Return value

The arc cosine of x within the range [ -PI/2 ; PI/2 ].

See also

Mathematical functions


atan

Calculating the arc tangent.
double atan(
double x
)

Parameters

x A value for calculating the arc tangent.

Return value

The arc tangent of x within the range [ -PI/2 ; PI/2 ].

See also

Mathematical functions


buf.alloc

The method allocates memory of the specified size in the object. If there is any data in the buffer, it is destroyed.
buf buf.alloc(
uint size
)

Parameters

size The size of memory space to be allocated.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


buf.append

The method adds data to the object.
buf buf.append(
uint | src,
uint | size
)

Parameters

src | The pointer to the data to be added.
size | The size of the data being added.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


buf.clear

Clear data in the object.

buf.clear()

See also

Buffer - binary data


buf.copy

The method copies data into the object.
buf buf.copy(
uint | src,
uint | size
)

Parameters

src | The pointer to the data being copied.
size | The size of the data being copied.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


buf.crc

The method calculates the checksum of data for an object of the buf.

uint buf.crc()

Return value

The checksum is returned.

See also

Buffer - binary data


buf.del

The method deletes part of data.
buf.del(
uint | off,
uint | size
)

Parameters

off | The offset of the data being deleted.
size | The size of the data being deleted.

See also

Buffer - binary data


buf.expand

The method increases the size of memory allocated for the object.
buf buf.expand(
uint size
)

Parameters

size The requested size of memory. If it is less than the current size, nothing happens. If the size is increased, the current data is saved.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


buf.free

The method deallocates memory allocated for the object.

buf.free()

See also

Buffer - binary data


buf.getmultistr

If an object contains a sequence of strings ending in zeros, this method will write these strings into a string array.
arr buf.getmultistr(
arr ret of str
)

Parameters

ret of str The string array the sequence of strings from the buffer will be written to.

Return value

The function returns the parameter ret.

See also

Buffer - binary data


buf.insert

The method inserts one buf object into another.
buf buf.insert(
uint | offset,
buf | value
)

Parameters

offset | The offset where data will be inserted. If the offset is greater than the size, data is added to the end to the buffer.
value | The buf object with the data to be inserted.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


buf.read

Reading data from a file.
buf buf.read(
str filename
)

Parameters

filename Filename.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


buf.regget

This method writes the value of a registry key into an object of the buf type.
buf buf.regget(
uint | root,
str | subkey,
str | valname,
uint | regtype
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | A name of the specified key value.
regtype | The pointer to uint the type of this value will be written to. It can be 0.

Return value

Returns the object which method has been called.

See also

Working with the Registry


buf.regset

Write the data of an buf object as registry key value. If there is no key, it will be created.
uint buf.regset(
uint | root,
str | subkey,
str | valname,
uint | regttype,
arr | ret of str
)

Parameters

root A root key.
$HKEY_CLASSES_ROOT
$HKEY_CURRENT_USER
$HKEY_LOCAL_MACHINE
$HKEY_USERS
subkey | A name of the registry key.
valname | The name of the value being written.
regttype Value type.
$REG_SZ | string
$REG_EXPAND_SZ | string with environment variables
$REG_BINARY | binary data
$REG_DWORD | number
$REG_MULTI_SZ | string sequence
ret of str | The array of strings all the created keys will be written to. It can be 0.

Return value

0 | no data has been written
1 | the value of the key was created during the writing process
2 | data is written into the existing value

See also

Working with the Registry


buf.replace

The method overwrites data in an object.
buf buf.replace(
uint | offset,
uint | size,
buf | value
)

Parameters

offset | The offset of the data being overwritten.
size | The size of the data being overwritten.
value | The buf object with new data.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


buf.setmultistr

The method writes all strings from a string array one by one into the specified object. Each string will end in a zero.
buf buf.setmultistr(
arr ret of str
)

Parameters

ret of str The string array data will be taken from.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


buf.write

Writing data to a file.
uint buf.write(
str filename
)

Parameters

filename The name of the file for writing. If the file already exists, it will be overwritten.

uint buf.write(
uint handle
)

Parameters

handle File identifier.

uint buf.write(
uint | handle,
uint | pos,
uint | off,
uint | size
)

Parameters

handle | File identifier.
pos | The offset in the file.
off | The offset of the data being written in the buffer.
size | The size of the data being written.

Return value

If error occurs, function returns 0.

See also

Buffer - binary data


buf.writeappend

Append data to the specified file.
uint buf.writeappend(
str filename
)

Parameters

filename The name of the file for writing. If the file already exists, it will be appended.

Return value

If error occurs, function returns 0.

See also

Buffer - binary data


call

This function allows you to call functions by their address. For instance, you can use it for dynamicaly loading DLL.

str name
uint lib = LoadLibrary( "kernel32.dll".ptr())
name.reserve( 512 )
call( GetProcAddress( lib, "GetModuleFileNameA".ptr()), 0x1000,
%{ GetModuleHandle(), name.ptr(), 512 } )
name.setlenptr()
print( "\(name)")

uint call(
uint | address,
uint | flags,
collection | params
)

Parameters

address | The address of the calling function.
flags Calling flags.
0x000100 | Calling cdecl fucntion
0x001000 | There is a return value - uint
params | Parameters for the calling function.

Return value

The value to was returned by the calling function.

See also

Other functions


callback

This function allows you to use gentee functions as callback functions. For example, gentee function can be specified as a message handler for windows.

uint cback = callback( &myfunc, 4 )
...
freecallback( cback )

uint callback(
uint | address,
uint | sizeparams
)

Parameters

address | Identifier ( address ) of gentee function that will be callback function.
sizeparams | The summary size of parameters (number of uint values). One parameter uint = 1 (uint = 1). uint + uint = 2, uint + long = 3.

Return value

You can use the return value as the callback address. You have to free it with freecallback function when you don't need this callback function.

See also

Other functions


ceil

Getting the smallest integer that is greater than or equal to x.
double ceil(
double x
)

Parameters

x Floating-point value.

Return value

The closest least integer.

See also

Mathematical functions


char2str

Convert the code of a character into a string.
str char2str(
str | par,
uint | ch
)

Parameters

par | The string for writing. The character will be added to the end of the string.
ch | Character code.

Return value

The function returns the parameter par.

See also

Strings


clipboard_gettext

Get a string from the clipboard.
uint clipboard_gettext(
str data
)

Parameters

data Result string.

Return value

The function returns the parameter data.

See also

Clipboard


clipboard_settext

Copy a string into the clipboard
uint clipboard_settext(
str data
)

Parameters

data The string for copying into the clipboard.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Clipboard


close

Close a file.
uint close(
uint handle
)

Parameters

handle File identifier.

Return value

If error occurs, function returns 0.

See also

Function working with files


collection.append

Appends elements of a collection to another collection.
collection collection.append(
collection src
)

Parameters

src The collection needs to be appended.

Return value

Returns the object which method has been called.

See also

Collections


collection.clear

Delete all items from the collection.

collection collection.clear()

Return value

Returns the object which method has been called.

See also

Collections


collection.gettype

Gets a element type of a collection.
uint collection.gettype(
uint index
)

Parameters

index Element index starts at zero.

Return value

An element type of a collection or zero on error.

See also

Collections


collection.ptr

Gets a pointer to a collection element.
uint collection.ptr(
uint index
)

Parameters

index Element index starts at zero.

Return value

A pointer to a collection element, or zero on error.

See also

Collections


collection.val

Gets a value of a collection element; this method is applied if an element type is a structure or a fundamental type, except for double, ulong and long.
uint collection.val(
uint index
)

Parameters

index Element index starts at zero.

Return value

A value of a collection element.

See also

Collections


congetch

Display text and wait for a keystroke.
uint congetch(
str text
)

Parameters

text Message text.

Return value

The function returns the value of the pressed key.

See also

Function for working with the console


congetstr

Get the string entered by the user with some text displayed before that.
str congetstr(
str | text,
str | input
)

Parameters

text | Text for displaying.
input | The variable of the str type for getting data.

Return value

The function returns the parameter input.

See also

Function for working with the console


conread

Get a string entered by the user.
str conread(
str input
)

Parameters

input The variable of the str type for getting data.

Return value

The function returns the parameter input.

See also

Function for working with the console


conrequest

Display a multiple choice request on the console.
uint conrequest(
str | text,
str | answer
)

Parameters

text | Request text.
answer | Enumerating possible answer letters. Answer variants are separated by '|'. For example, "Nn|Yy"

Return value

The function returns the number of the selected variant beginning from 0.

See also

Function for working with the console


conyesno

Display a question on the console.
uint conyesno(
str text
)

Parameters

text Question text.

Return value

The function returns 1 if the answer is 'yes' and 0 otherwise.

See also

Function for working with the console


copyfile

Copy a file.
uint copyfile(
str | name,
str | newname
)

Parameters

name | The name of an existing file.
newname | A new file name and path. If the file already exists, it will be overwritten.

Return value

If error occurs, function returns 0.

See also

Function working with files


copyfiles

Copying files and directories by mask.
uint copyfiles(
str | src,
str | destdir,
uint | flag,
uint | mode,
uint | proccess
)

Parameters

src | The names of mask of the files or directories being copied.
destdir | The directory where files will be copied.
flag The combination of search flags $FIND and
$COPYF_RO | Overwrite files with the attribute read-only.
$COPYF_SAVEPATH | Keep relative paths while copying files from subdirectories
$COPYF_ASK | Prompt before copying files already existing.
mode What to do if the file being copied already exists.
$COPY_OVER | Overwrite
$COPY_SKIP | Skip
$COPY_NEWER | Overwrite if newer
$COPY_MODIFIED | Overwrite if modified
proccess | The identifier of the function handling messages.

Return value

The function returns 1 if the copy operation is successful, otherwise it returns 0.

See also

Function working with files The handler of copyfiles messages


cos

Calculating the cosine.
double cos(
double x
)

Parameters

x An angle in radians.

Return value

The cosine of x.

See also

Mathematical functions


createdir

Create a directory.
uint createdir(
str name
)

Parameters

name The name of the directory being created.

Return value

If error occurs, function returns 0.

See also

Function working with files


csv.append

Add a string to an csv object.
csv.append(
arr val of str
)

Parameters

val of str The array of strings containing the elements of a string. All strings will be combined into one record and added to the csv object.

See also

Working with CSV data


csv.clear

Clear the csv data object.

csv.clear()

See also

Working with CSV data


csv.read

Read data from a csv file.
uint csv.read(
str filename
)

Parameters

filename Filename.

Return value

The size of the read data.

See also

Working with CSV data


csv.settings

Set separating and limiting characters for csv data.
csv.settings(
uint | separ,
uint | open,
uint | close
)

Parameters

separ | Separator. Comma by default.
open | The left limiting character. Double quotes by default.
close | The right limiting character. Double quotes by default.

See also

Working with CSV data


csv.write

Writing csv data to a file.
uint csv.write(
str filename
)

Parameters

filename The name of the file for writing. If the file already exists, it will be overwritten.

Return value

The size of the written data.

See also

Working with CSV data


datetime.dayofweek

Get the weekday.

uint datetime.dayofweek()

Return value

Returns the weekday.
0 is Sunday, 1 is Monday...

See also

Function for working with time


datetime.dayofyear

Get the number of a particular day in the year.

uint datetime.dayofyear()

Return value

Returns the number of a particular day in the year.

See also

Function for working with time


datetime.gettime

Get the current time. The weekday is set automatically.

datetime datetime.gettime()

Return value

Returns the object which method has been called.

See also

Function for working with time


datetime.setdate

Specify a date for the specified datetime structure. The weekday is set automatically.
datetime datetime.setdate(
uint | day,
uint | month,
uint | year
)

Parameters

day | Day.
month | Month.
year | Year.

Return value

Returns the object which method has been called.

See also

Function for working with time


datetimetoftime

Convert date from datetime into filetime.
uint datetimetoftime(
datetime | dt,
filetime | ft
)

Parameters

dt | Datetime structure.
ft | The variable of the filetime type for getting the result.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Function for working with time


days

The number of days between two dates.
int days(
datetime | left,
datetime | right
)

Parameters

left | The first date for comparison.
right | The second date for comparison.

Return value

Returns the number of days between two dates. If the first date is greater than the second one, the return value will be negative.

See also

Function for working with time


daysinmonth

The number of days in a month. Leap years are taken into account for February.
uint daysinmonth(
uint | year,
uint | month
)

Parameters

year | Year.
month | Month.

Return value

Returns the number of days in the month.

See also

Function for working with time


dbf.append

The method adds a record to a database.

uint dbf.append()

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.bof

Determine is the current record is the first one.

uint dbf.bof()

Return value

1 is returned if the current record is the first one.

See also

Working with DBF files


dbf.bottom

Move to the last record.

uint dbf.bottom()

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.close

Close a database.

dbf.close()

See also

Working with DBF files


dbf.create

Create a dbf file and open it.
uint dbf.create(
str | filename,
str | fields,
uint | ver
)

Parameters

filename | The name of the dbf file being created.
fields | The description of database fields. The line containing the description of fields separated by a line break or ';' Field name,Field type,Width,Fractional part length for numbers The name of a field cannot be longer than 10 characters Possible type fields: Ñ - string,N - integer,F - fraction,L - logical,D - date, M - memo field
ver | Version. 0 for dBase III or 1 for dBase IV.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.del

Set/clear the deletion mark for the current record.

uint dbf.del()

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.empty

The method creates the same, but empty database.
uint dbf.empty(
str filename
)

Parameters

filename The full name of the dbf file being created.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.eof

Determine is the current record is in the database.

uint dbf.eof()

Return value

Returns 1 if the current record is not defined/found and 0 otherwise.

See also

Working with DBF files


dbf.f_count

uint dbf.f_count()

Return value

Returns the number of fields.

See also

Working with DBF files


dbf.f_date

Getting the date from the specified field of the current record as a string or into the structure datetime.
str dbf.f_date(
str | val,
uint | num
)

Parameters

val | The string for getting the date.
num | Field number beginning with 1.

Return value

The function returns the parameter val.

datetime dbf.f_date(
datetime | dt,
uint | num
)

Parameters

dt | The structure for getting the date.
num | Field number beginning with 1.

Return value

The function returns the parameter dt.

See also

Working with DBF files


dbf.f_decimal

The method returns the size of the fractional part in a numerical field.
uint dbf.f_decimal(
uint num
)

Parameters

num Field number beginning with 1.

Return value

The size of the fractional part.

See also

Working with DBF files


dbf.f_double

Get a numerical value of the double type from the specified field of the current record.
double dbf.f_double(
uint num
)

Parameters

num Field number beginning with 1.

Return value

A value of the double type.

See also

Working with DBF files


dbf.f_find

The method returns the number of the field with the specified name.
uint dbf.f_find(
str name
)

Parameters

name The name of the field.

Return value

The number of the field with the specified name or 0 in case of an error.

See also

Working with DBF files


dbf.f_int

Get a numerical value of the int type from the specified field of the current record.
int dbf.f_int(
uint num
)

Parameters

num Field number beginning with 1.

Return value

A number of the int type is returned.

See also

Working with DBF files


dbf.f_logic

Get the value of the logical field from the current record.
uint dbf.f_logic(
uint num
)

Parameters

num Field number beginning with 1.

Return value

Returns the value of the logical field.
$DBF_LFALSE | 0 The value of the logical field is FALSE
$DBF_LTRUE | 1 The value of the logical field is TRUE
$DBF_LUNKNOWN | 2 The value of the logical field is undefined

See also

Working with DBF files


dbf.f_memo

Get the value of the memo field from the current record.
uint dbf.f_memo(
str | val,
uint | num
)

Parameters

val | The string for writing the value.
num | Field number beginning with 1.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.f_name

Get the name of the specified field.
str dbf.f_name(
uint num
)

Parameters

num Field number beginning with 1.

Return value

Returns the name of the specified field.

See also

Working with DBF files


dbf.f_offset

Get the offset of this field.
uint dbf.f_offset(
uint num
)

Parameters

num Field number beginning with 1.

Return value

Returns the offset of this field.

See also

Working with DBF files


dbf.f_ptr

Get the pointer to the contents of this field from the current record.
uint dbf.f_ptr(
uint num
)

Parameters

num Field number beginning with 1.

Return value

Returns the pointer to this field.

See also

Working with DBF files


dbf.f_str

Get the value of the field from the current record as a string.
str dbf.f_str(
str | val,
uint | num
)

Parameters

val | The string for getting the value.
num | Field number beginning with 1.

Return value

The function returns the parameter val.

See also

Working with DBF files


dbf.f_type

Get the field type.
uint dbf.f_type(
uint num
)

Parameters

num Field number beginning with 1.

Return value

Returns the type of this field.
You can use the following macros:
$DBFF_CHAR | = 'C'
$DBFF_DATE | = 'D'
$DBFF_LOGIC | = 'L'
$DBFF_NUMERIC | = 'N'
$DBFF_FLOAT | = 'F'
$DBFF_MEMO | = 'M'

See also

Working with DBF files


dbf.f_width

Get the width of the specified field.
uint dbf.f_width(
uint num
)

Parameters

num Field number beginning with 1.

Return value

Returns the width of the field.

See also

Working with DBF files


dbf.fw_date

Write a date into the specified field of the current record.
uint dbf.fw_date(
datetime | dt,
uint | num
)

Parameters

dt | The structure containing the date.
num | Field number beginning with 1.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.fw_double

Write a numerical value into the specified field of the current record.
uint dbf.fw_double(
double | dval,
uint | num
)

Parameters

dval | The number being written.
num | Field number beginning with 1.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.fw_int

Write a value of the int type into the specified field of the current record.
uint dbf.fw_int(
int | ival,
uint | num
)

Parameters

ival | The number being written.
num | Field number beginning with 1.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.fw_logic

Write a logical value into the specified field of the current record.
uint dbf.fw_logic(
uint | val,
uint | num
)

Parameters

val | Number 1 or 0.
num | Field number beginning with 1.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.fw_memo

Write a value into the specified memo field of the current record.
uint dbf.fw_memo(
str | val,
uint | num
)

Parameters

val | The string being written.
num | Field number beginning with 1.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.fw_str

Write a value into the specified field of the current record.
uint dbf.fw_str(
str | val,
uint | num
)

Parameters

val | The string being written.
num | Field number beginning with 1.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.geterror

Get the error code in case some method is finished unsuccessfully.

uint dbf.geterror()

Return value

The code of the last error is returned.
$ERRDBF_OPEN | Impossible to open the dbf file
$ERRDBF_READ | Impossible to read the dbf file
$ERRDBF_POS | An error of positioning in the file
$ERRDBF_EOF | No current record
$ERRDBF_WRITE | An error of writing in the dbf file
$ERRDBF_FOVER | The length of the string being written is greater than the size of the field
$ERRDBF_TYPE | Incompatible field type
$ERRDBT_OPEN | Impossible to open the dbt file
$ERRDBT_READ | Impossible to read the dbt file
$ERRDBT_POS | An error of positioning in the dbt file
$ERRDBT_WRITE | An error of writing in the dbt file

See also

Working with DBF files


dbf.go

Move to the record with the specified number.
uint dbf.go(
uint num
)

Parameters

num The required record number starting from1.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.isdel

Determine if the current record is marked as deleted.

uint dbf.isdel()

Return value

1 is returned if the current record is marked as deleted.

See also

Working with DBF files


dbf.open

Open a database (a dbf file).
uint dbf.open(
str filename
)

Parameters

filename The name of the dbf file being opened.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.pack

Pack a database. The database is copied into a new file excluding records marked as deleted.
uint dbf.pack(
str filename
)

Parameters

filename The name of the new dbf file.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.recno

Get the number of the current record.

uint dbf.recno()

Return value

The number of the current record or 0 if the record is not defined.

See also

Working with DBF files


dbf.skip

Move forward or backward for the specified number of records.
uint dbf.skip(
int step
)

Parameters

step The step of moving. If it is less than zero, the move will be toward the beginning of the database.

Return value

If error occurs, function returns 0.

See also

Working with DBF files


dbf.top

Move to the first record.

uint dbf.top()

Return value

If error occurs, function returns 0.

See also

Working with DBF files


The handler of copyfiles messages

In the process of copying the function copyfiles generates various messages and you can specify a function to handle them. The function must have the following structure:

func uint yourfunc( uint code, uint left, uint right )

The code parameter is the code of the message and the type of the other two parameters depends on code of the message.
Message code | Description | Second parameter | Third parameter
$COPYN_FOUND | The object for copying is found | The finfo structure about the found file or directory | str with the name of the target file or directory
$COPYN_NEWDIR | A directory is created | str - directory name |
$COPYN_ERRDIR | Cannot create a directory | str - directory name |
$COPYN_ASK | Copy request | finfo - source file | finfo - existing file
$COPYN_ERRFILE | Error while creating a file | str - file name |
$COPYN_NEWFILE | A file is created | str - file name |
$COPYN_BEGIN | Start copying file | finfo - source file | str - target file
$COPYN_PROCESS | A file is being copied | str - target file name | uint - progress of copying
$COPYN_END | Copying is over | finfo - source file | str - target file
$COPYN_ERRWRITE | Error while writing a file | str - file name |

By default, the function must return 0 or $COPYR_NOTHING, but the following variants are possible for some messages.
Message code | Return values
$COPYN_ERRDIR | $COPYR_RETRY - retry $COPYR_BREAK - stop copying
$COPYN_ASK | $COPYR_OVER - overwrite $COPYR_SKIP - skip $COPYR_OVERALL - copy this file and all the rest $COPYR_SKIPALL - skip this file and all the rest $COPYR_BREAK - stop copying
$COPYN_ERRFILE $COPYN_ERRWRITE | $COPYR_RETRY - retry $COPYR_BREAK - stop copying $COPYR_SKIP - skip

You can use the console message handler defcopyproc and specify &defcopyproc as a function for handling messages.

See also

copyfiles


deletedir

Delete a directory.
uint deletedir(
str name
)

Parameters

name The name of the directory being deleted.

Return value

If error occurs, function returns 0.

See also

Function working with files


deletefile

Delete a file.
uint deletefile(
str name
)

Parameters

name The name of the file being deleted.

Return value

If error occurs, function returns 0.

See also

Function working with files


delfiles

Deleting files and directories by mask. Directories are deleted together with all files and subdirectories. Be really careful while using this function. For example, calling

delfiles( "c:\\temp", $FIND_DIR | $FIND_FILE | $FIND_RECURSE )

will delete all files and directories named temp on the disk Ñ: including a search in all directories. In this case temp is considered a mask and since the flag $FIND_RECURSE is specified, the entire disk C: will be searched. If you just need to delete the directory temp with all its subdirectories and files, you should call

delfiles("c:\\temp", $FIND_DIR )

Calling

delfiles( "c:\\temp\\*.tmp", $FIND_FILE )

will delete all files in the directory tmp leaving subdirectories.
delfiles(
str | name,
uint | flag
)

Parameters

name | The name of mask for searching.
flag | The combination of search flags $FIND and $DELF_RO - delete files with the attribute read-only.

See also

Function working with files


destroy

Destroying an object created by the function new.
destroy(
uint ptr
)

Parameters

ptr The pointer to the object to be destroyed.

See also

Other functions


direxist

Checking if a directory exists.
uint direxist(
str name
)

Parameters

name Directory name.

Return value

The function returns 1, if the specified directory exists.

See also

Function working with files


double2str

The function converts double into a string.
str double2str(
str | ret,
str | pattern,
double | val
)

Parameters

ret | A string for obtaining the conversion result. If the string is not empty, data will be appended.
pattern | The conversion pattern string completely coincides with the conversion pattern of the printf and sprintf functions.
val | The convertible value.

Return value

The function returns the parameter ret.

See also

Strings Working with strings


exit

Exit the current program.
exit(
uint code
)

Parameters

code A return code or the results of the work of the program.

See also

Other functions


exitthread

Stop the current thread.
exitthread(
uint code
)

Parameters

code Thread exit code.

See also

Threads


exp

Exponential function.
double exp(
double x
)

Parameters

x A power for the number e.

Return value

The number e raised to the power of x.

See also

Mathematical functions


fabs

The absolute value for double |x|.
double fabs(
double x
)

Parameters

x Floating-point value.

Return value

The absolute value.

See also

Mathematical functions


fastsort

The function sorting strings and numbers.
fastsort(
uint | data,
uint | count,
uint | size,
uint | mode
)

Parameters

data | The pointer to the data to be sorted.
count | The number of items.
size | The size of one item.
mode The type of sorting.
$FSORT_STR | sorting strings
$FSORT_STRIGNORE | sorting strings case-insensitively
$FSORT_UINT | sorting numbers of the uint type.

The items being sorted can be of any type, but the first field in this type must be the str or uint type depending on the type of sorting.

See also

Other functions


fileexist

Checking if a file exists.
uint fileexist(
str name
)

Parameters

name Filename.

Return value

The function returns 1, if the specified file exists.

See also

Function working with files


File search

An object of the ffind type is used to search for files and directories by mask. Before starting the search, you should call the init method.
ffind.init(
str | name,
uint | flag
)

Parameters

name The mask for searching files and directories.
flag The combination of the following flags:
$FIND_DIR | Search only for directories
$FIND_FILE | Search only for files
$FIND_RECURSE | Search subdirectories

After this it is possible to use the initiated object in the foreach loop. The finfo structure will be returned for each found file.

ffind fd
fd.init( "c:\\*.exe", $FIND_FILE | $FIND_RECURSE )
foreach finfo cur,fd
{
   print( "\( cur.fullname )\n" )
}

See also

Function working with files The structure finfo


The structure finfo

The ffind object is used for a file search on the computer. It returns the finfo structure for each found file and the information about the found file is written to it.
type finfo {
str | fullname
str | name
uint | attrib
filetime | lastwrite
uint | sizehi
uint | sizelo
}

Fields

fullname | The name of the file or directory.
name | The name of the file or directory.
attrib | File attributes.
lastwrite | Last modification time.
sizehi | High size uint.
sizelo | Low size uint.

See also

Function working with files getfileinfo File search


firstdayofweek

Get the first day of a week for the user's locale.

uint firstdayofweek()

Return value

Returns the number of the weekday.
0 is Sunday, 1 is Monday...

See also

Function for working with time


float2str

The function converts float into a string.
str float2str(
str | ret,
str | pattern,
float | val
)

Parameters

ret | A string for obtaining the conversion result. If the string is not empty, data will be appended.
pattern | The conversion pattern string completely coincides with the conversion pattern of the printf and sprintf functions.
val | The convertible value.

Return value

The function returns the parameter ret.

See also

Strings Working with strings


floor

Getting the largest integer that is less than or equal to x.
double floor(
double x
)

Parameters

x Floating-point value.

Return value

The closest greatest integer.

See also

Mathematical functions


free

The function deallocates memory.
free(
uint par
)

Parameters

par The pointer to the memory space to be deallocated.

See also

Working with memory


ftimetodatetime

Convert date from filetime into datetime.
datetime ftimetodatetime(
filetime | ft,
datetime | dt,
uint | local
)

Parameters

ft | A structure of the filetime type. Can be taken from the finfo structure.
dt | A datetime structure for getting the result.
local | Specify 1 if you need to take the local time into account.

Return value

The function returns the parameter dt.

See also

Function for working with time


ftp

The given type is used to deal with the FTP protocol.

include : "internet.ge"

func main<main>
{
   ftp myftp

   if myftp.open("mysite.com", "", "", $FTP_PASV | $FTP_ANONYM )
   {
      str list

      if myftp.list( list, "LIST" ) : @list
      myftp.close()
   }
}

See also

Internet


ftp.close

The method terminates the connection on the FTP server.

uint ftp.close()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.command

This methos is used to send the specified command directly to an FTP server. The response from the server can be received with help of the lastresponse method.
uint ftp.command(
str cmd
)

Parameters

cmd The command text.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.createdir

The method creates a new directory on the FTP server.
uint ftp.createdir(
str dir
)

Parameters

dir The name of the directory

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.deldir

This method deletes a directory stored on the FTP server.
uint ftp.deldir(
str dir
)

Parameters

dir The name of the required directory

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.delfile

The method deletes a file stored on the FTP server.
uint ftp.delfile(
str filename
)

Parameters

filename The name of the required file

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.getcurdir

The method retrieves the current directory name from the FTP server.
uint ftp.getcurdir(
str dir
)

Parameters

dir Result string.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.getfile

The method retrieves files from the FTP server.
uint ftp.getfile(
str | filename,
buf | databuf,
uint | flag
)

Parameters

filename | The downloaded file name.
databuf | The received data buffer. Data are not stored on a drive.
flag Additional flags.
$FTP_BINARY | A binary file is downloaded
$FTP_TEXT | A text file is downloaded. This is a default mode.
$FTP_STR | Appends zero to the end of received data.

uint ftp.getfile(
str | srcname,
str | destname,
uint | flag
)

Parameters

srcname | The downloaded file name.
destname | A new file name.
flag Flags.
$FTP_BINARY | A binary file is downloaded
$FTP_TEXT | A text file is downloaded. This is a default mode.
$FTP_CONTINUE | Proceeds with retrieving.
$FTP_SETTIME | Sets the same file times as on the FTP server.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.getsize

Retrieves the file size from the FTP server.
uint ftp.getsize(
str | filename,
uint | psize
)

Parameters

filename | Filename.
psize | A pointer to uint value is used to store the file size.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.gettime

Retrieves last write times for the file on the FTP server.
uint ftp.gettime(
str | name,
datetime | dt
)

Parameters

name | Filename.
dt | The variable of datetime type is used to retrieve the file time.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.lastresponse

The method returns the last response from the FTP server.
str ftp.lastresponse(
str response
)

Parameters

response Result string.

Return value

The function returns the parameter response.

See also

Internet


ftp.list

The method retrieves a list of files and directories from the FTP server.
uint ftp.list(
str | list,
str | cmd
)

Parameters

list Result string.
cmd The command is used to retrieve a list of files.
"LIST" | Returns a list of files in the format of the LIST command.
"NLST" | Returns a list of filenames with no other information.
"MLSD" | Returns a list of files in the format of the MLSD command.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.open

This method establishes an FTP connection with the server. This method must be called before other methods dealing with the FTP server are called.
uint ftp.open(
str | url,
str | user,
str | password,
uint | flag,
uint | notify
)

Parameters

url | The name or address of the FTP server.
user | A user name. If the string is empty, anonymous connections are used.
password | A user password. If the connection is anonymous, your e-mail address is required.
flag Connection flags.
$FTP_ANONYM | Anonymous connection.
$FTP_PASV | Establishes a connection in passive mode.
notify | function is used to receive notification messages. This parameter can be zero.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.putfile

This method is used to upload the required file from the remote host to the FTP server.
uint ftp.putfile(
str | srcname,
str | destname,
uint | flag
)

Parameters

srcname | The name of the required source file.
destname | The name of a file stored on the FTP server.
flag Flags. If the flag of the binary or text mode is not specified, the method makes effort to determine a file type.
$FTP_BINARY | A binary file is uploaded
$FTP_TEXT | A text file is uploaded.
$FTP_CONTINUE | to proceed with file uploading.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.rename

This method renames a file or directory stored on the FTP server.
uint ftp.rename(
str | from,
str | to
)

Parameters

from | The current name of the file or directory.
to | A new name.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.setattrib

This method sets the attributes for the file or the directory.
uint ftp.setattrib(
str | name,
uint | mode
)

Parameters

name | The name of a file or directory.
mode | The attributes for the file.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


ftp.setcurdir

This method sets a new current directory.
uint ftp.setcurdir(
str dirname
)

Parameters

dirname The name of a new directory.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


getch

Waiting for a keystroke in console applications.

uint getch()

Return value

The pressed character.

See also

Other functions


getcurdir

Get the current directory.
str getcurdir(
str ret
)

Parameters

ret The string for getting the result.

Return value

The function returns the parameter ret.

See also

Function working with files


getdateformat

Get date in the specified format.
str getdateformat(
datetime | systime,
str | format,
str | date
)

Parameters

systime | The variable containing date.
format Date format. It can contain the following values:
dd | Day as a number.
ddd | Weekday as an abbriviation.
dddd | The full name of a weekday.
MM | Month as a number.
MMM | Month as an abbreviation.
MMMM | The full name of a month.
yy | The last tow digits in a year.
yyyy | Year.
date | The string for getting the date.

Return value

The function returns the parameter date.

See also

Function for working with time


getdatetime

Get date and time in the current Windows string format.
getdatetime(
datetime | dtime,
str | date,
str | time
)

Parameters

dtime | Datetime structure.
date | The string for getting the date. It can be 0.
time | The string for getting time. It can be 0.

See also

Function for working with time


getdrives

Get the names of available disks.
arr getdrives(
arr ret of str
)

Parameters

ret of str The array for getting disk names.

Return value

The function returns the parameter ret.

See also

Function working with files


getdrivetype

Get the type of a disk.
uint getdrivetype(
str drive
)

Parameters

drive The name of a disk with a closing slash. For example: C:\

Return value

Returns one of the following values:
$DRIVE_UNKNOWN | Unknown type.
$DRIVE_NO_ROOT_DIR | Invalid path to root.
$DRIVE_REMOVABLE | Removable disk.
$DRIVE_FIXED | Fixed disk.
$DRIVE_REMOTE | Network disk.
$DRIVE_CDROM | CD-ROM drive.
$DRIVE_RAMDISK | RAM disk.

See also

Function working with files


getenv

Get a value from the current environment.
str getenv(
str | varname,
str | ret
)

Parameters

varname | Environment variable name.
ret | String for getting the value.

Return value

Variable ret.

See also

Other functions


getfileattrib

Getting file attributes.
uint getfileattrib(
str name
)

Parameters

name Filename.

Return value

The function returns file attributes. It returns 0xFFFFFFFF in case of an error.

See also

Function working with files


getfiledatetime

Get the data and time of the last file modification as strings.
getfiledatetime(
filetime | ftime,
str | date,
str | time
)

Parameters

ftime | A structure of the filetime type. Can be taken from the finfo structure.
date | The string for writing date.
time | The string for writing time.

See also

Function for working with time


getfileinfo

Get information about a file or directory.
uint getfileinfo(
str | name,
finfo | fi
)

Parameters

name | The name of a file or directory.
fi | The structure finfo all the information will be written to.

Return value

It returns 1 if the file is found, it returns 0 otherwise.

See also

Function working with files The structure finfo


getftime

Get the time when the file was last modified.
uint getftime(
uint | handle,
filetime | ft
)

Parameters

handle | File identifier.
ft | The variable for getting the time of a file.

Return value

If error occurs, function returns 0.

See also

Function working with files


getid

The function returns the code of an object (function, method, operator, type) by its name and parameters.
uint getid(
str | name,
collection | params
)

Parameters

name | The name of an object (function, method, operator ). The name of the method must begin with '@'.
params | The types of the required parameters.

Return value

The code (identifier) of an object.

uint getid(
str name
)

Parameters

name The name of an object (function).

Return value

The code (identifier) of an object.

See also

Other functions


getmodulename

Get the file name of the currently running application.
str getmodulename(
str dest
)

Parameters

dest The string for getting the name.

Return value

The function returns the parameter dest.

See also

Function working with files


getmodulepath

Get the path to the running .exe file.
str getmodulepath(
str | dest,
str | subfolder
)

Parameters

dest | Result string.
subfolder | Additional path. This string will be added to the obtained result.

Return value

The function returns the parameter dest.

See also

Function working with files


getsize

Get the size of a file.
uint getsize(
uint handle
)

Parameters

handle File identifier.

Return value

The file size.

See also

Function working with files


gettempdir

Get the temporary directory of the application. When this function is called for the first time, in the temporary directory there will be created a directory named genteeXX, where XX is a unique number for this running application. When the application is closed, the directory will be deleted with all its files.
str gettempdir(
str ret
)

Parameters

ret The string for getting the result.

Return value

The function returns the parameter ret.

See also

Function working with files


gettext

Get the output string of the current text function.

str gettext()

Return value

The output string of the current text function. 0 is returned in case the output is the console.

See also

Other functions


gettimeformat

Get time in the specified format.
str gettimeformat(
datetime | systime,
str | format,
str | time
)

Parameters

systime | The variable containing time.
format Time format. It can contain the following values:
hh | Hours - 12-hour format.
HH | Hours -24-hour format.
mm | Minutes.
ss | Seconds.
tt | Time marker, such as AM or PM.
time | The string for getting time.

Return value

The function returns the parameter time.

See also

Function for working with time


hash.clear

Clear a hash array. The method removes all items from the array.

hash.clear()

See also

Associative arrays - hash tables


hash.create

Create an item with this key. If an item with this key already exists, it will be initiated again. Items are created automatically when they are addressed as array items for the first time - hashname["key string"].
uint hash.create(
str key
)

Parameters

key Key value.

Return value

The pointer to the created item is returned.

See also

Associative arrays - hash tables


hash.del

Delete an item with this key.
uint hash.del(
str key
)

Parameters

key Key value.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Associative arrays - hash tables


hash.find

Find an item with this key.
uint hash.find(
str key
)

Parameters

key Key value.

Return value

Either the pointer to the found item is returned or 0 is returned if there is no item with this key.

See also

Associative arrays - hash tables


hash.ignorecase

Work with the keys of this hash table without taking into account the case of letters. The method must be called before any items are added.

uint hash.ignorecase()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Associative arrays - hash tables


hash.sethashsize

Set the size of the value table for searching for keys. The method must be called before any items are added. The parameter contains the power of two for calculating the size of the table since the number of items must be the power of two. By default, the size of a table is 4096 items.
uint hash.sethashsize(
uint power
)

Parameters

power The power of two for calculating the size of the table.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Associative arrays - hash tables


hex2strl

Convert an integer in the hexadecimal form. The letters will be lowercase.
str hex2strl(
str | par,
uint | val
)

Parameters

par | The string for writing. The converted data will be added to the end of the string.
val | The integer being converted.

Return value

The function returns the parameter par.

See also

Strings


hex2stru

Convert an integer in the hexadecimal form. The letters will be uppercase.
str hex2stru(
str | par,
uint | val
)

Parameters

par | The string for writing. The converted data will be added to the end of the string.
val | The integer being converted.

Return value

The function returns the parameter par.

See also

Strings


http_get

The method sends a GET request to the specified URL and writes data it receives to the databuf buffer.
uint http_get(
str | url,
buf | databuf,
uint | notify,
uint | flag
)

Parameters

url | The URL address data is received from.
databuf | The buffer for getting data.
notify | The function for getting notifications. It can be 0.
flag Flags.
$HTTPF_REDIRECT | If redirection is used, download from the new address.
$HTTPF_STR | Add 0 to databuf after data is received. Use this flag if databuf is a string.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


http_getfile

The method sends a GET request to the specified URL and writes data it receives to the specified file.
uint http_getfile(
str | url,
str | filename,
uint | notify,
uint | flag
)

Parameters

url | The URL address for downloading.
filename | The name of the file for writing.
notify | The function for getting notifications. It can be 0.
flag Flags.
$HTTPF_REDIRECT | If redirection is used, download from the new address.
$HTTPF_CONTINUE | If the file already exists, resume downloading it.
$HTTPF_SETTIME | Set the same time for the file as it is on the server.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


http_head

The method sends a HEAD request to the specified URL address and partially parses the received data.
uint http_head(
str | url,
str | head,
httpinfo | hi
)

Parameters

url | The URL address for getting the header.
head | The string for getting the text of the header.
hi | The variable of the httpinfo type for getting information about the header.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


http_post

The method sends a POST request with the specified string to the specified URL address. It is used to fill out forms automatically.
uint http_post(
str | url,
str | data,
str | result,
uint | notify
)

Parameters

url | The URL address where the data will be sent.
data | The string with the data being sent. Before the data is sent, request strings with parameters should be recoded with the help of the iencoding method.
result | The string for getting a response from the server.
notify | The function for getting notifications. It can be 0.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


httpinfo

The structure is used to get data from an HTTP header. Depending on the header, some fields may be empty.
type httpinfo {
uint | code
datetime | dt
str | size
str | location
}

Fields

code | Message code.
dt | Last modified date.
size | File size.
location | New file location.

See also

Internet


inet_close

This function must be called after the work with the library is finished.

uint inet_close()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


inet_error

The function returns the code of the last error. Codes greater than 10000 are codes of errors in the library WinSock 2 ( ws2_32.dll ).

uint inet_error()

Return value

The code of the last error.
$ERRINET_DLLVERSION | Unsupported version of ws2_32.dll
$ERRINET_HTTPDATA | Not HTTP data is received
$ERRINET_USERBREAK | the process is interrupted y the user
$ERRINET_OPENFILE | Cannot open the file
$ERRINET_WRITEFILE | Cannot write the file

See also

Internet


inet_init

This function must be called before working with the library.

uint inet_init()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


inet_proxy

The functions allows you to specify a proxy server to be used for connecting to the Internet.
uint inet_proxy(
uint | flag,
str | proxyname
)

Parameters

flag The flag specifying for which protocols the specified proxy should be used.
$PROXY_HTTP | Use a proxy server for the HTTP protocol
$PROXY_FTP | Use a proxy server for the FTP protocol
$PROXY_ALL | Use a proxy server for all protocols
$PROXY_EXPLORER | Take the proxy server information from the Internet Explorer settings. In this case the proxyname parameter can be empty.
proxyname The name of the proxy server. It must contain a host name and a port number separated by a colon.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


inet_proxyenable

The function allows you to enable or disable the proxy server for various protocols. Initially, the proxy server must be specified using the inet_proxy function.
uint inet_proxyenable(
uint | flag,
uint | enable
)

Parameters

flag The flag specifying for which protocols the proxy should be enabled or disabled.
$PROXY_HTTP | Proxy server for the HTTP protocol
$PROXY_FTP | Proxy server for the FTP protocol
$PROXY_ALL | Proxy server for all protocols
enable Specify 1 to enable the proxy server or 0 to disable the proxy server.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


inetnotify

This structure is passed to the message handling function as a parameter. Additional parameters take various values depending on the message code.
type inetnotify {
str | url
str | head
uint | param
str | sparam
}

Fields

url | The URL address being processed.
head | The header of the received packet.
param | Additional integer parameter.
sparam | Additional string parameter.

See also

Internet


inetnotify_func

When some functions are called, you can specify a function for handing incoming notifications. In particular, it allows you to show the working process to the user. This handling function must have the following structure.
uint inetnotify_func(
uint | code,
inetnotify | ni
)

Parameters

code Message code.
$NFYINET_ERROR | An error occurred. The code of the error can be got with the help of the inet_error function.
$NFYINET_CONNECT | Server connection.
$NFYINET_SEND | Sending a request.
$NFYINET_POST | Sending data.
$NFYINET_HEAD | Processing the header. ni.param points to httpinfo.
$NFYINET_REDIRECT | Request redirection. ni.sparam contains the new URL.
$NFYINET_GET | Data is received. ni.param contains the total size of all data.
$NFYINET_PUT | Data is sent. ni.param contains the total size of all data.
$NFYFTP_RESPONSE | Response of the FTP server. The field ni.head contains it.
$NFYFTP_SENDCMD | Sending a command to the FTP server. The field ni.head contains it.
$NFYFTP_NOTPASV | Passive mode with the FTP server is unavailable.
$NFYINET_END | The connection is terminated.
ni The variable of the inetnotify type with additional data.

Return value

The function must return 1 to continue working and 0 otherwise.

See also

Internet


ini.delkey

Delete an entry.
ini.delkey(
str | section,
str | key
)

Parameters

section | Section name.
key | The name of the entry being deleted.

See also

Working with INI files


ini.delsection

Delete a section.
ini.delsection(
str section
)

Parameters

section The name of the section being deleted.

See also

Working with INI files


ini.getnum

Get the numerical value of an entry.
uint ini.getnum(
str | section,
str | key,
uint | defval
)

Parameters

section | Section name.
key | Key name.
defval | The value to be assigned if the entry is not found.

Return value

The numerical value of the key.

See also

Working with INI files


ini.getvalue

Get the value of an entry.
uint ini.getvalue(
str | section,
str | key,
str | value,
str | defval
)

Parameters

section | Section name.
key | Key name.
value | The string for getting the value.
defval | The value to be assigned if the entry is not found.

Return value

Returns 1 if the entry is found and 0 otherwise.

See also

Working with INI files


ini.keys

Get the list of entries in this section. All entries will be written into an array of strings.
arr ini.keys(
str | section,
arr | ret of str
)

Parameters

section | Section name.
ret of str | The array of strings the names of entries will be written to.

Return value

The function returns the parameter ret.

See also

Working with INI files


ini.read

Read data from a file.
ini.read(
str filename
)

Parameters

filename The name of the ini file.

See also

Working with INI files


ini.sections

Get the list of sections. All sections will be written into an array of strings.
arr ini.sections(
arr ret of str
)

Parameters

ret of str The array of strings the names of sections will be written to.

Return value

The function returns the parameter ret.

See also

Working with INI files


ini.setnum

Write the numerical value of an entry.
ini.setnum(
str | section,
str | key,
uint | value
)

Parameters

section | Section name.
key | Key name.
value | The value of the entry being written.

See also

Working with INI files


ini.setvalue

Write the value of an entry.
ini.setvalue(
str | section,
str | key,
str | value
)

Parameters

section | Section name.
key | Key name.
value | The value of the entry being written.

See also

Working with INI files


ini.write

Save data into an ini file.
uint ini.write(
str filename
)

Parameters

filename The name of the ini file.

Return value

Returns the size of the written data.

See also

Working with INI files


inigetval

Get the value of an entry from an ini file.
str inigetval(
str | ininame,
str | section,
str | key,
str | value,
str | defval
)

Parameters

ininame | The name of the ini file.
section | Section name.
key | Key name.
value | The string for writing the value.
defval | The value that will be inserted in case of an error or if there is not such an entry.

Return value

The function returns the parameter value.

See also

Working with INI files


inisetval

Write the value of an entry into an ini file.
uint inisetval(
str | ininame,
str | section,
str | key,
str | value
)

Parameters

ininame | The name of the ini file.
section | Section name.
key | Key name.
value | The value of the entry being written.

Return value

If error occurs, function returns 0.

See also

Working with INI files


int2str

The function converts int into a string.
str int2str(
str | ret,
str | pattern,
int | val
)

Parameters

ret | A string for obtaining the conversion result. If the string is not empty, data will be appended.
pattern | The conversion pattern string completely coincides with the conversion pattern of the printf and sprintf functions.
val | The convertible value.

Return value

The function returns the parameter ret.

See also

Strings Working with strings


isequalfiles

Compare two files.
uint isequalfiles(
str | left,
str | right
)

Parameters

left | The name of the first file to be compared.
right | The name of the second file to be compared.

Return value

The function returns 1 if the files are equal, otherwise it returns 0.

See also

Function working with files


isleapyear

Leap year check.
uint isleapyear(
uint year
)

Parameters

year The year being checked.

Return value

Returns 1 if the year is a leap one and 0 otherwise.

See also

Function for working with time


ln

Natural logarithm.
double ln(
double x
)

Parameters

x Floating-point value.

Return value

The natural logarithm ln( x ).

See also

Mathematical functions


localeuser

Get the identifier of the user's locale. The function localesystem returns the locale identifier for the system.

uint localesystem()

uint localeuser()

Return value

The locale identifier.

See also

Other functions


log

Common logarithm.
double log(
double x
)

Parameters

x Floating-point value.

Return value

The common logarithm log10( x ).

See also

Mathematical functions


long2str

The function converts long into a string.
str long2str(
str | ret,
str | pattern,
long | val
)

Parameters

ret | A string for obtaining the conversion result. If the string is not empty, data will be appended.
pattern | The conversion pattern string completely coincides with the conversion pattern of the printf and sprintf functions.
val | The convertible value.

Return value

The function returns the parameter ret.

See also

Strings Working with strings


max

Determines the largest of two numbers.
uint max(
uint | left,
uint | right
)

Parameters

left | The first compared number of the uint type.
right | The second compared number of the uint type.

Return value

The function returns the largest of two numbers.

See also

Other functions


mcmp

The function compares two memory spaces.
int mcmp(
uint | left,
uint | right,
uint | size
)

Parameters

left | The pointer to the first memory space.
right | The pointer to the second memory space.
size | The size being compared.

Return value

0 | The spaces are equal.
<0 | The first space is smaller.
>0 | The second space is smaller.

See also

Working with memory


mcopy

The function copies data from one memory space into another.
uint mcopy(
uint | dest,
uint | src,
uint | size
)

Parameters

dest | The pointer for the data being copied.
src | The pointer to the source of the data being copied.
size | The size of the data being copied.

Return value

The pointer to the copied data.

See also

Working with memory


min

Determines the smallest of two numbers.
uint min(
uint | left,
uint | right
)

Parameters

left | The first compared number of the uint type.
right | The second compared number of the uint type.

Return value

The function returns the smallest of two numbers.

See also

Other functions


mlen

Determines the number of bytes till zero.
uint mlen(
uint dest
)

Parameters

dest The pointer to a memory space.

Return value

The number of bytes till the zero character.

See also

Working with memory


mmove

The function moves the specified space. The initial and final data may overlap.
mmove(
uint | dest,
uint | src,
uint | size
)

Parameters

dest | The pointer for the data being copied.
src | The pointer to the source of the data being copied.
size | The size of the data being copied.

See also

Working with memory


modf

Splitting into whole and fractional parts.
double modf(
double | x,
uint | y
)

Parameters

x | Floating-point value.
y | A pointer to double for getting the whole part.

Return value

The fractional part of x.

See also

Mathematical functions


movefile

Rename, move a file or a directory.
uint movefile(
str | name,
str | newname
)

Parameters

name | The name of an existing file or a directory.
newname | A new file name and path.

Return value

If error occurs, function returns 0.

See also

Function working with files


mzero

The functions zeroes the memory space.
uint mzero(
uint | dest,
uint | size
)

Parameters

dest | The pointer to a memory space.
size | The size of the data being zeroed.

Return value

The pointer to the zeroed data.

See also

Working with memory


nameofmonth

Get the name of a month in the user's language.
str nameofmonth(
str | ret,
uint | month
)

Parameters

ret | Result string.
month | The number of the month from 1.

Return value

The function returns the parameter ret.

See also

Function for working with time


new

The function creates an object of the specified type.
uint new(
uint id
)

Parameters

id The identifier or the name of a type.

Return value

The function returns the pointer to the created object.

See also

Other functions


odbc.connect

You can connect to a database using a string connection or a DSN name.

The method is called in order to connect to the database with the help of the string connection. Use The ODBC connection string for this purpose, that contains a driver type, a database name and some additional parameters. The example below shows a type of the string connected to the SQL server: "Driver={SQL Server};Server=MSQLSERVER;Database=mydatabase;Trusted_Connection=yes;"
uint odbc.connect(
str connectstr
)

Parameters

connectstr Connection string.

Return value

Returns 1 if the connection is successful; otherwise, returns 0.

This method is used to connect to the database through the previously defined connection (the DSN name).
uint odbc.connect(
str | dsn,
str | user,
str | psw
)

Parameters

dsn | Name of a previously defined connection - DSN.
user | User name.
psw | User password.

Return value

Returns 1 if the connection is successful; otherwise, returns 0.

See also

Data Access Using ODBC


odbc.disconnect

Disconnects from a database.

odbc.disconnect()

See also

Data Access Using ODBC


odbc.geterror

Gets the message if the last error occured while connecting to the database.
uint odbc.geterror(
str | state,
str | message
)

Parameters

state | This string will contain the current state.
message | This string will contain an error message.

Return value

Returns the last error code.

See also

Data Access Using ODBC


odbc.newquery

Creates a new ODBC query for the particular ODBC connection. Several queries are likely to be created for one connection. Queries are created inside the ODBC object and deleted in case of its deletion.

odbcquery odbc.newquery()

Return value

A new ODBC query.

See also

Data Access Using ODBC


odbcfield.getbuf

Gets the field's value as a value of the buf type. This method is applied for fields with binary data.
buf odbcfield.getbuf(
buf dest
)

Parameters

dest Result object.

Return value

Returns the object that includes data obtained.


odbcfield.getdatetime

Gets the field's value as a date and time value. This method is applied for fields that contain date and/or time.
datetime odbcfield.getdatetime(
datetime dt
)

Parameters

dt Result object.

Return value

Returns date and time.


odbcfield.getdouble

Gets the field's value as a floating-point number. This method is applied for fields that contain floating-point numbers.

double odbcfield.getdouble()

Return value

Returns the field's value.


odbcfield.getindex

Gets the field index number.

uint odbcfield.getindex()

Return value

Field index number.


odbcfield.getint

Gets the field's value as an integer. This method is applied for fields that contain integers (the storage size is up to 4 bytes).

int odbcfield.getint()

Return value

Returns the field's value.


odbcfield.getlong

Gets the field's value as an integer. This method is applied for fields that contain long integers (8 bytes).

long odbcfield.getlong()

Return value

Returns the field's value.


odbcfield.getname

Gets a field's name.
str odbcfield.getname(
str result
)

Parameters

result Result string

Return value

Field's name.


odbcfield.getnumeric

Gets the field's value as a fixed point number. This method is applied for fields that contain fixed point numbers. The structure is applied for data of this type, as follows:
type numeric {
long val
uint scale
}
The val field contains the integer representation of a number, and the scale field indicates how many times val is divided by 10 in order to get a real number (a precision number).
numeric odbcfield.getnumeric(
numeric num
)

Parameters

num Result structure.

Return value

Returns the structure with the number obtained.


odbcfield.getstr

Gets the field's value as a string. This method is applied for fields that contain a string, a date, time and numeric fields.
str odbcfield.getstr(
str dest
)

Parameters

dest Result string.

Return value

Returns the object that includes the string obtained.


odbcfield.gettype

Gets a type of the field's value. Returns the identifier of one of the following types: buf, str, int, long, numeric, double, datetime.

uint odbcfield.gettype()

Return value

Type identifier.


odbcfield.getuint

Gets the field's value as an unsigned integer. This method is applied for fields that contain integers (the storage size is up to 4 bytes).

uint odbcfield.getuint()

Return value

Returns the field's value.


odbcfield.getulong

Gets the field's value as an unsigned integer. This method is applied for fields that contain long integers (8 bytes).

ulong odbcfield.getulong()

Return value

Returns the field's value.


odbcfield.isnull

Determines if the field contains the NULL value.

uint odbcfield.isnull()

Return value

Returns nonzero, if the field contains the NULL value; otherwise, it returns zero.


odbcquery.active

Checks whether a result set exists after the SQL query execution. If the SQL query of the "SELECT ..." type has been executed successfully, this method returns nonzero.

uint odbcquery.active()

Return value

Returns nonzero if a result set exists.

See also

Data Access Using ODBC


odbcquery.close

Closes a result set. This method is used after the SQL query of the SELECT... type has been executed. While calling the odbcquery.run method, the given method is automatically called.

odbcquery.close()

See also

Data Access Using ODBC


odbcquery.fieldbyname

Finds a field based on a specified field name.

field odbcquery.fieldbyname()

Return value

Returns the field or zero if fields with the same name are not found.

See also

Data Access Using ODBC


odbcquery.first

Moves the cursor to the first record in the result set.

uint odbcquery.first()

Return value

If the cursor has been moved, it returns nonzero.

See also

Data Access Using ODBC


odbcquery.geterror

Gets the message if the last error occured while running the SQL query.
uint odbcquery.geterror(
str | state,
str | message
)

Parameters

state | This string will contain the current state.
message | This string will contain an error message.

Return value

Returns the last error code.

See also

Data Access Using ODBC


odbcquery.getrecordcount

Gets the total number of records in a result set when the SQL query of the "SELECT ..." type has been executed.

int odbcquery.getrecordcount()

Return value

Returns the the total number of records; if the total number of records is not determined, it returns -1.

See also

Data Access Using ODBC


odbcquery.last

Moves the cursor to the last record in the result set.

uint odbcquery.last()

Return value

If the cursor has been moved, it returns nonzero.

See also

Data Access Using ODBC


odbcquery.moveby

Moves the cursor by the specified number of records relative to its current position in the result set.
uint odbcquery.moveby(
int off
)

Parameters

off Indicates the number of records to move the cursor. If the number is negative, the cursor is moved backward.

Return value

If the cursor has been moved, it returns nonzero.

See also

Data Access Using ODBC


odbcquery.next

Moves the cursor to the next record in the result set.

uint odbcquery.next()

Return value

If the cursor has been moved, it returns nonzero; otherwise, it returns zero. If the current record is the last, it returns zero.

See also

Data Access Using ODBC


odbcquery.prior

Moves the cursor to the prior record in the result set.

uint odbcquery.prior()

Return value

If the cursor has been moved, it returns nonzero.

See also

Data Access Using ODBC


odbcquery.run

Runs a SQL query.
uint odbcquery.run(
str sqlstr
)

Parameters

sqlstr String that contains the SQL query.

Return value

If the execution is successful, it returns nonzero.

See also

Data Access Using ODBC


odbcquery.settimeout

Sets the number of seconds to wait for a SQL query execution.
odbcquery.settimeout(
uint timeout
)

Parameters

timeout The number of seconds to wait for a SQL query execution. If it is equal to 0, then there is no timeout.

See also

Data Access Using ODBC


oleobj.createobj

The method creates a new COM object
uint oleobj.createobj(
str | name,
str | mashine
)

Parameters

name | An object name, or the string representation of an object identifier - "{...}".
mashine | A computer name where the required object is created; if the current string is empty, the object is created in the current computer.

Return value

If error occurs, method returns zero, otherwise returns 1.

Example

   oleobj excapp
   excapp.createobj( "Excel.Application", "" )
      //is equal to excapp.createobj( "{00024500-0000-0000-C000-000000000046}", "" )
   excapp.flgs = $FOLEOBJ_INT
   excapp~Visible = 1

See also

Working with COM Object


oleobj.getres

This method is applied for getting an error code or a warning; the code is the C type of HRESULT.

uint oleobj.getres()

Return value

Returns the HRESULT code of the last COM object operation.

See also

Working with COM Object


oleobj.iserr

The method enables you to define whether an error occures within the last COM object operation

uint oleobj.iserr()

Return value

If error occurs, method returns 1, otherwise returns zero

See also

Working with COM Object


oleobj.release

The method deletes the bond between the variable and the COM object and releases the COM object.

oleobj.release()

See also

Working with COM Object


open

Open a file.
uint open(
str | name,
uint | flag
)

Parameters

name The name of the file to be opened.
flag The following flags can be used.
$OP_READONLY | Open only for reading
$OP_EXCLUSIVE | Open in the exclusive mode
$OP_CREATE | Create the file
$OP_ALWAYS | Create the file only if it does not exist

Return value

The function returns the file identifier. It returns 0 in case of an error.

See also

Function working with files


Initializing the search pattern

The spattern type is used to search through the buffer for another one. Before search start-up, call the spattern.init method in order to initialize the search pattern. Then do a search of the specified pattern with the help of spattern.search.
spattern spattern.init(
buf | pattern,
uint | flag
)

Parameters

pattern | Search (pattern) buffer.
flag | Search-Flags. Zero must be indicated.

Return value

Returns the object which method has been called.

See also

Buffer - binary data


Initializing the search pattern

The spattern type is used to search through the string for another string. Before search start-up, call the spattern.init method in order to initialize the search pattern. Then do a search of the specified pattern with the help of spattern.search.
spattern spattern.init(
str | pattern,
uint | flag
)

Parameters

pattern Search string (pattern).
flag Search-flags.
$QS_IGNCASE | Case-insensitive.
$QS_WORD | Search the whole word only.
$QS_BEGINWORD | Search words which start with the specified pattern.

Return value

Returns the object which method has been called.

See also

Strings


pow

Raising to the power.
double pow(
double | x,
double | y
)

Parameters

x | A base.
y | A power.

Return value

Raising x to the power of y.

See also

Mathematical functions


print

Print a string into the current flow data output.
print(
str par
)

Parameters

par Output string.

See also

Strings


process

Start a process.
uint process(
str | cmdline,
str | workdir,
uint | result
)

Parameters

cmdline | The command line.
workdir | The working directory. It can be 0.
result | The pointer to uint for getting the result. If 0, the function will not wait until the process finishes its work.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Other functions


read

Reading a file.
uint read(
uint | handle,
buf | rbuf,
uint | size
)

Parameters

handle | File identifier.
rbuf | The buffer where data will be read. Reading is carried out by adding data to the buffer. It means that read data will be added to those already existing in the buffer.
size | The size of the data being read.

Return value

The function returns the size of the read data.

See also

Function working with files


regdelkey

Delete a key.
uint regdelkey(
uint | root,
str | subkey
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | The name of the registry key being deleted.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Working with the Registry


regdelvalue

Delete the value of a key.
uint regdelvalue(
uint | root,
str | subkey,
str | valname
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | The name of the value being deleted.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Working with the Registry


reggetmultistr

Get the value of a registry key of the $REG_MULTISZ type into a string array.
arr reggetmultistr(
uint | root,
str | subkey,
str | valname,
arr | val of str
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | A name of the specified key value.
val of str | The array strings are written to.

Return value

The function returns the parameter val.

See also

Working with the Registry


reggetnum

Get the numerical value of a registry key.
uint reggetnumdef(
uint | root,
str | subkey,
str | valname,
uint | defval
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | A name of the specified key value.
defval | The default number in case there is no value.

uint reggetnum(
uint | root,
str | subkey,
str | valname
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | A name of the specified key value.

Return value

A numerical value is returned.

See also

Working with the Registry


regkeys

Get the list of subkeys of this key.
uint regkeys(
uint | root,
str | subkey,
arr | ret of str
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
ret of str | The array the names of the keys will be written to.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Working with the Registry


regsetmultistr

Write an array of strings as a value of a registry key of the $REG_MULTISZ type. If there is no key, it will be created.
uint regsetmultistr(
uint | root,
str | subkey,
str | valname,
arr | value of str,
arr | ret of str
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | The name of the value being written.
value of str | The arrays of strings being written.
ret of str | The array of strings all the created keys will be written to. It can be 0.

Return value

0 | no data has been written
1 | the value of the key was created during the writing process
2 | data is written into the existing value

See also

Working with the Registry


regsetnum

Write a number as a registry key value. If there is no key, it will be created.
uint regsetnum(
uint | root,
str | subkey,
str | valname,
uint | value,
arr | ret of str
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | The name of the value being written.
value | The number being written.
ret of str | The array of strings all the created keys will be written to. It can be 0.

Return value

0 | no data has been written
1 | the value of the key was created during the writing process
2 | data is written into the existing value

See also

Working with the Registry


regvaltype

Get the type of a registry key value.
uint regvaltype(
uint | root,
str | subkey,
str | valname
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | The name of the key value the type of which is being determined.

Return value

0 is returned if the type is not determined or there is no such value. Besides, the following values are possible:
$REG_SZ | string
$REG_EXPAND_SZ | string with environment variables
$REG_BINARY | binary data
$REG_DWORD | number
$REG_MULTI_SZ | string sequence

See also

Working with the Registry


regvalues

Get the list of the names of values in this key.
uint regvalues(
uint | root,
str | subkey,
arr | ret of str
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
ret of str | The array the names of values in the keys will be written to.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Working with the Registry


regverify

Check if there is a certain key in the registry and create it if it is not there.
uint regverify(
uint | root,
str | subkey,
arr | ret of str
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | The name of the registry key being checked.
ret of str | The array of strings all the created keys will be written to. It can be 0.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Working with the Registry


Data search

The spattern type is used to search through the buffer for another one. Before search start-up, call the spattern.init method in order to initialize the search pattern.
uint spattern.search(
uint | src,
uint | size
)

Parameters

src | Pointer to the beginning of data in order to start a search.
size | Data size.

Return value

The offset of the found fragment. If the offset is equal to size, no fragment is found.

uint spattern.search(
buf | src,
uint | offset
)

Parameters

src | Buffer where the specified data (search pattern) will be searched.
offset | Offset where the search must be started or proceeded.

Return value

The offset of the found fragment. If the offset is equal to the buffer size, no fragment is found.

spattern sp
buf pattern src
...
sp.init( pattern, 0 )
if sp.search( src, 0 ) < *src
{
   print("The pattern has been found in src buffer!\n")
}

See also

Buffer - binary data


String search

The spattern type is used to search through the string for another string. Before search start-up, call the spattern.init method in order to initialize the search pattern.
uint spattern.search(
str | src,
uint | offset
)

Parameters

src | String where the specified string will be searched (search pattern).
offset | Offset where the search must be started or proceeded.

Return value

The offset of the found fragment. If the offset is equal to string size,no fragment is found.

spattern sp
str src = "This is a test string."
...
sp.init( "test", 0 )
if sp.search( src, 0 ) < *src
{
   print("The pattern has been found in the source string!\n")
}

See also

Strings


sendstr

Type a string on the keyboard.
uint sendstr(
str data
)

Parameters

data The string to be typed on the keyboard.

Return value

If error occurs, function returns 0.

See also

Keyboard


sendvkey

Press a key alone or together with Shift, Ctrl, Alt.
uint sendvkey(
ushort | vkey,
uint | flag
)

Parameters

vkey Virtual key code.
flag Flags for pressing additional keys.
$SVK_SHIFT | Shift is pressed.
$SVK_ALT | Alt is pressed.
$SVK_CONTROL | Ctrl is pressed.

Return value

If error occurs, function returns 0.

See also

Keyboard


setattribnormal

Setting the attribute $FILE_ATTRIBUTE_NORMAL.
uint setattribnormal(
str name
)

Parameters

name Filename.

Return value

If error occurs, function returns 0.

See also

Function working with files


setcurdir

Set the current directory.
uint setcurdir(
str dirname
)

Parameters

dirname The name of the new current directory.

Return value

If error occurs, function returns 0.

See also

Function working with files


setenv

The function adds new environment variable or modifies the value of the existing environment variable. New values will be valid only in the current process.
str setenv(
str | varname,
str | varvalue
)

Parameters

varname | Environment variable name.
varvalue | A new value of the environment variable.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Other functions


setfileattrib

Set file attributes.
uint setfileattrib(
str | name,
uint | attrib
)

Parameters

name Filename.
attrib File attributes.
$FILE_ATTRIBUTE_READONLY | read-only
$FILE_ATTRIBUTE_HIDDEN | hidden
$FILE_ATTRIBUTE_SYSTEM | system
$FILE_ATTRIBUTE_ARCHIVE | archive
$FILE_ATTRIBUTE_NORMAL | normal

Return value

If error occurs, function returns 0.

See also

Function working with files


setftime

Set time for a file.
uint setftime(
uint | handle,
filetime | ft
)

Parameters

handle | File identifier.
ft | New time for the file.

Return value

If error occurs, function returns 0.

See also

Function working with files


setidvm

The function fills a idvm structure.
type idvm {
uint | id
uint | vm
}

Fields

id | Function identifier.
vm | Virtual machine identifier.

Function description
idvm setidvm(
idvm | iv,
uint | idfunc
)

Parameters

iv | A structure of the idvm type.
idfunc | Function identifier.

Return value

The function returns the parameter iv.

See also

Other functions


setpos

Set the current position in the file.
uint setpos(
uint | handle,
int | offset,
uint | mode
)

Parameters

handle | File identifier.
offset | Position offset.
mode The type of moving the position.
$FILE_BEGIN | from the beginning of the file
$FILE_CURRENT | from the current position
$FILE_END | from the end of the file

Return value

The function returns the current position in the file.

See also

Function working with files


shell

Launch or open a file in the associated application.
shell(
str name
)

Parameters

name Filename.

See also

Other functions


sin

Calculating the sine.
double sin(
double x
)

Parameters

x An angle in radians.

Return value

The sine of x.

See also

Mathematical functions


sizeof

The function returns the size of the specified type.
uint sizeof(
uint id
)

Parameters

id The name of the type. The compiler changes the name of the type to its identifier.

Return value

The type size in bytes.

See also

Other functions


sleep

Pause the current thread for the specified time.
sleep(
uint msec
)

Parameters

msec The time for pausing the thread in milliseconds.

See also

Threads


socket

The structure is used to work with proxies.
type socket {
str | host
ushort | port
uint | socket
uint | flag
}

Fields

host | Host name.
port | Port number.
socket | Open socket identifier.
flag Additional flags.
$SOCKF_PROXY The socket is opened via a proxy server.

See also

Internet


socket.close

Close a socket.

uint socket.close()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


socket.connect

The method creates a socket and establishes a connection to the host and port specified in the host and port fields of the socket structure.

uint socket.connect()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


socket.isproxy

This method can be used to determine if a socket is connected via a proxy server or not.

uint socket.isproxy()

Return value

1 is returned if the socket is connected via a proxy server and 0 is returned otherwise.

See also

Internet


socket.recv

The method gets a packet from the connected server.
uint socket.recv(
buf data
)

Parameters

data The buffer for writing data. The received packet will be added to the data already existing in the buffer.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


socket.send

The method sends a request to the connected server.
uint socket.send(
str data
)

Parameters

data Request string.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


socket.urlconnect

The method is used to create and connect a socket to the specified Internet address. If a proxy server is enabled, the connection will be established via it.
uint socket.urlconnect(
str | url,
str | host,
str | path
)

Parameters

url | The URL address for connecting.
host | The string for getting the host from the URL.
path | The string for getting the relative path from the URL.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


sort

The function for sorting data.
sort(
uint | data,
uint | count,
uint | size,
uint | iv
)

Parameters

data | The pointer to the data to be sorted.
count | The number of items.
size | The size of one item.
iv | The idvm structure that must be filled with the help of the setidvm function. As the function, you must specify the object comparison function that has two parameters and returns int. It must return a value less than 0, equal to 0, or greater than 0 depending on whether the first parameter is less than, equal to or greater than the second.

See also

Other functions


sqrt

Square root.
double sqrt(
double x
)

Parameters

x A positive floating-point value.

Return value

The square root of x.

See also

Mathematical functions


stack.clear

Clear a stack.

stack.clear()

See also

Stack


stack.pop

The method extracts a number from a stack. The stack must be described as a stack of uint or int.

uint stack.popval()

Return value

The number extracted from the stack is returned.

The method extracts a string from a stack. The stack must be described as a stack of str.
str stack.pop(
str val
)

Parameters

val Result string.

Return value

The function returns the parameter val.

The method deletes the top item from a stack.

uint stack.pop()

Return value

The pointer to the new top item.

See also

Stack


stack.push

The method adds a number to a stack. The stack must be described as a stack of uint or int.
uint stack.push(
uint val
)

Parameters

val Added number.

Return value

The added value is returned.

The method adds a string to a stack. The stack must be described as a stack of str.
str stack.push(
str val
)

Parameters

val Added string.

Return value

The added string is returned.

Add an item to a stack.

uint stack.push()

Return value

The pointer to the added item.

See also

Stack


stack.top

Get the top item in a stack.

uint stack.top()

Return value

The pointer to the top item.

See also

Stack


str2double

The function converts a string into double.
double str2double(
str val
)

Parameters

val Ñòðîêà êîíâåðòàöèè.

Return value

Çíà÷åíèå òèïà double.

See also

Strings Working with strings


str2int

The function converts a string into int or uint.
int str2int(
str val
)

Parameters

val The string for conversion. If the string starts from 0x, the integer is considered to be in the hexadecimal form.

Return value

A value of the int type.

See also

Strings Working with strings


str2long

The function converts a string into long.
long str2long(
str val
)

Parameters

val The string for conversion.

Return value

A value of the long type.

See also

Strings Working with strings


str.append

Add data to a string.
str str.append(
uint | src,
uint | size
)

Parameters

src | The pointer to the data to be added.
size | The size of the data being added.

Return value

Returns the object which method has been called.

See also

Strings


str.appendch

Adding a character to a string.
str str.appendch(
uint ch
)

Parameters

ch Äîáàâëÿåìûé ñèìâîë.

Return value

Returns the object which method has been called.

See also

Strings


str.char2oem

Convert from the Windows encoding into the DOS encoding">

str str.char2oem()

Return value

Returns the object which method has been called.

See also

Strings


str.clear

Clear a string.

str str.clear()

Return value

Returns the object which method has been called.

See also

Strings


str.copy

The method copies data into a string.
str str.copy(
uint | src,
uint | size
)

Parameters

src | The pointer to the data being copied. If data does not end in a zero, it will be added automatically.
size | The size of the data being copied.

str str.copy(
uint src
)

Parameters

src The pointer to the data being copied. All data to the zero character will be copied.

Return value

Returns the object which method has been called.

See also

Strings


str.crc

The method calculates the checksum of a string.

uint str.crc()

Return value

The string checksum is returned.

See also

Strings


str.del

Delete a substring.
str str.del(
uint | off,
uint | size
)

Parameters

off | The offset of the substring being deleted.
size | The size of the substring being deleted.

Return value

Returns the object which method has been called.

See also

Strings


str.eqlen

Compare a string with the specified data or string. The comparison is carried out only at the length of the string the method is called for.
uint str.eqlenign(
uint src
)

Parameters

src The pointer to the data to be compared. The comparison is case-insensitive.

uint str.eqlenign(
str src
)

Parameters

src The pointer to the string to be compared. The comparison is case-insensitive.

uint str.eqlen(
str src
)

Parameters

src The pointer to the string to be compared.

uint str.eqlen(
uint src
)

Parameters

src The pointer to the data to be compared.

Return value

Returns 1 if there is an equality and 0 otherwise.

See also

Strings


str.faddname

Add a file name or a directory to a path.
str str.faddname(
str name
)

Parameters

name The name being added. It will be added after '\'.

Return value

Returns the object which method has been called.

See also

Strings


str.fappendslash

Add '\' to the end of a string if it is not there.

str str.fappendslash()

Return value

Returns the object which method has been called.

See also

Strings


str.fdelslash

Delete the final '\' if it is there.

str str.fdelslash()

Return value

Returns the object which method has been called.

See also

Strings


str.ffullname

Get the full path and name of a file.
str str.ffullname(
str name
)

Parameters

name Initial file name.

Return value

Returns the object which method has been called.

See also

Strings


str.fgetdir

Remove the final name of a file or directory.
str str.fgetdir(
str name
)

Parameters

name Initial path.

Return value

Returns the object which method has been called.

See also

Strings


str.fgetdrive

Get the network name (\\computer\share\) or the name of a disk (c:\).
str str.fgetdrive(
str name
)

Parameters

name Initial file name.

Return value

Returns the object which method has been called.

See also

Strings


str.fgetparts

Get the directory, name and extensions of a file.
str.fgetparts(
str | dir,
str | fname,
str | ext
)

Parameters

dir | The string for getting the directory. It can be 0.
fname | The string for getting the file name. It can be 0.
ext | The string for getting the file extension. It can be 0.

See also

Strings


str.fill

Fill a string to the left or to the right.
str str.fill(
str | val,
uint | count,
uint | flag
)

Parameters

val | The string that will be filled.
count | The number of additions.
flag Flags.
$FILL_LEFT | Add to the left.
$FILL_LEN | The count parameter contains the final string size.
$FILL_CUT | Cut if longer than the final size. Used together with FILL_LEN.

Return value

Returns the object which method has been called.

See also

Strings


str.fillspacel

Fill a string with spaces to the left or to the right. fillspacel adds spaces to the left while fillspacer adds spaces to the right.
str str.fillspacer(
uint len
)

str str.fillspacel(
uint len
)

Parameters

len Final string size.

Return value

Returns the object which method has been called.

See also

Strings


str.findch

Find a character in a string.
uint str.findch(
uint | ch,
uint | right
)

Parameters

ch | Search character.
right | If it equals 1, the search will be carried out from the end of the string.

Return value

The offset of the character if it is found. If the character is not found, the length of the string is returned.

See also

Strings


str.findchfrom

Find a character in a string starting from the specified offset.
uint str.findchfrom(
uint | ch,
uint | offset
)

Parameters

ch | Search character.
offset | The offset to start searching from.

Return value

The offset of the character if it is found. If the character is not found, the length of the string is returned.

See also

Strings


str.findchnum

Find character number i in a string.
uint str.findchnum(
uint | ch,
uint | num
)

Parameters

ch | Search character.
num | The number of the character starting from 1.

Return value

The offset of the character if it is found. If the character is not found, the length of the string is returned.

See also

Strings


str.fnameext

Get the name of the last file or directory from the full path.
str str.fnameext(
str name
)

Parameters

name Initial path.

Return value

Returns the object which method has been called.

See also

Strings


str.fsetext

Get the file name with a new extension.
str str.fsetext(
str | name,
str | ext
)

Parameters

name | Initial file name.
ext | File extension.

Return value

Returns the object which method has been called.

See also

Strings


str.fsetname

Modify the current filename.
str str.fsetname(
str name
)

Parameters

name A new filename.

Return value

Returns the object which method has been called.

See also

Strings


str.fsetparts

Compound the name of a file out of the path, name and extension. This function can be also used to modify the path, name or extension of a file. In this case if some component equals 0, it is left unmodified.
str str.fsetparts(
str | dir,
str | fname,
str | ext
)

Parameters

dir | Directory.
fname | Filename.
ext | File extension.

Return value

Returns the object which method has been called.

See also

Strings


str.fsplit

Split the full path into the name of the final file or directory and the rest of the path.
str.fsplit(
str | dir,
str | name
)

Parameters

dir | The string for getting the directory.
name | The string for getting the name of a file or directory.

See also

Strings


str.fwildcard

Check if a string coincides with the specified mask.
uint str.fwildcard(
str wildcard
)

Parameters

wildcard The mask being checked. It can contain '?' (one character) and '*' (any number of characters).

Return value

Returns 1 if the string coincides with the mask.

See also

Strings


str.iencoding

The method recodes the specified string in order to send it using the POST method. Spaces are replaced with '+', special characters are replaced with their hexadecimal representations %XX. The result will be written to the string for which the method was called.
str str.iencoding(
str src
)

Parameters

src The string for recoding.

Return value

Returns the object which method has been called.

See also

Internet


str.ihead

The method is used to get the message header. It will be written to the string for which the method was called. Besides, the header will be deleted from the data object..
str str.ihead(
buf data
)

Parameters

data The buffer of the string containing the data being processed.

Return value

Returns the object which method has been called.

See also

Internet


str.ihttpinfo

The method processes a string as an HTTP header and writes data it gets into the httpinfo structure.
uint str.ihttpinfo(
httpinfo hi
)

Parameters

hi The variable of the httpinfo type for getting the results.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Internet


str.insert

The method inserts one string into another.
str str.insert(
uint | offset,
str | value
)

Parameters

offset | The offset where string will be inserted.
value | The string being inserted.

Return value

Returns the object which method has been called.

See also

Strings


str.islast

Check the final character.
uint str.islast(
uint ch
)

Parameters

ch The character being checked.

Return value

Returns 1 if the last character in the string coincides with the specified one and 0 otherwise.

See also

Strings


str.iurl

The method is used to parse a URL address.
uint str.iurl(
str | host,
str | port,
str | path
)

Parameters

host | The string for getting the host name.
port | The string for getting the port.
path | The string for getting the relative path.

Return value

1 is returned if the FTP protocol was specified. Otherwise, 0 is returned.

See also

Internet


str.lines

Get an array of lines out of a string.
arr str.lines(
arr | ret of str,
uint | trim
)

arr str.lines(
arr | ret of str,
uint | trim,
arr | offset
)

Parameters

ret of str | The array to write the found lines to.
trim | If 1, spaces and characters less than a space will be deleted on both sides of the string.
offset | The uint array for writing the offset of each line.

Return value

The function returns the parameter ret.

See also

Strings


str.lower

The method converts characters in a string to lowercase.

str str.lower()

Return value

Returns the object which method has been called.

See also

Strings


str.lowersub

Convert a substring in the specified string to lowercase.
str str.lowersub(
uint | off,
uint | size
)

Parameters

off | Substring offset.
size | Substring size.

Return value

Returns the object which method has been called.

See also

Strings


str.oem2char

Convert from the DOS encoding into the Windows encoding

str str.oem2char()

Return value

Returns the object which method has been called.

See also

Strings


str.print

Print a string into the current flow data output.

str.print()

See also

Strings


str.ptr

Get the pointer to the memory space containing the string. The method is needed when passing a string to external functions that work with strings ending in zeros.

uint str.ptr()

Return value

Returns the pointer to the data.

See also

Strings


str.quote

The method adds one character to the left and to the right. If the string already starts and ends in this character, it will not be added.
str str.quote(
uint ch
)

Parameters

ch The character that will be added to the left and to the right.

Return value

Returns the object which method has been called.

See also

Strings


str.read

Read a string from a file.
str str.read(
str filename
)

Parameters

filename Filename.

Return value

Returns the object which method has been called.

See also

Strings


str.regget

This method gets the value of a registry key in the form of a string.
str str.reggetdef(
uint | root,
str | subkey,
str | valname,
str | defval
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | A name of the specified key value.
defval | The default string in case there is no value.

str str.regget(
uint | root,
str | subkey,
str | valname
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | A name of the specified key value.

Return value

Returns the object which method has been called.

See also

Working with the Registry


str.regset

Write a string as a registry key value. If there is no key, it will be created.
uint str.regset(
uint | root,
str | subkey,
str | valname,
arr | ret of str
)

Parameters

root | A root key. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
subkey | A name of the registry key.
valname | The name of the value being written.
ret of str | The array of strings all the created keys will be written to. It can be 0.

Return value

0 | no data has been written
1 | the value of the key was created during the writing process
2 | data is written into the existing value

See also

Working with the Registry


str.repeat

Repeat a string the specified number of times.
str str.repeat(
uint count
)

Parameters

count The number of repeatitions. The result will be written into this very string.

Return value

Returns the object which method has been called.

See also

Strings


str.replace

The method replaces data in a string.
str str.replace(
uint | offset,
uint | size,
str | value
)

Parameters

offset | The offset of the data being replaced.
size | The size of the data being replaced.
value | The string being inserted.

Return value

Returns the object which method has been called.

See also

Strings


str.replacech

The method copies a source string with the replacing a character to a string.
str str.replacech(
str | src,
uint | from,
str | to
)

Parameters

src | Initial string.
from | A character to be replaced.
to | A string for replacing.

Return value

Returns the object which method has been called.

See also

Strings


str.reserve

Reserve space for writing into a string later.
str str.reserve(
uint size
)

Parameters

size Reserved size.

Return value

Returns the object which method has been called.

See also

Strings


str.search

The method determines if the string has been found inside another string or not.This method is considered easier than the spattern.search method.
uint str.search(
str | pattern,
uint | flag
)

Parameters

pattern Search string (pattern).
flag Search-flags.
$QS_IGNCASE | Case-insensitive.
$QS_WORD | Search the whole word only.
$QS_BEGINWORD | Search words which start with the specified pattern.

Return value

The method returns 1 if the substring is found, otherwise the return value is zero.

See also

Strings


str.setlen

Setting a new string size. The method does not reserve space. You cannot specify the size of a string greater than the reserved space you have. Mostly, this function is used for specifying the size of a string after external functions write data to it.
str str.setlen(
uint size
)

Parameters

size New string size.

Return value

Returns the object which method has been called.

See also

Strings


str.setlenptr

Recalculate the size of a string to the zero character. The function can be used to determine the size of a string after other functions write data into it.

str str.setlenptr()

Return value

Returns the object which method has been called.

See also

Strings


str.split

The method splits a string into substrings taking into account the specified separator.
str.split(
arr | names of str,
uint | ch,
uint | flag
)

Parameters

names of str | The array of strings substrings will be written to.
ch | Separator.
flag Flags.
$SPLIT_EMPTY | Take into account empty substrings.
$SPLIT_NOSYS | Delete characters <= space on the left and on the right.
$SPLIT_FIRST | Split till the first separator.
$SPLIT_QUOTE | Take into account that elements can be enclosed by single or double quotation marks.

See also

Strings


str.substr

Get a substring. The result substring will be written over the existing string in the first method.
str str.substr(
uint | off,
uint | size
)

Parameters

off | Substring offset.
size | Substring size.

str str.substr(
str | src,
uint | off,
uint | size
)

Parameters

src | Initial string.
off | Substring offset.
size | Substring size.

Return value

Returns the object which method has been called.

See also

Strings


str.trim

Delete the specified character on either sides of a string.
str str.trim(
uint | ch,
uint | flag
)

Parameters

ch The character being deleted.
flag Ôëàãè for deletion.
$TRIM_LEFT | Trim the left side
$TRIM_RIGHT | Trim the right side
$TRIM_ONE | Delete only one character
$TRIM_PAIR | If the character being deleted is a bracket, look the closing bracket on the right

Return value

Returns the object which method has been called.

See also

Strings


str.trimrspace

Delete spaces on the right.

str str.trimrspace()

Return value

Returns the object which method has been called.

See also

Strings


str.trimspace

Delete spaces on the left and on the right.

str str.trimspace()

Return value

Returns the object which method has been called.

See also

Strings


str.trimsys

Delete spaces and characters less than spaces on both sides.

str str.trimsys()

Return value

Returns the object which method has been called.

See also

Strings


str.upper

The method converts characters in a string to uppercase.

str str.upper()

Return value

Returns the object which method has been called.

See also

Strings


str.uppersub

Convert a substring in the specified string to uppercase.
str str.uppersub(
uint | off,
uint | size
)

Parameters

off | Substring offset.
size | Substring size.

Return value

Returns the object which method has been called.

See also

Strings


str.write

Writing a string to a file.
uint str.write(
str filename
)

Parameters

filename The name of the file for writing. If the file already exists, it will be overwritten.

uint str.write(
uint handle
)

Parameters

handle File identifier.

Return value

If error occurs, function returns 0.

See also

Strings


tan

Calculating the tangent.
double tan(
double x
)

Parameters

x An angle in radians.

Return value

The tangent of x.

See also

Mathematical functions


thread.create

Create a thread.
uint thread.create(
uint | idfunc,
uint | param
)

Parameters

idfunc | The pointer to the function that will be called as a new thread. The function must have one parameter. You can get the pointer using the operator &.
param | Additional parameter.

Return value

The handle of the created thread is returned. It returns 0 in case of an error.

See also

Threads


thread.getexitcode

Get the thread exit code.
uint thread.getexitcode(
uint result
)

Parameters

result The pointer to a variable of the uint type the thread exit code will be written to. If the thread is still active, the value $STILL_ACTIVE will be written.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Threads


thread.isactive

Check the work of a thread.

uint thread.isactive()

Return value

Returns 1 if the thread is active and 0 otherwise.

See also

Threads


thread.resume

Resume a thread paused with the suspend method.

uint thread.resume()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Threads


thread.suspend

Stop a thread.

uint thread.suspend()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Threads


thread.terminate

Terminate a thread.
uint thread.terminate(
uint code
)

Parameters

code Thread termination code.

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Threads


thread.wait

Wait till a thread is exited.

uint thread.wait()

Return value

Nonzero if initialization was successful; otherwise 0.

See also

Threads


tree.clear

Delete all items in the tree.

tree tree.clear()

Return value

Returns the object which method has been called.

See also

Trees


tree.del

Delete an item together with all its child items.
tree.del(
treeitem ti
)

Parameters

ti The item being deleted.

See also

Trees


tree.leaf

Add a "leaf" to the specified node. A "leaf" is a final item.
treeitem tree.leaf(
treeitem ti
)

Parameters

ti Parent node.

Return value

The added item of 0 in case of an error.

See also

Trees


tree.node

Add a "node" to the specified node. You can add items to a "node".
treeitem tree.node(
treeitem ti
)

Parameters

ti Parent node.

Return value

The added item of 0 in case of an error.

See also

Trees


tree.root

Get the root item.

treeitem tree.root()

Return value

Root item

See also

Trees


treeitem.changenode

Change the parent node of an item.
uint treeitem.changenode(
treeitem ti
)

Parameters

ti New parent node.

Return value

If error occurs, function returns 0.

See also

Trees


treeitem.child

Get the first child item of another item.

treeitem treeitem.child()

Return value

Returns the first child item or 0 if there is none.

See also

Trees


treeitem.data

Get the pointer to the data stored in an object.

uint treeitem.data()

Return value

Returns the pointer to the data.

See also

Trees


treeitem.getnext

Get the next item of a tree.

treeitem treeitem.getnext()

Return value

Returns the next item of the tree.

See also

Trees


treeitem.getprev

Get the previous item of a tree.

treeitem treeitem.getprev()

Return value

Returns the previous item of the tree.

See also

Trees


treeitem.getroot

Get the root item of a tree.

treeitem tree.root()

treeitem treeitem.getroot()

Return value

Returns the root item of the tree.

See also

Trees


treeitem.isleaf

The method checks if an item is a "leaf" (if it cannot have child items).

uint treeitem.isleaf()

Return value

Returns 1 if this item is a tree "leaf" and 0 otherwise.

See also

Trees


treeitem.isnode

The method checks is an item can have child items.

uint treeitem.isnode()

Return value

Returns 1 if this item is a tree "node" and 0 otherwise.

See also

Trees


treeitem.isroot

The method checks if an item is a root one.

uint treeitem.isroot()

Return value

Returns 1 if this item is a root one and 0 otherwise.

See also

Trees


treeitem.lastchild

Get the last child item of another item.

treeitem treeitem.lastchild()

Return value

Returns the last child item or 0 if there is none.

See also

Trees


treeitem.move

Move an item within its parent.
uint treeitem.move(
treeitem after
)

Parameters

after The node to insert the item after. Specify 0 if it should be made the first item.

Return value

If error occurs, function returns 0.

See also

Trees


treeitem.parent

Get the parent of an item.

treeitem treeitem.parent()

Return value

Returns the parent of this item.

See also

Trees


type_delete

Delete the object as located by the pointer.
type_delete(
uint | ptr,
uint | itype
)

Parameters

ptr | The pointer to the memory space where the object being deleted is located.
itype | The type of the object.

See also

Other functions


type_hasdel

Specifies the necessity to call the function type_delete for deleting an object of this type.
uint type_hasdel(
uint itype
)

Parameters

itype The type of an object.

Return value

1 is returned if it is necessary to call type_delete, 0 is returned otherwise.

See also

Other functions


type_hasinit

Specifies the necessity to call the function type_init for initiating an object of this type.
uint type_hasinit(
uint itype
)

Parameters

itype The type of an object.

Return value

1 is returned if it is necessary to call type_init, 0 is returned otherwise.

See also

Other functions


type_init

Initiate the object as located by the pointer.
uint type_init(
uint | ptr,
uint | itype
)

Parameters

ptr | The pointer to the memory space where the object being created is located.
itype | The type of the object.

Return value

The pointer to the object is returned.

See also

Other functions


variant.arrcreate

This method creates the SafeArray array in the variable of the VARIANT type. VARIANT is an element of the array. Values can be assigned to the array elements using the arrfromg method. An element of the array can be obtained with the help of the arrgetptr method.
uint variant.arrcreate(
collection bounds
)

Parameters

bounds The collection that contains array parameters. Two numbers are specified for each array dimension: the first number - an element quantity, the second number - a sequence number of the first element in the dimension.

Return value

If error occurs, method returns zero, otherwise returns 1.

The example uses SafeArray

   VARIANT v
   v.arrcreate( %{3,0,2,0} )//An array with 3 lines and 2 columns is being created

   v.arrfromg( %{0,0, 0.1234f} )
   v.arrfromg( %{0,1, int(100)} )
   v.arrfromg( %{2,1, "Test" } )
   ...
   excapp~Range( excapp~Cells( 1, 1 ), excapp~Cells( 3, 2 ) ) = v //The array is being transmitted to the COM object

SafeArray allows you to group data, that makes data exchange with the COM object faster.

See also

Working with COM Object


variant.arrfromg

The method assigns a value to an element of the SafeArray array
uint variant.arrfromg(
collection item
)

Parameters

item The collection that contains "coordinates" of an element; the last element of the collection - the assigned value.

Return value

If error occurs, method returns zero, otherwise returns 1.

Example

   v.arrfromg( %{0,0, 0.1234f} )
   v.arrfromg( %{0,1, int(100)} )
   v.arrfromg( %{2,1, "Test" } )

See also

Working with COM Object


variant.arrgetptr

The method enables you to obtain a pointer to an element of the SafeArray array.

uint variant.arrgetptr()

Return value

The method returns address of an array element, if error occurs it returns zero.

See also

Working with COM Object


variant.clear

Clears the variable contents, the storage area is released if necessary. The VARIANT type is equal to VT_EMPTY. This method is automatically called before a new value has been set

variant.clear()

See also

Working with COM Object


variant.isnull

This method enables you to define whether or not a variable is NULL - the VARIANT( VT_NULL ) type.

uint variant.isnull()

Return value

The method returns 1, if the VARIANT variable is of the VT_NULL type, otherwise, it returns zero.

See also

Working with COM Object


verifypath

Verifying a path and creating all absent directories.
uint verifypath(
str | name,
arr | dirs of str
)

Parameters

name | The name of the path to be verified.
dirs of str | An array for getting all the directories being created. It can be 0 ( 0->arr of str ).

Return value

The function returns 1 if directories have been verified and created successfully. In case of an error, the function returns 0 and the last dirs item contains the name where there occurred an error while creating a directory.

See also

Function working with files


write

Writing to a file.
uint write(
uint | handle,
buf | wbuf
)

Parameters

handle | File identifier.
wbuf | The buffer from which data will be written.

Return value

If error occurs, function returns 0.

See also

Function working with files


xml.addentity

Adds an entity description; the entity must have been described before the gettext method is called. Below you can see the list of entities described by default:
&amp; - &;
&quot; - ";
&apos; - ';
&gt; - >;
&lt; - <;

xml.addentity(
str | key,
str | value
)

Parameters

key | Key (an entity name - &entity_name; ).
value | Entity value is a string that will be pasted into the text.

See also

XML file processing


xml.getroot

Gets the root item of the XML document tree.
Actually, a root item contains all items of an XML document tree only.

xmlitem xml.getroot()

Return value

Returns a root item.

See also

XML file processing


xml.procfile

Reads the XML file, the name of which is specified as a parameter, and process it.
uint xml.procfile(
str file
)

Parameters

file Name of the file processed.

Return value

Returns 1 if the method is successful; otherwise, returns zero.

See also

XML file processing


xml.procstr

Processes a string contained the XML document.
uint xml.procstr(
str src
)

Parameters

src XML data string.

Return value

Returns 1 if the method is successful; otherwise, returns zero.

See also

XML file processing


xmlitem.chtag

Searches through the XML tree for a tag item with the help of the specified "path". A "path" consists of tag names separated by the '/' character, if the first character in a path is the '/' character, the item search begins from the tree root; otherwise - from the current item.
xmlitem xmlitem.chtag(
str path
)

Parameters

path Path of the item.

Return value

Returns the item obtained or zero, if no item has been found.

See also

XML file processing


xmlitem.findtag

Searches through the XML tree for a tag item with the specified name. The item is searched recursively through all child items.
xmlitem xmlitem.findtag(
str name
)

Parameters

name Name of the required tag.

Return value

Returns the item obtained or zero, if no item has been found.

See also

XML file processing


xmlitem.getattrib

Gets a tag item attribute value.
str xmlitem.getattrib(
str | name,
str | result
)

Parameters

name | Attribute name.
result | Result string.

Return value

Returns the string that contains the attribute value. If no attribute has been found, it returns an empty string.

See also

XML file processing


xmlitem.getchild

Gets the first child item of the current item.

xmlitem xmlitem.getchild()

Return value

Returns the child item or zero, if the item does not contain any child items.

See also

XML file processing


xmlitem.getchildtag

Gets the first child tag item. This method is similar to the xmlitem.getchild method; however, if the child item is not a tag item, in this case, the tag item that comes first is searched through the child items.

xmlitem xmlitem.getchildtag()

Return value

Returns the child tag item or zero, if the item does not contain any child tag items.

See also

XML file processing


xmlitem.getchildtext

Gets the first child text item. This method is similar to the xmlitem.getchild method; however, if the child item is not a text item, in this case, the text item that comes first is searched through the child items.

xmlitem xmlitem.getchildtext()

Return value

Returns the child text item or zero, if the item does not contain any child text items.

See also

XML file processing


xmlitem.getnext

Gets the next item; however, the next item must be searched through the items with the same parent item.

xmlitem xmlitem.getnext()

Return value

Returns the next item or zero, if the item is the last item.

See also

XML file processing


xmlitem.getnexttag

Gets the next tag item. This method is similar to the xmlitem.getnext method, but if the next item is not a tag item, this operation repeats.

xmlitem xmlitem.getnexttag()

Return value

Returns the next tag item or zero, if the item is the last item.

See also

XML file processing


xmlitem.getnexttext

Gets the next text item. This method is similar to the xmlitem.getnext method, but if the next item is not a text item, this operation repeats.

xmlitem xmlitem.getnexttext()

Return value

Returns the next text item or zero, if the item is the last item.

See also

XML file processing


xmlitem.getparent

Gets the parent item of the current item.

xmlitem xmlitem.getparent()

Return value

Returns the parent item or zero, if the current item is the root item.

See also

XML file processing


xmlitem.gettext

Gets a text of the current item in the XML tree. This method is applied either to a text item or a tag item, in the latter case, the text is obtained from the child text item.
str xmlitem.gettext(
str result
)

Parameters

Return value

Returns the string that contains the text of the item. If no text has been found, it returns an empty string.

See also

XML file processing


xmlitem.isemptytag

Determines if the current item is a tag item, that contains no child items <tag .../>;.

uint xmlitem.isemptytag()

Return value

Returns nonzero if the item is a tag item, that contains no child items; otherwise, it returns zero.

See also

XML file processing


xmlitem.ispitag

Determines if the current item is a tag of processing instruction <?tag ...?>.

uint xmlitem.ispitag()

Return value

Returns nonzero if the item is a tag of processing instruction, otherwise, it returns zero.

See also

XML file processing


xmlitem.istag

Determines if the current item is a tag item.

uint xmlitem.istag()

Return value

Returns nonzero if the item is a tag item; otherwise, it returns zero.

See also

XML file processing


xmlitem.istext

Determines if the current item is a text item.

uint xmlitem.istext()

Return value

Returns nonzero if the item is a text item; otherwise, it returns zero.

See also

XML file processing