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.
today I was again surprised by an awkwardly strange behaviour of one WebFOCUS function, yet not suprised to much as I have experienced the same awkwardness with other features and functions in this so-called powerful tool.
My today's favorite is STRREP - which is meant to replace all string occurences (param #4) in an input string (param #2). Usually this works as expected - BUT:
Have you tried using this one with an input string shorter than the search string. Well you might say: what's the point in doing so - simple answer: when using dynamic strings you cannot a-priori tell what will be in there. (I stumbled accross this problem btw. when trying to use STRREP on multi-selection strings from an HTML page - replacing the ' OR ' with a comma+space - for input strings with a length < 6 this won't work)
You won't get your PAPA back - instead an empty string is returned. Even worse: in some versions of WF (I "successfully" tried 7.7.01)using the a.m. construction in a DEFINE FUNCTION part leads to an agent crash. At least this crash seems to have been fixed in 7.7.03
In every other computer language where you can script or program with strings a similar function would just return the in-string, as the string-to-replace can never be found. But ... "Hocus-Pocus-Focus" ... WF doesn't.
So - again a check + exception handling is needed to test the dynamic string length and avoid performing a STRREP if instr.length < repstr.length. Pain in the ...
Cheers, LinneThis message has been edited. Last edited by: linnex,
Syntax of the STRREP procedure: STRREP (inlength, instring, searchlength, searchstring, replength, repstring, outlength, outstring) The manual states that 'searchlength' must be less than or equal to 'inlength' (searchlength: Is the number of characters in the (shorter length) string to be replaced). In your case it is not. If you expand the string to be searched to at least 6 charcaters, you do get the original string in case the search string can't be found. It is not documented however that it should return an empty string when something is not correct. You might want to bring that to the attention of IB tech support by opening a case.
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
The manual states that 'searchlength' must be less than or equal to 'inlength'
I do not quite agree - that the restriction is stated there, for me it is only "hinted". IMHO: A standard documentation should state: "The search length must be less than the in-string length" or similar.
Well, I must admit I have read this passage of "shorter length" after I had my superb experience with STRREP + multiple agent crashes. One might assume that this "shorter length" refers to the instr - nevertheless this is still at least strange. But of course you are right, that the result actual result returned is not at all documented. I will consider opening a case here.
Nevertheless I am happy to have given you that catchy tune
I've always been a little perplexed about why I need to tell WF how long strings are in the first place. It can't figure out the length of 'abc' on its own?
J.
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007
The FUSELIB routines were originally either written in FORTRAN, or written to be callable from FORTRAN.
It's been a while (), but as I recall the FORTRAN function-call protocol just passed the address of the variable (or of a copy of its value), without supplying any info on the "type" of the argument. For that matter, there was no native Character data type -- we would sneak them into arrays of one of the numeric types.
And, since they were "contributed" to the library, without "editing" or peer review, you got a hodgepodge of length-then-value and value-ten-length designs for the parameter list. (Even the RJUST, LJUST, CENTER trio are not consistent.)
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
Yep, that's it. As I remember it, it is called parameter passing by reference. You only pass the memory address of the first byte of the parameter, which is why you really do need the length to be specified also and why you can't figure out what size string you have been passed.
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
-- the output option string can be 1 to 5 characters long (e.g., 'Y' and 'YYMDX'). If shorter than 4, the value is blank-padded to a full word. But if it's 4 -- e.g., 'YYMD' -- what assures that the next word in memory does not start with T (or X), which would (mis)lead the routine to convert the month to alpha?
-Jack
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
In this special case, literal strings are being passed (the values are within quotes). In that case the parameters are not passed by reference, but by value. The receiving function will have to cater for the maximum number of characters passed. What makes you state that if it is shorter than 5, it gets padded to a full-word?
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
What makes you state that if it is shorter than 5, it gets padded to a full-word?
That's the way it is (or was) in FORTRAN, in the 360 spawning ground of FOCUS -- all allocated variables and literals would start on whole-word boundaries, so the remainder of the last word of a character literal (if length is not a multiple of 4), would be padded with blanks.
It may be platform-dependent.
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005