From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 257: | Line 257: | ||
end; | end; | ||
</pre> | </pre> | ||
<h2> Boolean Types </h2> | |||
Specifies true or false logical values. This is also an integer type. | |||
<div class="table-responsive"> | |||
{| class="wikitable" style="border: 2px solid #c3d7e0" | |||
! style="background-color: #c3d7e0"| Type !!style="background-color: #c3d7e0"| Description | |||
|- | |||
|Boolean || Can take the values True or False. | |||
|} | |||
</div> | |||
<b>Example</b><br> | |||
<b>TRObject Syntax</b><br> | |||
<pre> | |||
var | |||
b: Boolean; | |||
{ | |||
b = True; | |||
ShowMessage(b); | |||
} | |||
</pre> | |||
<b>Base Syntax</b><br> | |||
<pre> | |||
var | |||
b: Boolean; | |||
begin | |||
b := True; | |||
ShowMessage(b); | |||
end; | |||
</pre> | |||
<h2> Date and Time Types </h2> | |||
<div class="table-responsive"> | |||
{| class="wikitable" style="border: 2px solid #c3d7e0" | |||
! style="background-color: #c3d7e0"| Type !!style="background-color: #c3d7e0"| Description | |||
|- | |||
|TclDateTime|| Stores dates and times, represented as days and fractions of days. | |||
|} | |||
</div> | |||
<b>Example</b><br> | |||
<b>TRObject Syntax</b><br> | |||
<pre> | |||
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)); | |||
} | |||
</pre> | |||
<b>Base Syntax</b><br> | |||
<pre> | |||
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; | |||
</pre> | |||
Revision as of 08:00, 3 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;
| Sr.No | Type & Description |
|---|---|
| 1 | Character Typically a single octet (one byte). This is an integer type. |
| 2 | Integer The most natural size of integer for the machine. |
| 3 | Real A single-precision floating point value. |
| 4 | Boolean Specifies true or false logical values. This is also an integer type. |
| 5 | Enumerated Specifies a user-defined list. |
| 6 | Subrange Represents variables, whose values lie within a range. |
| 7 | String Stores an array of characters. |