« [Commentary] Happy New Year! | Main | [Article] Servoy & MySQL Mini HowTo »
January 06, 2006
[Gotcha!] Calc returning wrong string value
Today I debut a new category: Gotcha! Devoted especially to revealing those moments which at the time they happen you are fervently hoping the world is not peeking over your shoulder. Like the time I backed into my parents garage and took the garage door down in a huge crash because I forgot I had two four-wheelers loaded in the back of my truck. It was just my luck that half the neighborhood seemed to be out for a walk past our house that day.
About seven years ago (in Servoy years) I posted this post which listed a number of my favorite Servoy gotchas. Jim C. from down the road here got all of the answers right as I remember in the comments section. And as Marcel at Servoy World 2005 aptly demonstrated in a fascinating sessionthere are so many more embarrassing moments to discuss!
So to all of you...and meI devote this category. No longer will you have to live with those hidden deep dark moments when Servoy slapped you down in a particularly embarrasing way. In the name of therapy, send your "moments" to me so the world can read about it. You'll feel better...really. Better yet, tell me about someone else's "moment" and you'll feel even better!
(Special note: I am paying major royalties in beer for anonymous tips that catch Bob Cusick or Jan Aleman out.)
Today's Gotcha! is best described by quoting the original email to me:
======
3 fields, all in same table: rct_softcredit (num), rct_notes (text) and rct_notesview (calc: text).
rct_notesview:
if (rct_softcredit > 0)
{ return 'woof ' + rct_notes
}
It returns the contents of rct_notes. Where's 'woof'?
This is where it is eventually going:
if (rct_softcredit != 0)
{ return softdonor_to_contact.con_organization + ' | ' + rct_notes;
}
======
Help locate the missing dog. Post your answer in the comment section!
| Posted by David Workman on January 6, 2006 at 04:01 PM in Gotcha! | Permalink
Comments
Servoy Developer
Version R2 2.2.3-build 335
Java version 1.5.0_05-48 (Mac OS X)
OK, it works for me - I get the 'woof' so am I missing something planet sized ?
Cheers
Harry
Posted by: Harry Catharell | Jan 9, 2006 12:58:45 PM
Yes, the code does work! The problem occurs if the field "rct_notesview" is set as an RTF_AREA field on a form. Then "woof" gets added in front of all the rtf tags and so doesn't show up in the result as any text before the opening rtf tags is not displayed.
For the record, fields set to type RTF_AREA or HTML_AREA save a bunch of tags along with the text the user enters. So the actual string in the backend database is quite a bit different than what is actually displaying.
You can test this out by putting two versions of a the same field on a form. Set one to RTF_AREA and leave the other one as default. As you type in the RTF_area version, you can see what is really being saved in the normal field.
I think this is a pretty good Gotcha! :)
Posted by: David Workman | Jan 13, 2006 10:31:42 AM
I think that this is a very pertinent 'gotcha' as well, based upon a couple of threads on the Forum recently regarding HTML & RTF field types
OK, David, bring on the next one, then !?? :-)
Cheers
Harry
Posted by: Harry Catharell | Jan 14, 2006 9:21:10 AM