From Clomosy Docs

(Created page with "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; myArrayInteger : TclArrayInteger; myArrayString : TclArrayString; myArrayDouble : TclArrayDouble; myArrayBoolean : TclArrayBoolean; myA...")
 
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;


  myArrayInteger : TclArrayInteger;
{| class="wikitable" style="border: 2px solid #c3d7e0"
myArrayString  : TclArrayString;
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"|Definition  
myArrayDouble : TclArrayDouble;
|-
myArrayBoolean : TclArrayBoolean;  
| TclArrayInteger || myArrayInteger : TclArrayInteger; || Array definition indexed by integers.
myArraySingle : TclArraySingle;
|-
myArrayWord : TclArrayWord;
| TclArrayString || myArrayString  : TclArrayString; || Array definition indexed by string.
myArrayExtended : TClArrayExtended;
|-
| TclArrayDouble || myArrayDouble : TclArrayDouble; || Array definition indexed by double.
|-
| TclArrayBoolean || myArrayBoolean : TclArrayBoolean; || Array definition indexed by boolean.
|-
| TclArraySingle || myArraySingle : TclArraySingle; || Array definition indexed by single.
|-
| TclArrayWord || myArrayWord : TclArrayWord; || Array definition indexed by words.
|-
| TClArrayExtended || myArrayExtended : TClArrayExtended; || Array definition indexed by extanded.
|-
| Create || myArray := TClArrayInteger.Create; ||
|}
   
   
To be able to use it, it must be created in the form.
To be able to use it, it must be created in the form.

Revision as of 08:59, 6 November 2023

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 myArrayInteger : TclArrayInteger; Array definition indexed by integers.
TclArrayString myArrayString  : TclArrayString; Array definition indexed by string.
TclArrayDouble myArrayDouble : TclArrayDouble; Array definition indexed by double.
TclArrayBoolean myArrayBoolean : TclArrayBoolean; Array definition indexed by boolean.
TclArraySingle myArraySingle : TclArraySingle; Array definition indexed by single.
TclArrayWord myArrayWord : TclArrayWord; Array definition indexed by words.
TClArrayExtended myArrayExtended : TClArrayExtended; Array definition indexed by extanded.
Create myArray := TClArrayInteger.Create;

To be able to use it, it must be created in the form.

myArray := TClArrayInteger.Create;

To reach the array size, you need to use the count parameter.

myArray.Count;

To add an element to the array;

myArray.Add(50);

'GetItem' is 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.

myArray (50 , 100, 70, 12, 3)

myArray.GetItem(1)

If you want to delete your entire directory you can use "RemoveAll".

myArray.RemoveAll;

"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".

myArray.RemoveAt(5);

Example:

var

 MyForm : TclForm;
 myArray : TClArrayInteger;
 iIndex : Integer;
begin MyForm := TclForm.Create(Self); myArray := TClArrayInteger.Create; 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;
MyForm.Run; end;