Focal Point
help with functions

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4861092442

August 28, 2007, 04:59 PM
serenekk
help with functions
Hi all,
I'd like to upcase a string that has a comma in it like a string 'This is good, but make it better.' How can I do an upcase on it?
I have it like this:
&STR = 'This is good, but make it better.'
-SET &STRLEN=&STR.LENGTH;
-SET &TMPLNGTH = 'A' || &STR1LEN;
-SET &UPSTR = UPCASE(&STRLEN,&STR, &TMPLNGTH );

this wont work because the string has upcase.

Also after upcase, I need to use strrep function on this to take out the comma.
Can somebody help with both functions?
Thanks,

KK


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
August 28, 2007, 05:09 PM
Francis Mariani
-SET &ECHO=ALL;

-SET &STRING1 = 'This is good, but make it better.';

-SET &STRING1A = STRIP(&STRING1.LENGTH, &STRING1, ',', 'A&STRING1.LENGTH');

-SET &STRING1B = UPCASE(&STRING1A.LENGTH, &STRING1A, 'A&STRING1A.LENGTH');

-TYPE GOOD: &STRING1
-TYPE BETTER: &STRING1B



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
August 28, 2007, 05:12 PM
serenekk
comma in the string represents 2 inputs though. so if I have something like this:
1, 2, 3, 4, 5 in a string, those each word seperated by commas are to be treated as input for something to search on..


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
August 28, 2007, 05:14 PM
Francis Mariani
I don't understand. You said you wanted to "take out the comma".


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
August 28, 2007, 05:35 PM
serenekk
sorry, somehow it got posted before I finished typing. Sorry for the confusion, let me explain the whole thing what I was trying to accomplish.
Yes. Comma(s) will be taken out before or after the whole string is upper cased. those commas will be replaced with an OR.
For example, if input string is
'Web, Focus, Sort, Search' etc
I am turning it into a where statement something like
WHERE DESCRIPTION EQ 'WEB' OR 'FOCUS' OR 'SORT' OR 'SEARCH';

for the end-user, s/he will be inputting the string 'Web, Focus, Sort, Search' in a text area on a lunch page.

to get that where statement, the requuirements are that they should be up-cased, and replace comma with an or for each comma.

What is the best way to get this done?
Thanks so much in advance,
KK


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
August 28, 2007, 05:55 PM
Leah
Have you considered the multiselect or in a drop down list?


Leah
August 28, 2007, 06:07 PM
serenekk
yes but wont work since there are just so many. The users will type in for their input in a text area box.


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
August 29, 2007, 12:19 AM
susannah
kk,
how about the OVRLAY function to replace the , with an ' OR '.
Do you hve the 4th manual in the series, the FUNCTIONS manual? Have a look thru the entire section on TEXT functions. Good stuff there.
The POSIT and/or GETTOK functions you might like, as well.
The UPCASE function should be working fine for you, i can't see why it won't.
I perfer the ARGLEN function to the &var.LENGTH way. I get a more accurate answer. the .LENGTH will count trailing blanks...
-s.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
August 29, 2007, 02:46 AM
Tony A
STRREP will do the job for you -
-SET &StrInput  = 'Web, Focus, Sort, Search';
-SET &StrOutput =
- UPCASE(100,''''||STRREP(&StrInput.LENGTH,&StrInput,2,', ',6,''' OR ''',98,'A98')||'''','A100');
-? &Str

Although I would suggest a method with (possibly) less effort would be to change your WHERE field EQ to WHERE field IN and then have your list comma seperated and within braces -
WHERE DESCRIPTION IN ('WEB','FOCUS','SORT','SEARCH')

BTW, please update your signature (see the "sticky" topic on the topic list page) so that we can gauge our responses to you, knowing your platform and release.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 29, 2007, 08:39 AM
jgelona
kmafu,

Your original statement is incorrect, the ',' had nothing to do with the UPCASE working. The problem was with your code.

-SET &STR = '#Web#,#Focus#,#Sort#,#Search#';
-SET &UPSTR = UPCASE(&STR.LENGTH,'&STR.EVAL','A&STR.LENGTH');
-* Convert # to '
-SET &UPSTR = CTRAN(&UPSTR.LENGTH,'&UPSTR.EVAL',35,39,'A&STR.LENGTH');


Now your WHERE becomes

WHERE DESCRIPTION IN (&UPSTR)

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


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
August 29, 2007, 08:56 AM
serenekk
Thanks very much, All!
I will definitely try these answers. Will post back following up on this if I have more questions later today or tomorrow.
Again, Thanks!
KK


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
August 29, 2007, 09:02 AM
dhagen
quote:
for the end-user, s/he will be inputting the string 'Web, Focus, Sort, Search' in a text area on a lunch page.


Why not just use JavaScript to do this?


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
August 29, 2007, 11:50 AM
susannah
Stefaans
they work just fine. all the way thru 762.
the specs are very specific.
code tightening over the versions may have caused any problems you have encountered.
If you follow the rules, they work like a charm.
-s.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
August 29, 2007, 12:05 PM
hammo1j
THIS SHOULD BE IN THE MANUAL WOULD SAVE A GREAT DEAL OF TROUBLE.

The problem people get with functions not working with dm is that dm will try and establish the datatype on the fly thus '0' will be translated to double precision.

Force the issue by coding your alpha arguments using

(a) ASIS
(b) Concatenation of a blank on the end (dont worry if the string goes past its length )
eg '0' | ' ' will always be treated as string.



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
August 29, 2007, 12:26 PM
Stefaans
Hi All
I have started working on this one, but am busy at work. I think Susannah is the closest.
What I am working on is to take the string and POSIT the comma and shorten the string to Posit + 1 to end of string. The use ARGLEN to determine the length of the new string.
As this is Dialogue manager, either use this in a repeat loop or a goto until the length of the string is LE to 0.
The main point is to write the part from the beginning of the string to just before the comma (each time) TO A FILE.
THEN

TABLE FILE MYFILE
PRINT *
WHERE DESCRIPTION IN FILE EXTERNAL FILE.
END
This should cater for predicate values less than 4000 chars long.
I have had to do this many times over the past 18 years

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


WebFOCUS 7.7.01 Windows, TSO 7.0
August 29, 2007, 01:17 PM
susannah
"Savannah"...i like it...i'm changing my handle right away!




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
August 29, 2007, 01:34 PM
Stefaans
Oh Susannah, I am so sorry Smiler but I know that you are a big enough person to tolerate a typo.
sincerest regards Steve


WebFOCUS 7.7.01 Windows, TSO 7.0