From Clomosy Docs

No edit summary
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 37: Line 37:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
var
var
Line 70: Line 70:
   ShowMessage(memorySize);
   ShowMessage(memorySize);
}
}
</pre>
<b>Base Syntax</b><br>
<pre>
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;
</pre>
</pre>


Line 125: Line 91:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
var
var
Line 148: Line 114:
   ShowMessage(r);
   ShowMessage(r);
}
}
</pre>
<b>Base Syntax</b><br>
<pre>
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;
</pre>
</pre>


Line 197: Line 139:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
var
var
Line 226: Line 168:
   ShowMessage('UnicodeString: '+ unicodeS);
   ShowMessage('UnicodeString: '+ unicodeS);
}
}
</pre>
<b>Base Syntax</b><br>
<pre>
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;
</pre>
</pre>


Line 270: Line 182:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
var
var
Line 279: Line 191:
   ShowMessage(b);
   ShowMessage(b);
}
}
</pre>
<b>Base Syntax</b><br>
<pre>
var
  b: Boolean;
begin
  b := True;     
  ShowMessage(b);
end;
</pre>
</pre>


Line 301: Line 203:
</div>
</div>


<b>Example</b><br>
<b>Example 1</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
var
var
Line 316: Line 218:
}
}
</pre>
</pre>
<b>Base Syntax</b><br>
 
<b>Example 2 - Calculating the Number of Days Between Two Dates</b><br>
 
1. Use the Trunc() function on both TclDateTime values to remove the time part and consider only the date portion.<br>
 
2. The TclDateTime type is a Double:<br>
 
* The integer part represents the number of days since January 1, 2014.
 
* The fractional part represents the time of day (e.g., hours and minutes).
 
3. After calculating the difference between the two dates, use the Abs() function to get the absolute value. This ensures a positive result even if the dates are entered in reverse.<br>
 
4. Using this method, the number of days between two dates can be calculated easily.<br>
 
 
<pre>
<pre>
var
var
   currentDateTime: TclDateTime; // TDateTime türünde bir değişken
   Difference: Integer;
   specificDateTime: TclDateTime; // Belirli bir tarih ve saat için değişken
   date1, date2 : TclDateTime;
 
{
begin
   date1 = StrToDateTime('01.01.2024 08:30:00');
   currentDateTime := Now;
   date2 = StrToDateTime('13.05.2025 14:45:00');
  specificDateTime := EncodeDate(2024, 1, 1) + EncodeTime(15, 30, 0, 0);
  Difference = Abs(Trunc(date1) - Trunc(date2));
 
   ShowMessage('Difference: ' + IntToStr(Difference)); // Day difference
   ShowMessage('Current Date and Time: '+ DateTimeToStr(currentDateTime));
}
   ShowMessage('Specific Date and Time: '+ DateTimeToStr(specificDateTime));
end;
</pre>
</pre>


Line 342: Line 257:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
var
var
Line 354: Line 269:
   ShowMessage(v);
   ShowMessage(v);
}
}
</pre>
<b>Base Syntax</b><br>
<pre>
var
  v: Variant;
begin
  v := 42;   
  ShowMessage(v);
  v := 'Hello, World!';
  ShowMessage(v);
end;
</pre>
</pre>


Line 378: Line 280:
|-
|-
|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 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.
|}
</div>
<h2> Special Data Types </h2>
<div class="table-responsive">
{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Type !!style="background-color: #c3d7e0"| 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 [[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.
|-
|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.
|}
|}
</div>
</div>
Line 391: Line 318:
&nbsp;&nbsp;Identifier = contant_value;
&nbsp;&nbsp;Identifier = contant_value;
</div>
</div>
{{#seo:|title=Data Types in Clomosy - Clomosy Docs}}
{{#seo:|description=Understand how to use different data types to structure and optimize your mobile app's code effectively.}}

Latest revision as of 06:48, 13 May 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 1

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

Example 2 - Calculating the Number of Days Between Two Dates

1. Use the Trunc() function on both TclDateTime values to remove the time part and consider only the date portion.

2. The TclDateTime type is a Double:

  • The integer part represents the number of days since January 1, 2014.
  • The fractional part represents the time of day (e.g., hours and minutes).

3. After calculating the difference between the two dates, use the Abs() function to get the absolute value. This ensures a positive result even if the dates are entered in reverse.

4. Using this method, the number of days between two dates can be calculated easily.


var
  Difference: Integer;
  date1, date2 : TclDateTime;
{
  date1 = StrToDateTime('01.01.2024 08:30:00');
  date2 = StrToDateTime('13.05.2025 14:45:00');
  Difference = Abs(Trunc(date1) - Trunc(date2));
  ShowMessage('Difference: ' + IntToStr(Difference)); // Day difference
}

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: