From Clomosy Docs

No edit summary
No edit summary
Line 2: Line 2:
There are different definitions according to the data type. These;
There are different definitions according to the data type. These;


<div class="table-responsive">
{| class="wikitable" style="border: 2px solid #c3d7e0"
{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"|Definition
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition
|-
|-
| TclArrayInteger || myArrayInteger : TclArrayInteger; || Array definition indexed by integers.
| TclArrayInteger || arrayInteger : TclArrayInteger; || Array definition indexed by integers.
|-
|-
| TclArrayString || myArrayString : TclArrayString; || Array definition indexed by string.
| TclArrayString || arrayString : TclArrayString; || Array definition indexed by string.
|-
|-
| TclArrayDouble || myArrayDouble : TclArrayDouble; || Array definition indexed by double.
| TclArrayDouble || arrayDouble : TclArrayDouble; || Array definition indexed by double.
|-
|-
| TclArrayBoolean || myArrayBoolean : TclArrayBoolean; || Array definition indexed by boolean.
| TclArrayBoolean || arrayBoolean : TclArrayBoolean; || Array definition indexed by boolean.
|-
|-
| TclArraySingle || myArraySingle : TclArraySingle; || Array definition indexed by single.
| TclArraySingle || arraySingle : TclArraySingle; || Array definition indexed by single.
|-
|-
| TclArrayWord || myArrayWord : TclArrayWord; || Array definition indexed by words.
| TclArrayWord || arrayWord : TclArrayWord; || Array definition indexed by words.
|-
|-
| TClArrayExtended || myArrayExtended : TClArrayExtended; || Array definition indexed by extanded.
| TClArrayExtended || arrayExtended : TClArrayExtended; || Array definition indexed by extanded.
|-
|-
| Create || myArray := TClArrayInteger.Create; || An object is created in the form.
| Create || array1 = TClArrayInteger.Create; || An object is created in the form.
|-
|-
| Count || myArray.Count; || The size of the array is taken.
| Count || array1.Count; || The size of the array is taken.
|-
|-
| Add || myArray.Add(50); || The value 50 is added to the array.
| Add || array1.Add(50); || The value 50 is added to the array.
|-
|-
| GetItem || myArray (50 , 100, 70, 12, 3) myArray.GetItem(1) || Used to access the items of the array. This will return the requested item one by one, no matter how many items are in the array. I want to get the data in the 2nd element of the sample array.
| GetItem || array1 (50 , 100, 70, 12, 3) array1.GetItem(1) || Used to access the items of the array. This will return the requested item one by one, no matter how many items are in the array. I want to get the data in the 2nd element of the sample array.
|-
|-
| SetItem || myArray.SetItem(1,25) //myArray:TclArrayInteger || Value assignment is performed to the array element in the array used. The first parameter represents the index number, the second parameter represents the value assigned to the selected index number.
| SetItem || array1.SetItem(1,25) //array1:TclArrayInteger || Value assignment is performed to the array element in the array used. The first parameter represents the index number, the second parameter represents the value assigned to the selected index number.
|-
|-
| RemoveAll || myArray.RemoveAll; || It is used to delete the entire directory.
| RemoveAll || array1.RemoveAll; || It is used to delete the entire directory.
|-
|-
| RemoveAt || myArray.RemoveAt(5); || "RemoveAt" is used if you want to delete data in an index of the array. The return value of this operation is returned as boolean. The return value is "True" if data deletion has been performed. If this index does not exist in the array and cannot be deleted, it returns "False".
| RemoveAt || array1.RemoveAt(5); || "RemoveAt" is used if you want to delete data in an index of the array. The return value of this operation is returned as boolean. The return value is "True" if data deletion has been performed. If this index does not exist in the array and cannot be deleted, it returns "False".
|-
|-
|Destroy || myArray.Destroy; || It is used to delete an object from memory and free the memory.
|Destroy || array1.Destroy; || It is used to delete an object from memory and free the memory.
|}
|}
'''Example:'''
</div>
:'''Base Syntax'''
 
  var
<b>Example</b><br>
    myArray : TClArrayInteger;
<b>TRObject Syntax</b><br>
    iIndex : Integer;
<pre>
 
var
  begin
  array1 : TClArrayInteger;
    myArray := TClArrayInteger.Create;
  i : Integer;
    myArray.Add(20);
    myArray.Add(30);
    myArray.Add(17);
    myArray.Add(23);
   
    for iIndex := 0 to myArray.Count-1 do
    begin
      ShowMessage('Value: '+IntToStr(myArray.GetItem(iIndex)));
    end;
   
  end;


:'''TRObject Syntax'''
{
   var
   array1 = TClArrayInteger.Create;
    myArray : TClArrayInteger;
  array1.Add(20);
    iIndex : Integer;
  array1.Add(30);
  array1.Add(17);
  array1.Add(23);
    
    
  for (i = 0 to array1.Count-1)
   {
   {
     myArray = TClArrayInteger.Create;
     ShowMessage('Value: '+IntToStr(array1.GetItem(i)));
    myArray.Add(20);
    myArray.Add(30);
    myArray.Add(17);
    myArray.Add(23);
   
    for (iIndex = 0 to myArray.Count-1)
    {
      ShowMessage('Value: '+IntToStr(myArray.GetItem(iIndex)));
    }
   
   }
   }
}
</pre>
<b>Base Syntax</b><br>
<pre>
var
  array1 : TClArrayInteger;
  i : Integer;
begin
  array1 := TClArrayInteger.Create;
  array1.Add(20);
  array1.Add(30);
  array1.Add(17);
  array1.Add(23);
 
  for i := 0 to array1.Count-1 do
  begin
    ShowMessage('Value: '+IntToStr(array1.GetItem(i)));
  end;
end;
</pre>


== See Also ==
<h2> See Also </h2>
* [[TRObject_Language#Arrays | Arrays]]
* [[Sorting Algorithms]]
* [[Sorting Algorithms]]

Revision as of 13:32, 22 October 2024

Array means many variables of the same data type. Array variables are like a list with a sequence number. Items belonging to this list are also accessed by their sequence number. Another structure that enables the use of Array on Clomosy is the TclArray structure. There are different definitions according to the data type. These;

Feature Use of Definition
TclArrayInteger arrayInteger : TclArrayInteger; Array definition indexed by integers.
TclArrayString arrayString  : TclArrayString; Array definition indexed by string.
TclArrayDouble arrayDouble : TclArrayDouble; Array definition indexed by double.
TclArrayBoolean arrayBoolean : TclArrayBoolean; Array definition indexed by boolean.
TclArraySingle arraySingle : TclArraySingle; Array definition indexed by single.
TclArrayWord arrayWord : TclArrayWord; Array definition indexed by words.
TClArrayExtended arrayExtended : TClArrayExtended; Array definition indexed by extanded.
Create array1 = TClArrayInteger.Create; An object is created in the form.
Count array1.Count; The size of the array is taken.
Add array1.Add(50); The value 50 is added to the array.
GetItem array1 (50 , 100, 70, 12, 3) array1.GetItem(1) Used to access the items of the array. This will return the requested item one by one, no matter how many items are in the array. I want to get the data in the 2nd element of the sample array.
SetItem array1.SetItem(1,25) //array1:TclArrayInteger Value assignment is performed to the array element in the array used. The first parameter represents the index number, the second parameter represents the value assigned to the selected index number.
RemoveAll array1.RemoveAll; It is used to delete the entire directory.
RemoveAt array1.RemoveAt(5); "RemoveAt" is used if you want to delete data in an index of the array. The return value of this operation is returned as boolean. The return value is "True" if data deletion has been performed. If this index does not exist in the array and cannot be deleted, it returns "False".
Destroy array1.Destroy; It is used to delete an object from memory and free the memory.

Example
TRObject Syntax

var
  array1 : TClArrayInteger;
  i : Integer;

{
  array1 = TClArrayInteger.Create;
  array1.Add(20); 
  array1.Add(30);
  array1.Add(17);
  array1.Add(23);
  
  for (i = 0 to array1.Count-1)
  {
    ShowMessage('Value: '+IntToStr(array1.GetItem(i)));
  }
}

Base Syntax

var
  array1 : TClArrayInteger;
  i : Integer;

begin
  array1 := TClArrayInteger.Create;
  array1.Add(20); 
  array1.Add(30);
  array1.Add(17);
  array1.Add(23);
  
  for i := 0 to array1.Count-1 do
  begin
    ShowMessage('Value: '+IntToStr(array1.GetItem(i)));
  end;
end;

See Also