From Clomosy Docs

No edit summary
No edit summary
Line 273: Line 273:
|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.
|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.
|TclJSONQuery || It is a class used for working with JSON data. Its usage can be found on the [[JSON Data Source]] and [[Clomosy Cloud Database Technology | 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.
|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.

Revision as of 12:16, 16 April 2025

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:

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

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);
}

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

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);
}

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

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);
}

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

var
  b: Boolean; 

{
  b = True;      
  ShowMessage(b);
}

Date and Time Types

Type Description
TclDateTime Stores dates and times, represented as days and fractions of days.

Example

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));
}

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

var
  v: Variant;

{
  v = 42;    
  ShowMessage(v);

  v = 'Hello, World!'; 
  ShowMessage(v);
}

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 for processing text files. This type can be used to read or write text files line by line. For detailed information, please refer to the File Handling 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: