From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 378: | Line 378: | ||
|- | |- | ||
|TclArray|| A list of a specific data type with a fixed or dynamic length. For detailed information, please refer to the [[TclArray]] page. | |TclArray|| A list of a specific data type with a fixed or dynamic length. For detailed information, please refer to the [[TclArray]] page. | ||
|} | |||
</div> | |||
<h2> File Types </h2> | |||
<div class="table-responsive"> | |||
{| class="wikitable" style="border: 2px solid #c3d7e0" | |||
! style="background-color: #c3d7e0"| Type !!style="background-color: #c3d7e0"| Description | |||
|- | |||
|TextFile || It is a data type used in file operations. For detailed information, please refer to the [[]] page. | |||
|} | |} | ||
</div> | </div> | ||
Revision as of 08:11, 23 October 2024
The data types of an entity specify its associated meaning, constraints, possible values, operations, functions, and storage mode.
A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in TRObject has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.
A type declaration is used to declare the data type of an identifier. The syntax of a type declaration is as follows:
var
days : integer;
Integer Types
| Type | Description |
|---|---|
| Byte | Values range from 0 to 255. |
| ShortInt | Values range from -128 to 127. |
| SmallInt | Values range from -32,768 to 32,767. |
| Integer | Values range from -2,147,483,648 to 2,147,483,647. |
| LongInt | Has the same range as Integer. |
| Int64 | Values range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. |
| Cardinal | Values range from 0 to 4,294,967,295. |
| LongWord | Values range from 0 to 4,294,967,295. |
| UInt64 | Values range from 0 to 18,446,744,073,709,551,615. |
Example
TRObject Syntax
var
age: Byte;
temperature: ShortInt;
year: SmallInt;
population: Integer;
distance: Int64;
fileSize: Cardinal;
largeNumber: UInt64;
balance: LongInt;
memorySize: LongWord;
{
age = 25;
temperature = -15;
year = 1990;
population = 1500000;
distance = 10000000000;
fileSize = 4000000;
largeNumber = 1200000000000000000;
balance = -5000000;
memorySize = 3000000000;
ShowMessage(age);
ShowMessage(temperature);
ShowMessage(year);
ShowMessage(population);
ShowMessage(distance);
ShowMessage(fileSize);
ShowMessage(largeNumber);
ShowMessage(balance);
ShowMessage(memorySize);
}
Base Syntax
var age: Byte; temperature: ShortInt; year: SmallInt; population: Integer; distance: Int64; fileSize: Cardinal; largeNumber: UInt64; balance: LongInt; memorySize: LongWord; begin age := 25; temperature := -15; year := 1990; population := 1500000; distance := 10000000000; fileSize := 4000000; largeNumber := 1200000000000000000; balance := -5000000; memorySize := 3000000000; ShowMessage(age); ShowMessage(temperature); ShowMessage(year); ShowMessage(population); ShowMessage(distance); ShowMessage(fileSize); ShowMessage(largeNumber); ShowMessage(balance); ShowMessage(memorySize); end;
Floating-point Types
| Type | Description |
|---|---|
| Single | Single precision, approximately 7-digit floating-point number. |
| Double | Double precision, approximately 15-digit floating-point number. |
| Extended | High precision, approximately 19-20 digit floating-point number. |
| Currency | Fixed precision (4 decimal places), suitable for financial calculations. |
| Real | Typically used interchangeably with Double. |
Example
TRObject Syntax
var
s: Single;
d: Double;
e: Extended;
c: Currency;
r: Real;
{
// Değişkenlere değer atayalım
s = 1234.5678;
d = 123456789.1234567;
e = 1234567890123456789.123456789;
c = 123456.7890;
r = 987654321.1234567;
// Sonuçları ekrana yazdıralım
ShowMessage(s);
ShowMessage(d);
ShowMessage(e);
ShowMessage(c);
ShowMessage(r);
}
Base Syntax
var s: Single; d: Double; e: Extended; c: Currency; r: Real; begin // Değişkenlere değer atayalım s := 1234.5678; d := 123456789.1234567; e := 1234567890123456789.123456789; c := 123456.7890; r := 987654321.1234567; // Sonuçları ekrana yazdıralım ShowMessage(s); ShowMessage(d); ShowMessage(e); ShowMessage(c); ShowMessage(r); end;
Character and String Types
| Type | Description |
|---|---|
| Char | A single character (ANSI). |
| WideChar | A single wide character (Unicode). |
| String | A variable-length ANSI character string. |
| ShortString | A fixed-length ANSI character string up to 255 characters. |
| AnsiString | ANSI character string. |
| WideString | Unicode character string. |
| UnicodeString | Unicode character string, Delphi's default string type. |
Example
TRObject Syntax
var
c: Char;
wideC: WideChar;
s: String;
shortS: ShortString;
ansiS: AnsiString;
wideS: WideString;
unicodeS: UnicodeString;
{
c = 'A';
wideC = '𐍈';
s = 'TRObject programming language';
shortS = 'Hello!';
ansiS = 'İstanbul';
wideS = 'Extended text with Unicode support: ö, ü, ş';
unicodeS = 'Unicode, the default string type; Turkish characters: ç, ğ, İ';
ShowMessage('Char: '+ c);
ShowMessage('WideChar: '+ wideC);
ShowMessage('String: '+ s);
ShowMessage('ShortString: '+ shortS);
ShowMessage('AnsiString: '+ ansiS);
ShowMessage('WideString: '+ wideS);
ShowMessage('UnicodeString: '+ unicodeS);
}
Base Syntax
var
c: Char;
wideC: WideChar;
s: String;
shortS: ShortString;
ansiS: AnsiString;
wideS: WideString;
unicodeS: UnicodeString;
begin
c := 'A';
wideC := '𐍈';
s := 'TRObject programming language';
shortS := 'Hello!';
ansiS := 'İstanbul';
wideS := 'Extended text with Unicode support: ö, ü, ş';
unicodeS := 'Unicode, the default string type; Turkish characters: ç, ğ, İ';
ShowMessage('Char: '+ c);
ShowMessage('WideChar: '+ wideC);
ShowMessage('String: '+ s);
ShowMessage('ShortString: '+ shortS);
ShowMessage('AnsiString: '+ ansiS);
ShowMessage('WideString: '+ wideS);
ShowMessage('UnicodeString: '+ unicodeS);
end;
Boolean Types
Specifies true or false logical values. This is also an integer type.
| Type | Description |
|---|---|
| Boolean | Can take the values True or False. |
Example
TRObject Syntax
var
b: Boolean;
{
b = True;
ShowMessage(b);
}
Base Syntax
var b: Boolean; begin b := True; ShowMessage(b); end;
Date and Time Types
| Type | Description |
|---|---|
| TclDateTime | Stores dates and times, represented as days and fractions of days. |
Example
TRObject Syntax
var
currentDateTime: TclDateTime; // TDateTime türünde bir değişken
specificDateTime: TclDateTime; // Belirli bir tarih ve saat için değişken
{
currentDateTime = Now;
specificDateTime = EncodeDate(2024, 1, 1) + EncodeTime(15, 30, 0, 0);
ShowMessage('Current Date and Time: '+ DateTimeToStr(currentDateTime));
ShowMessage('Specific Date and Time: '+ DateTimeToStr(specificDateTime));
}
Base Syntax
var
currentDateTime: TclDateTime; // TDateTime türünde bir değişken
specificDateTime: TclDateTime; // Belirli bir tarih ve saat için değişken
begin
currentDateTime := Now;
specificDateTime := EncodeDate(2024, 1, 1) + EncodeTime(15, 30, 0, 0);
ShowMessage('Current Date and Time: '+ DateTimeToStr(currentDateTime));
ShowMessage('Specific Date and Time: '+ DateTimeToStr(specificDateTime));
end;
Variant Type
| Type | Description |
|---|---|
| Variant | An flexible data type that can store values of different types, such as integers, floating-point numbers, strings, and booleans. |
Example
TRObject Syntax
var
v: Variant;
{
v = 42;
ShowMessage(v);
v = 'Hello, World!';
ShowMessage(v);
}
Base Syntax
var v: Variant; begin v := 42; ShowMessage(v); v := 'Hello, World!'; ShowMessage(v); end;
Array Types
| Type | Description |
|---|---|
| Array | A list of a specific data type with a fixed or dynamic length. For detailed information, please refer to the Arrays page. |
| TclArray | A list of a specific data type with a fixed or dynamic length. For detailed information, please refer to the TclArray page. |
File Types
| Type | Description |
|---|---|
| TextFile | It is a data type used in file operations. For detailed information, please refer to the [[]] page. |
Special Data Types
| Type | Description |
|---|---|
| TclStringList | It is a useful class for storing and managing a string and provides a list-like structure. For detailed information, please refer to the TclStringList page. |
| TclJSONQuery | It is a class used for working with JSON data. Its usage can be found on the JSON Data Source and Cloud Database Queries pages. |
| TclSqliteQuery | It is a class used to interact with the SQLite database. It allows you to execute SQL queries, retrieve data, insert, update, and delete records in the SQLite database. For detailed information, please refer to the Local Database Queries page. |
| TclSqlQuery | It is a general class used to interact with SQL databases. This class allows you to execute SQL queries, retrieve data, insert, update, and delete records in various SQL-based database systems. For detailed information, please refer to the SQL Server Queries page. |
Constants
Use of constants makes a program more readable and helps to keep special quantities at one place in the beginning of the program. TRObject allows numerical, logical, string and character constants. Constants can be declared in the declaration part of the program by specifying the const declaration.
Syntax of constant type declaration is follows:
const
Identifier = contant_value;