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 trailing spaces to a string to make it fixed length?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[solved] How to add trailing spaces to a string to make it fixed length?
 Login/Join
 
Platinum Member
posted
I have some input strings of which the length are different. Is there a function I can patch it with trailing spaces to make it fixed length?

example:

'F121' -> 'F121 ' (A5)
'bdd' -> 'bdd ' (A5)

Thanks!

This message has been edited. Last edited by: bug,


7.66 and 7.704
System: Windows / AIX / Linux
Output: Mostly HTML, with some PDF, Excel and Lotus(!)
 
Posts: 147 | Location: Toronto (GTA) | Registered: May 25, 2005Report This Post
Expert
posted Hide Post
I do this....
quick & dirty

-DEFAULT &mystring = '123';
-TYPE &mystring  &mystring.LENGTH
-SET &mystring = &mystring | '     ';
-SET &mystring = EDIT( &mystring.QUOTEDSTRING, '99999');
-TYPE &mystring  &mystring.LENGTH




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
Platinum Member
posted Hide Post
This works Smiler

Thanks!


quote:
Originally posted by susannah:
I do this....
quick & dirty

-DEFAULT &mystring = '123';
-TYPE &mystring  &mystring.LENGTH
-SET &mystring = &mystring | '     ';
-SET &mystring = EDIT( &mystring.QUOTEDSTRING, '99999');
-TYPE &mystring  &mystring.LENGTH


7.66 and 7.704
System: Windows / AIX / Linux
Output: Mostly HTML, with some PDF, Excel and Lotus(!)
 
Posts: 147 | Location: Toronto (GTA) | Registered: May 25, 2005Report This Post
Virtuoso
posted Hide Post
Could not resist using one of my favourite techniques, which is useful if there are many variables with different length requirements:
DEFINE FUNCTION VARFILL (STRING/A200,LENGTH/I3)
VARFILL/A200V=SUBSTV(200,STRING,1,LENGTH,VARFILL);
END
-RUN

-DEFAULT &mystring = '123';
-TYPE &mystring  &mystring.LENGTH
-SET &mystring = VARFILL(&mystring.QUOTEDSTRING,5);
-TYPE &mystring  &mystring.LENGTH


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Virtuoso
posted Hide Post
Be aware of the special case where the value of &mystring is FOC_NONE or _FOC_NULL. You would end up with 'FOC_N' or '_FOC_' respectively, neither of which do what's expected of them.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
Good point.
DEFINE FUNCTION VARFILL (STRING/A200,LENGTH/I3)
LENGTH/I3 = IF STRING LIKE 'FOC_%' OR STRING LIKE '_FOC_%' THEN ARGLEN(200,STRING,'I3') ELSE LENGTH;
VARFILL/A200V = SUBSTV(200,STRING,1,LENGTH,'A200V');
END
-RUN

-DEFAULT &mystring = 'FOC_NONE';
-TYPE &mystring  &mystring.LENGTH
-SET &mystring = VARFILL('&mystring.EVAL',5);
-TYPE &mystring  &mystring.LENGTH

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
Platinum Member
posted Hide Post
And don't forget FPRINT (though you're 766 version may not have access to it, you're 7704 will)

-DEFAULTS &STR1='F121';
-TYPE &STR1 &STR1.LENGTH
-SET &STR1TYPE=IF &STR1.TYPE EQ N THEN I ELSE A;
-SET &STR2=FPRINT('&STR1.EVAL',&STR1TYPE.EVAL&STR1.LENGTH,'A5');
-TYPE &STR2 &STR2.LENGTH



In FOCUS since 1985 - WF 8.009/8.104 Win 8 Outputs: ALL of 'em! Adapters: Sql Server Teradata Oracle
 
Posts: 161 | Location: Dallas, TX | Registered: February 20, 2009Report 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 trailing spaces to a string to make it fixed length?

Copyright © 1996-2020 Information Builders