[SOLVED] How to add 's or ' to the end of a variable
Hi, This is my first post on this forum, so please be kind.
I need to add either a 's or ' to the end of my variable, depending on if the variable ends in an "s" or not.
For example: John's Snapshot or Lucas' Snapshot
I can do this with JavaScript with the code below, but I'm not sure how to do this with the WebFOCUS Language. Thanks in advance.
function setFirstName() { var s = (local_ibi_client_fname.charAt(local_ibi_client_fname.length-1) == 's')? "'" : "'s"; document.getElementById('client_fname').innerHTML = local_ibi_client_fname + s + " Snapshot"; }This message has been edited. Last edited by: <Kathryn Henning>,
If you're planning on using that variable in any FOCUS expression, such as a DEFINE or WHERE clause, make sure to suffix it with .QUOTEDSTRING instead of enclosing it in single quotes as that apostrophe in the data may cause some issues.
-* In a DEFINE expression
DEFINE FILE BLAH
FULL_NAME/A60 = &FN_NEW.QUOTEDSTRING;
END
...
TABLE FILE BLAH
PRINT ....
WHERE NAME EQ &FN_NEW.QUOTEDSTRING
END