Forum > General

Default parametrs doesnt work

<< < (2/3) > >>

Zoran:
Mas Steindorf, you are wrong; when two parameters are passed, the compiler will treat the second parameter as the second parameter and the third parameter will get the default parameter.
As Jamie says, this should compile, but only in objfpc or delphi modes.

Quote from the documentation:

--- Quote ---The compiler must be in OBJFPC or DELPHI mode to accept default values.
--- End quote ---


--- Quote from: KodeZwerg on September 28, 2022, 12:25:33 am ---
--- Quote from: Parthen on September 27, 2022, 10:30:06 pm ---
--- 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";}};} ---procedure ScreenWrite(Character: String; CharacterColor: Word = DefaultColor; BackgroundColor: Word = DefaultBgColor);
--- End quote ---

--- 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";}};} ---procedure ScreenWrite(const Character: String; const CharacterColor: Word = DefaultColor; const BackgroundColor: Word = DefaultBgColor);This should fix your problem.

--- End quote ---

What? Const should not make a difference with this.

Kays:
Meanwhile
--- 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";}};} ---{$modeSwitch defaultParameters+}is sufficient if you prefer a different mode other than {$mode objFPC}/{$mode Delphi}.

Parthen:

--- Quote from: jamie on September 27, 2022, 10:55:26 pm ---Do you have {$MODE ObjPas} at the top of your source?

--- End quote ---

No, I dont know anything about it. Google also doesnt have info about it, may you give me some documentation for this?

Parthen:

--- Quote from: Kays on September 28, 2022, 01:31:26 am ---Meanwhile
--- 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";}};} ---{$modeSwitch defaultParameters+}is sufficient if you prefer a different mode other than {$mode objFPC}/{$mode Delphi}.

--- End quote ---

Okay, this helps me. Thanks!

PascalDragon:

--- Quote from: Parthen on September 28, 2022, 07:44:38 am ---
--- Quote from: jamie on September 27, 2022, 10:55:26 pm ---Do you have {$MODE ObjPas} at the top of your source?

--- End quote ---

No, I dont know anything about it. Google also doesnt have info about it, may you give me some documentation for this?

--- End quote ---

The $Mode directive is an important part of FPC ($ModeSwitch is as well). You can read more about the modes here.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version