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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
FocCount behavior
 Login/Join
 
Gold member
posted
Anyone notice that simply referencing (not assigning values to) a field name in an empty datasource stack changes FocCount from 0 to 1? For example, if I have a datasource stack, stkABC and my code does the following:

stack clear stkABC;
reposition datasource1.SEGNAME.KEY_FIELD;
for all next KEY_FIELD into stkABC where KEY_FIELD eq "some value";

Let's say this returned 0 records so stkABC is still empty and FocCount should still be zero.

Then I do this:

Compute Var1 = stkABC().KEY_FIELD;

I guess Var1 would be assigned NULL or "" or something. Not sure since if I do a:
Type "Var1 = " Var1; in my code it just prints:

Var =

Anyway, after this I want to check the FocCount of stkABC in an IF statement to either do something or not, for example:

if stkABC.FocCount eq 0 then
form1.Button1.enabled = 0;
else
form1.Button1.enabled = 1;

Problem is this IF statement will evaluate as false because after the Compute statement that referenced stkABC().KEY_FIELD, stkABC.FocCount now equals 1 not 0, even though I know that stkABC is actually empty (or is it actually not?).

I know I can work around this by checking to see if stkABC.FocCount is 0, and if it is, not executing any code that even just references stkABC or stkABC() or stkABC(row number) if I want to intentionally keep stkABC.FocCount at 0 when stkABC is empty.

The dynamic behavior of stacks in the Maintain language is really helpful but it would nice if the manuals made it clear that just referencing an empty stack or field in an empty datasource stack either changes just the FocCount of that stack from 0 to 1 or actually creates a row in that stack and changes FocCount. It would have saved me a few hours of debugging.

I guess I would think that unless an empty stack is referenced on the left side of an assignment statement, the stack should remain empty and the FocCount of that stack should remain at 0. If it's referenced on the right side of an assignment statement, that should not affect the stack in any way.

Just curious on other peoples' thoughts on this.


FOCUS 7.7.03
WebFOCUS 8.0.x/8.1
z/OS, Windows
 
Posts: 54 | Location: Everett, WA | Registered: September 27, 2005Report This Post
Virtuoso
posted Hide Post
I think I must have got used to this behaviour now. I remember hitting this issue years ago and having the same sort of thoughts as you.

My understanding, which could be wrong, is that this is to do with FocIndex rather than FocCount. As you know FocIndex can never be zero or less. By referencing a stack, FocIndex cannot be zero, so defaults to 1, ergo the stack has a FocCount of 1. I cannot remember now, but I think FocCount will always keep track of FocIndex if FocIndex goes above FocCount.

I think your solution of checking FocCount before running code sounds the most sensible, though I have a feeling I also check the value of a key field, which cannot be blank, in the stack(1).

Now I tend to run fexes to collect data, if the data collection could return zero records, and only use Next when it is a certainty that data will be retrieved.

I am not sure about the documentation (it's a while since I read it!), but I always cover this in training courses. So perhaps it should be covered better to bring in the element of least surprise.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Master
posted Hide Post
Gentlemen
I can explain the reaon for this, but I agree that the behavior is not great. The reason is, whenever you reference a value or row in a stack, that row or value will automatically exist. So the line:
Compute Var1 = stkABC().KEY_FIELD;
Creates a row 1 in stkABC and gives KEY_FIELD either blank or 0 depending on its format and stkABC.FOCCOUNT goes to 1. The problems I have seen are with this scenario:

For all next Moviecode into stk
Where category eq 'XXX';
Compute Stk.NewField/a10;

After the Next statement, stk.foccount = 0 since there are no records that match this WHERE clause. However, when we compute the NewField into the stack, we not only add the column to the stack, but a row as well with all blank or 0 values. So, Stk.foccount = 1.

This issue has been in programming for a while, but there has been no good solution. To get around it, I find myself using:

If stk(1).moviecode ne '' then ...

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders