LotusScript Quiz: the "+" operator
As you (if you are a LotusScript developer ;-)) know,
- Msgbox "a" + 3 results in a type mismatch error.
- Msgbox "a" & 3 delivers "a3".
Now, do you know what the result of this line of code is?
B. 2.
C. A type mismatch error occurs
Solution: B - LotusScript tries to parse the string, and adds the two values.
This also works with strings like "1.1" or "1,1". In my Notes environment "," is the decimal seperator, so "1,1" + 1 results in 2,1 and "1.1" + 1 results in... 12.
The code does not work, however, with "1a" + 1, even though val("1a") returns 1. LotusScript seems to parse the string differently here - mh...
Still... please do NOT use this - this is evil coding ;-)
- Msgbox "a" + 3 results in a type mismatch error.
- Msgbox "a" & 3 delivers "a3".
Now, do you know what the result of this line of code is?
Msgbox "1" + 1
A. "11".B. 2.
C. A type mismatch error occurs
Solution: B - LotusScript tries to parse the string, and adds the two values.
This also works with strings like "1.1" or "1,1". In my Notes environment "," is the decimal seperator, so "1,1" + 1 results in 2,1 and "1.1" + 1 results in... 12.
The code does not work, however, with "1a" + 1, even though val("1a") returns 1. LotusScript seems to parse the string differently here - mh...
Still... please do NOT use this - this is evil coding ;-)




Last seen at...
1 Comments:
I'm surprised you didn't have to cstr("1" + 1).
I don't know if it's just old habit but I thought Msgbox couldn't convert numeric to string without an error.
Post a Comment
Thank you for your comment. It will be published shortly. Keep having a great day!
<< Home