Forum > Beginners

Array properties [SOLVED]

(1/3) > >>

pascal111:
في شذرة الكود التالي والتي في هذا الرابط https://www.freepascal.org/docs-html/current/ref/refsu35.html#x88-1100006.7.3 - الذي يشرح خصائص الأصناف من نوع المصفوفة - لا أرى أي إعلانٍ لمصفوفة أم أنّ إعلان المصفوفة يكون بداخل الـ methods ولا أعتقد ذلكـ ﻷنّها بذلكـ تكون مصفوفة مؤقّتة أم أنّ هذا أسلوب مصفوفة ديناميكيّة ؟

google translate:

"In the following code snippet "chunk" which is in this link https://www.freepascal.org/docs-html/current/ref/refsu35.html#x88-1100006.7.3 - which explains the properties of the classes of the array type - I don't see any array declaration or is the array declaration inside the methods and I don't think so because it is thus a temporary array or is this a dynamic array style?"


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Type    TIntList = Class    Private      Function GetInt (I : Longint) : longint;      Function GetAsString (A : String) : String;      Procedure SetInt (I : Longint; Value : Longint;);      Procedure SetAsString (A : String; Value : String);    Public      Property Items [i : Longint] : Longint Read GetInt                                             Write SetInt;      Property StrItems [S : String] : String Read GetAsString                                              Write SetAsstring;    end;   

ASerge:

--- Quote from: pascal111 on May 17, 2021, 02:39:36 pm ---I don't see any array declaration or is the array declaration inside the methods and I don't think so because it is thus a temporary array or is this a dynamic array style?"

--- End quote ---
From the mentioned documentation "These are properties that accept an index, just as an array does."

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---property Items[i: LongInt]: ...property StrItems[S: string]: ...

Handoko:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---property Something[i : Sometype] //  is an array property.
Don't be confused with the static array or dynamic array. They all have similarity but different.

lucamar:
The point is that the programmer accesses the property as if it were an array, no matter what the actual implementation is: it might be a real array, some container class (e.g. TStrings ot TList) or whatever, but from the class user point of view it behaves (mostly) as an array.

Some examples are TComponent.Components[] and TWinControl.Controls[], which are implemented through an internal TFPList.

pascal111:

--- Quote from: lucamar on May 17, 2021, 04:02:16 pm ---The point is that the programmer accesses the property as if it were an array, no matter what the actual implementation is: it might be a real array, some container class (e.g. TStrings ot TList) or whatever, but from the class user point of view it behaves (mostly) as an array.

Some examples are TComponent.Components[] and TWinControl.Controls[], which are implemented through an internal TFPList.

--- End quote ---

من كلامكـ أفهم أنّ الخاصيّة تُربط بنوع بيانات ما قد يكون مصفوفة حقيقيّة أو حاوية ... الخ ،وأنّ هذا الربط يكون داخليّاً كما في حالة TComponent.Components[] و TWinControl.Controls[] ،ولكن أين يكمن هذا الربط الداخلي حيثُ لو كان بداخل الـ methods لكان مؤقتاً فأتوقع أن يكون داخل بنية الصنف نفسها أي عند بناء الصنف ليكون مثلاً شحن الخاصيّة بالبيانات دائماً طيلة فترة حياة الكائن؟

google translate:

"From your words, I understand that the property is linked to some type of data, which may be a real array or container ... etc., and that this connection is internal as in the case of TComponent.Components [] and TWinControl.Controls [] , but where is this internal linking "laying" "for whereas" where if it was inside the methods, it would have been temporary, so I expect it to be inside the class structure itself, i.e. when building the class so that, for example, shipping "assigning" the property with data is permanent throughout the life of the object?"

Navigation

[0] Message Index

[#] Next page

Go to full version