xsharp.eu • No compiler error
Page 1 of 1

No compiler error

Posted: Fri Nov 17, 2023 2:57 pm
by Horst
Hello

This line makes no compiler error +self

Code: Select all

	cHtml 			+= +SELF:odbKontroll:FIELDGET(#Kontroller) 
Horst

Re: No compiler error

Posted: Fri Nov 17, 2023 5:24 pm
by Chris
Hi Horst,

I think that strictly speaking this is not an error, because the expression returned by SELF:odbKontroll:FIELDGET(#Kontroller) can be a number (since FIELDGET returns a usual), and the +/- unary operator is valid for numbers. Using the plus sign might sound strange, but it's the same as using the minus sign, which is valid in the case of a number:

nNumber += -SELF:odbKontroll:FIELDGET(#Kontroller)

This is adding the negative value of the field, of course it would make more sense to use -= in the first place, but still, this is valid syntax.

Of course in your case you are using a string variable, in which it is not valid to add/subtract a number, but I don't think the compiler can be made that smart to recognize this (since it does not know the return value type of FIELDGET). Unless Robert has a different idea..

Re: No compiler error

Posted: Mon Nov 20, 2023 10:27 am
by robert
Horst, Chris,

This is valid syntax. The usual type supports both the unary plus and unary minus operations.
The result of that operation is then casted to a string for the += operation with cHtml.

Robert