From Clomosy Docs

Revision as of 07:29, 3 October 2024 by ClomosyManager (talk | contribs)

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









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.