Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to add 's or ' to the end of a variable

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] How to add 's or ' to the end of a variable
 Login/Join
 
Gold member
posted
Hi,
This is my first post on this forum, so please be kind. Smiler

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>,


WebFOCUS 8.2.03
z/OS
 
Posts: 66 | Registered: May 20, 2013Report This Post
Platinum Member
posted Hide Post
Hi,

How about this:

-*
-SET &FNAME = 'John';
-*-SET &FNAME = 'Lucas';
-*
-SET &FN_LST = SUBSTR(&FNAME.LENGTH, &FNAME, &FNAME.LENGTH, &FNAME.LENGTH, 1, 'A1');
-SET &FN_NEW = IF &FN_LST EQ 's' THEN &FNAME || ''' Snapshot' ELSE &FNAME || '''s Snapshot';
-*
-TYPE FNAME ------ &FNAME
-TYPE FN_LST ----- &FN_LST
-TYPE FN_NEW ----- &FN_NEW
-EXIT
-*

Give it a try and let me know.


WebFocus 8.201M, Windows, App Studio
 
Posts: 227 | Location: Lincoln Nebraska | Registered: August 12, 2008Report This Post
Gold member
posted Hide Post
Perfect! Thank you!


WebFOCUS 8.2.03
z/OS
 
Posts: 66 | Registered: May 20, 2013Report This Post
Virtuoso
posted Hide Post
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



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Expert
posted Hide Post
I would also syggest that you truncate or right justify the variable before getting the last char, just in case there are trailing spaces.

-SET &FNAME = TRUNCATE(&FNAME) ;
or
-SET &FNAME = RJUST(&FNAME.LENGTH,&FNAME,'A&FNAME.LENGTH') ;


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to add 's or ' to the end of a variable

Copyright © 1996-2020 Information Builders