Forum > General
Default values in property?
egsuh:
I'll rewrite the initial example.
--- 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 TMyObj = class public function GetMessage(RState: integer; lang: string=''; GoNext: boolean=false; ivExists: boolean=false; pid: integer=0; wave: integer=0): string; property AQMessage[RState:integer; lang:string; gonext, ivexists:boolean; pid, wave: integer]: string read getMessage; end; var MyObj: TMyObj;
With the above example, I can write: s := MyObj.GetMessage(100);
but not : s := AQMessage(100);
because I cannot define like:
--- 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 AQMessage[RState:integer; lang:string=''; gonext:boolean=false; ivexists:boolean=false; pid:integer=0; wave: integer=0]: string read getMessage;
And I'm asking whether there are any way that I can write: s := MyObj.AQMessage(100);
rvk:
--- Quote from: egsuh on March 29, 2023, 11:10:21 am ---I'll rewrite the initial example.
(...)
And I'm asking whether there are any way that I can write: s := MyObj.AQMessage(100);
--- End quote ---
So, AQMessage is more like a class function than a property/field, isn't it?
Then why not just use it as a class function and delete AQMessage (or rename GetMessage() to AQMessage())?
You don't have a single field for AQMessage (i.e. FAQMessage or something) so it shouldn't be a property.
KodeZwerg:
Make your arguments as properties and use AQMessage without any arguments, inside GetMessage use fields from the properties (overload that method to either being a getter or a standalone method)
Navigation
[0] Message Index
[*] Previous page