[CASE-OPENED] Bug in WF handling &VARs for output formats
Dear all,
I was wondering if you might help me to check if the problem I found is a real WebFOCUS bug (and probably also existing on different versions). I had some issues and discussions with WF support in the past so I would love to show them that my cases are "real bugs" first.
-SET &TEST_STR = 'ABCDEFGHIJKLMNOPQRSTU';
-* tmp variable has been used previously
-SET &TMP = '123';
-* now we use &TMP again for defining the Ax format (could also be done statically: = 'A8')
-SET &LEN = 1;
-SET &TMP = 'A' || &LEN;
-TYPE &TMP
-* do a substr (or any char function using &TMP='Ax'
-TYPE SUBSTR(&TEST_STR.LENGTH, &TEST_STR.QUOTEDSTRING, 2, &LEN + 1, &LEN, '&TMP');
-SET &TEST_STR = SUBSTR(&TEST_STR.LENGTH, &TEST_STR.QUOTEDSTRING, 2, &LEN + 1, &LEN, '&TMP');
-TYPE &TEST_STR.QUOTEDSTRING
Using the a.m. code, I would assume that the resulting &TEST_STR would be 1-char long (as I have assigned -SET &TMP='A1' actually. For my WF version the result is however a string containing a single "B" + 12 spaces - so length=13. What actually happens is: WF is not clearing the previously assigned text in &TMP correctly. Eventhough you cannot see it when -TYPEd - '&TMP' used in SUBSTR seems to contain 'A83'. If you add another figure to -SET &TMP=123, say 4, the '&TMP' will act as 'A134'.
I am using WF 7.7.03 HF6.
Workaround found: using &TMP.QUOTEDSTRING
Could you confirm that this problematic behavour is also valid for your WF version?
Thanks and best regards LinneThis message has been edited. Last edited by: linnex,
WebFOCUS 7.7.03
June 18, 2013, 06:16 AM
MichaelBalle
works fine in Verions 7.6.5:
-SET &TEST_STR = 'ABCDEFGHIJKLMNOPQRSTU';
-* tmp variable has been used previously
-SET &TMP = '123';
-* now we use &TMP again for defining the Ax format (could also be done statically: = 'A8')
-SET &LEN = 1;
-SET &TMP = 'A' || 1;
-TYPE A1
A1
-* do a substr (or any char function using &TMP='Ax'
-TYPE SUBSTR(21, 'ABCDEFGHIJKLMNOPQRSTU', 2, 1 + 1, 1, 'A1');
SUBSTR(21, 'ABCDEFGHIJKLMNOPQRSTU', 2, 1 + 1, 1, 'A1');
-SET &TEST_STR = SUBSTR(21, 'ABCDEFGHIJKLMNOPQRSTU', 2, 1 + 1, 1, 'A1');
-TYPE 'B'
'B'
WebFOCUS 7.6, 7.7 Windows, All Output formats
June 18, 2013, 07:12 AM
linnex
Thanks Michael for checking.
Seems that they have introduced this "new behaviour" in 7.7.?
WebFOCUS 7.7.03
June 18, 2013, 05:43 PM
Waz
Works in 7.1.6, 7.6.6, 7.6.12 and 8.0.02M, but does not in 7.7.03
Waz...
Prod:
WebFOCUS 7.6.10/8.1.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!
June 19, 2013, 04:37 AM
linnex
Hi Waz, thanks for testing it in multiple versions. This is greatly appreciated.
Cheers Linne
WebFOCUS 7.7.03
June 19, 2013, 04:50 AM
linnex
Have opened a mior case. Just in case the problem is not yet known and "remains" in the 7.7.0+ line.
Thanks again to Michael and Waz for your tests.
WebFOCUS 7.7.03
June 19, 2013, 05:01 AM
Tony A
Using the .EVAL extension works in 7.7.03, which is how I would have coded it anyway.
-SET &TEST_STR = 'ABCDEFGHIJKLMNOPQRSTU';
-* tmp variable has been used previously
-SET &TMP = '123';
-* now we use &TMP again for defining the Ax format (could also be done statically: = 'A8')
-SET &LEN = 1;
-SET &TMP = 'A' || &LEN;
-TYPE &TMP
-* do a substr (or any char function using &TMP='Ax'
-TYPE SUBSTR(&TEST_STR.LENGTH, &TEST_STR.QUOTEDSTRING, 2, &LEN + 1, &LEN, '&TMP.EVAL');
-SET &TEST_STR = SUBSTR(&TEST_STR.LENGTH, &TEST_STR.QUOTEDSTRING, 2, &LEN + 1, &LEN, '&TMP.EVAL');
-TYPE &TEST_STR.QUOTEDSTRING
-SET &TEST_STR = 'ABCDEFGHIJKLMNOPQRSTU';
-* tmp variable has been used previously
-SET &TMP = '123';
-* now we use &TMP again for defining the Ax format (could also be done statically: = 'A8')
-SET &LEN = 1;
-SET &TMP = 'A' || 1;
-TYPE A1
A1
-* do a substr (or any char function using &TMP='Ax'
-TYPE SUBSTR(21, 'ABCDEFGHIJKLMNOPQRSTU', 2, 1 + 1, 1, 'A1');
SUBSTR(21, 'ABCDEFGHIJKLMNOPQRSTU', 2, 1 + 1, 1, 'A1');
-SET &TEST_STR = SUBSTR(21, 'ABCDEFGHIJKLMNOPQRSTU', 2, 1 + 1, 1, 'A1');
-TYPE 'B'
'B'
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
June 19, 2013, 10:09 AM
j.gross
Let me add to Tony's remarks.
When amper variable substitution is performed on Focus commands (i.e., fex lines without a leading "-"), it is done by a process that is essentially innocent of any knowledge of Focus-command syntax, and the substitution is mechanical.
But within a dialog manager directive, substitution is generally not performed in scanning the line, absent an explicit .EVAL.
For example,
-DEFAULT &FOO = &BAR ;
results in the four-character string "&BAR" (rather than the current value of the variable named &BAR) becoming the value of &FOO.
Even in
-SET &FOO = &BAR ;
the lookup of the value of &BAR occurs in the execution stage, not in the parsing stage. If &BAR contains 1+2, it will set &FOO to '1+2', not 3.
If substitution is performed at all on the final arg "'&TMP'" in linnex's -SET, I believe it's an undocumented feature. Don't rely on such favors -- play it safe and control the process by using &var.QUOTEDSTRING or '&var.EVAL'.
- Jack Gross WF through 8.1.05
June 19, 2013, 10:27 AM
linnex
Hi,
thanks, Tony, for the suggestions using .EVAL and Jack for your explanation on the substition mechanisms.
I have now been working with WF for > 3 years and I have never seen a similar (programming) language before where you have so many "undocumented features" on which you should not rely etc. With WF it is really difficult to decide which one is a real feature (and will hopefully never be changed with a new version - which I have already experienced as well) and which is just "there" be coincidence...
FOCUS is really not one of my favorite computer languages and those "features" will not increase my liking of it