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     Curious behaviour with SUBSTR function

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Curious behaviour with SUBSTR function
 Login/Join
 
Expert
posted
In the code below, the expected length for &USER_NAME is 15, but it's set to 17. Anyone know why?

-SET &ECHO=ALL;
-SET &USER_FNAME = 'Francis                                           ';
-SET &USER_LNAME = 'Mariani                                           ';

-SET &USER_NAME1 = &USER_FNAME || (' ' | &USER_LNAME);

-SET &ARGL1 = ARGLEN(&USER_NAME1.LENGTH,&USER_NAME1,'I3');

-* SUBSTR(inlength, parent, start, end, sublength, outfield)
-SET &USER_NAME =
-  SUBSTR(&USER_NAME1.LENGTH, &USER_NAME1, 1, &ARGL1, &ARGL1, 'A&ARGL1');

-TYPE USER_NAME1 &USER_NAME1.LENGTH XXX &USER_NAME1 XXX
-TYPE USER_NAME  &USER_NAME.LENGTH XXX &USER_NAME XXX

Thanks.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
Interesting. If you add .EVAL to ' A&ARGL1' in the SUBSTR function, you get the right length. Someone explain that one.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Expert
posted Hide Post
quote:
(&USER_NAME1.LENGTH

i'm thinking its the .LENGTH thing.
I've gotten different results using .LENGTH and using ARGLEN. so i only use ARGLEN now, unless i'm absobloodylutely sure that the .LENGTH of some inbound parm can never be user-tinkered-with.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Master
posted Hide Post
Fran

Your syntax is incorrect - you are passing the length as the string AamperARGL1. WF is allowing but misinterpreting this.

Correct syntax is

Either

quote:
- SUBSTR(&USER_NAME1.LENGTH, &USER_NAME1, 1, &ARGL1, &ARGL1, 'A&ARGL1.EVAL');


or

quote:
- SUBSTR(&USER_NAME1.LENGTH, &USER_NAME1, 1, &ARGL1, &ARGL1, 'A' | &ARGL1);


Susannah

.length and ARGLEN are two different things

ARGLEN searches from the right to find the first non blank character.

.length is the length of a dm variable including any trailing blanks.

Regards

John



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
Virtuoso
posted Hide Post
Francis, this is actually less weird than you think.

Darin is correct, the .EVAL works.

What is happening is that the 'A&ARGL1' is literally being passed to the function. You can get the same result by using 'XYZ' or ' ' as the last parameter. The functions are ignoring bad formats. The only weirdy is that the default format is A17, and this applies to other functions, not just SUBSTR.

You could use (as well as .EVAL)
-SET &AL = 'A' | &ARGL1;

-SET &USER_NAME =
- SUBSTR(&USER_NAME1.LENGTH, &USER_NAME1, 1, &ARGL1, &ARGL1, '&AL');

or,

-SET &USER_NAME =
- SUBSTR(&USER_NAME1.LENGTH, &USER_NAME1, 1, &ARGL1, &ARGL1,TRUNCATE(&USER_NAME1));

(- SUBSTR(&USER_NAME1.LENGTH, &USER_NAME1, 1, &ARGL1, &ARGL1, 'A' | &ARGL1); won't work John)

which brings me to the point that to remove trailing spaces, the TRUNCATE function simply works,
-SET &USER_FNAME = 'Francis                                           ';
-SET &USER_LNAME = 'Mariani                                           ';
-SET &USER_NAME1 = &USER_FNAME || (' ' | &USER_LNAME);
-SET &USER_NAME = TRUNCATE(&USER_NAME1);

or

-SET &USER_FNAME = 'Francis                                           ';
-SET &USER_LNAME = 'Mariani                                           ';
-SET &USER_NAME = TRUNCATE(&USER_FNAME) | ' ' | TRUNCATE(&USER_LNAME);

would avoid a lot of coding.

This message has been edited. Last edited by: Alan B,


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Expert
posted Hide Post
Thank you everyone. I forgot I should be using .EVAL in the format argument of a function.

quote:
-SET &USER_FNAME = 'Francis ';
-SET &USER_LNAME = 'Mariani ';
-SET &USER_NAME = TRUNCATE(&USER_FNAME) | ' ' | TRUNCATE(&USER_LNAME);


Alan B, thank you for that simple solution using TRUNCATE.

Cheers.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report 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     Curious behaviour with SUBSTR function

Copyright © 1996-2020 Information Builders