Default value fo param in method

Hi,

Description of Elements says this:

Optionally, a default value can be provided via the := operator. If a default is provided, callers can omit the parameter in question, and the default will be used instead:

method DoSomething(aParameter: String := 'Use this by default.');

My method after I found out what is going wrong:

method MakeText(HeaderText, BodyText: System.String; KeepTogether : System.Boolean := false; alignment : System.Int32 := iTextSharp.text.Element.ALIGN_JUSTIFIED; SpacingBefore : System.Single := 20.0; NoSpacingBody : Boolean := false; paraSpacingAfter : System.Single := 10.0);

Debugger:

image

The method I used bevor, which is NOT working:

method MakeText(HeaderText, BodyText: System.String; KeepTogether : System.Boolean := false; alignment : System.Int32 := iTextSharp.text.Element.ALIGN_JUSTIFIED; SpacingBefore : System.Single := 20; NoSpacingBody : Boolean := false; paraSpacingAfter : System.Single := 10);

Debugger:

image

The default vale of 10 had been ignored

I have to change now all Methods now to .0, otherwise it is not interpreted as a figure.

Hmm…

Thanks, logged as bugs://84391

Hi,

what platform is this, and could you send us a (ideally minimal) test case that shows this? Also, can you rule out that it’s maybe just the debugger showing a bad value for the Double?

thanx!

Hi Marc,

no, debugger shows correct value, as I can see from Result of method.

Win10, VS 2015 Pro, Elements .2479

Mit freundlichen GrĂĽssen

Marcus van den Bergh

Geschäftsführer

asthenis GmbH

Signiert durch RSA (2048 Bits) und QR-Code:

image001.png

Hinweis: Diese Mail enthält eine digitale Signatur, die unter Unständen von Ihrem E-Mail Clienten als Anhang identifiziert wird, wenn der Client das Auswerten von Signaturen nicht unterstützt. Bitte ignorieren Sie die Signatur in diesem Fall.

Ok, a concrete testcase would be appreciated. Also, 2479 is rather old, can you try the most recent version, jic? thanx!

I will try newer Version and tell you.

It is any way not urgent as I found way around it

1 Like

Hi,

unfortunately I cannot give you any feedback as the project (after Update to stable build Jun) fails to compile. I have got 183 Errors

Declaration of const and variables shall be changed to static or public. Code, that was working over years without any problems shall be changed.

I am really fed up!!!

1 Like

Hi,

my apologies for this inconvenience. This actually is a bug fix, not a bug; global variables and constants accidentally had the wring visibility by default, public. They’re should always have been assembly; you can mark them as public explicitly if you want them visible outside of the current project,

eg

var x: String; public;  

Do not tell me that I have to declare all constants (which shall be by default static) to public now?

if you want them public, yes.

static != public. Consts are static, but the default visibility for all items is “assembly”, i.e. only visible in the current project. It’s always been — that consts and vars didn’t get the right visibility assigned was a bug.