Forum > General

Default values in property?

(1/2) > >>

egsuh:
Is there any way that I can assign default values to property? Method's default values are not applied automatically. 


      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;                 

SymbolicFrank:
Assign it a value in the constructor?

egsuh:
Actually problem is I can't use in following way.

    s := AQMessage(100);
   

KodeZwerg:
Show your problem with more than 1 line of code would help us to help you.
How about to upload a small demo project that cover your problem?

SymbolicFrank:
So, you have a function, GetMessage, that might not give a "proper" result, in which case you want to return some default value?


--- 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";}};} ---function GetMessage: string;begin  Result := DEFAULT_VALUE;   try    Result := GetTheMessage;  finally  end;end;

Navigation

[0] Message Index

[#] Next page

Go to full version