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    WebFOCUS/FOCUS Forum on Focal Point     [Solved] X+1=35 X+2=70?

Read-Only Topic
 Go Search Notify Tools
 [Solved] X+1=35 X+2=70?
Platinum Member
 posted April 17, 2018 04:08 PM
Hi Folks,
Let me begin by saying that this forum is great, thank you!

I've been at WebFOCUS for about 8 months now. I like it, but I just can't exaplain some of the stuff I see.

I've inherited some code and we've discovered a bug where some calculations are incorrect. The CNT_OCCS column isn't being calculated correctly. So I'm trying to teach myself how it is being calculated.

TABLE FILE OCCURRENCES
SUM
...
COMPUTE COUNTER/I9 = COUNTER + 1; NOPRINT
COMPUTE CNT_OCCS/I9 = CNT_OCC + 1; NOPRINT
BY LOWEST RECENCY NOPRINT
BY OCCURRENCES.FACT_OCCURRENCE.OCCURRENCE_NUMBER AS 'Occ #'
BY OCCURRENCES.FACT_OCCURRENCE.OCCURRENCE_SOURCE_KEY NOPRINT
...

My first issue (and I don't think any of you can solve it without seeing all the code) is that I have no idea where CNT_OCC is coming from. I've searched every fex file for that string with no success. The synonym doesn't have that string either. Anyway... don't worry about it... my biggest gripe is with the following...

What is really blowing my mind is that
COMPUTE CNT_OCCS/I9 = CNT_OCC + 1; NOPRINT
line.

If I output the value of CNT_OCCS I get 35. So that would mean that CNT_OCC is 34... right? Wrong... have a look at the lines below:

COMPUTE CNT_OCCS/I9 = CNT_OCC + 1; -*results in 35
COMPUTE CNT_OCCS/I9 = CNT_OCC + 2; -*results in 70
COMPUTE CNT_OCCS/I9 = CNT_OCC + 10; -*results in 350
COMPUTE CNT_OCCS/I9 = CNT_OCC - 1; -*results in -35

So what I can deduce by this is that CNT_OCC is 35, and that its calculating the product not the sum. I'm aware that 2(35) = 70, but why on earth does 35+2=70?

Can anyone explain that behaviour?

I'm just venting now... Can't I rely on the basic logic/arithmetic I learned in grade 1 (rhetorical question, but right now I'm thinking no)? That kind of logic where "+" means ADDITION and not MULTIPLICATION.

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

WebFOCUS 8201, SP 0.1, Windows 7, HTML

 Posts: 190 | Registered: May 19, 2017 IP
Expert
 posted April 17, 2018 04:37 PM Hide Post
Without reading ALL of your post, the first thing to consider is that CNT_OCC is CNT_OCCS. The default behaviour of WebFOCUS is to find the real column if a column (field) name is truncated. This is controlled by the SET FIELDNAME command. I don't think this default behaviour is helpful to developers.

So, most likely CNT_OCC is CNT_OCCS, and it's a simple counter of the number of rows in the output.

```COMPUTE CNT_OCCS/I9 = CNT_OCC + 1;
```
This adds one to the current value of CNT_OCCS, for each row in the output.

Try this:

```TABLE FILE CAR
PRINT
COMPUTE CNT_OCCS/I9 = CNT_OCC + 1;
BY COUNTRY
BY CAR
BY MODEL
END```

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

 Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005 IP
Platinum Member
 posted April 17, 2018 05:02 PM Hide Post
Thank you very much for your response.

Wait what? CNT_OCCS is CNT_OCC? Ok... I'm taking a breath... calming down...

That code you posted is a great example. But geez who wrote this FOCUS language? That's crazy. Stuff like that shouldn't be allowed. The only reason they are the same is because the right side happens to have the first few characters of the left side? That's not ok. We've seen i=i+1 in programming for years, but now iThisIsRidiculous=i+1 is equivalent.

To be clear, if the code read out like CNT_OCC = CNT_OCC + 1 I'd understand it to be incrementing a counter, but those are different names! That's so crazy!

Seems like every couple of weeks I find a new FOCUS-ism that defies logic (I think it does). GRRRRR...

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

WebFOCUS 8201, SP 0.1, Windows 7, HTML

 Posts: 190 | Registered: May 19, 2017 IP
Expert
 posted April 17, 2018 05:03 PM Hide Post
I think the missing piece is in some training I seem to remember that covered what happen internally from reading the data to outputting the report.

It gives perspective of why things don't seem to work as expected.

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!

 Posts: 6349 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006 IP
Expert
 posted April 17, 2018 05:12 PM Hide Post
quote:
CNT_OCCS is CNT_OCC?

WebFOCUS will check that the field name is a shortened longer name, and use that field.

Great for lazy programmers like me.

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!

 Posts: 6349 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006 IP
Platinum Member
 posted April 17, 2018 06:01 PM Hide Post
Like... wow... I don't know what to say... I'm baffled that WedFOCUS works like this. Is this behaviour considered a feature? I've read above that it can be explained and that there is a reason for this, but its stupid behaviour for a programming language.

X = X That makes sense

XAASEVASRGASEVASVE = X Makes no sense

And hey why stop there... Let's make...

green = grey 'cause they both start with g

52 = 48 'cause they are both even numbers

eggs_benedict = french_toast 'cause they are both made with eggs

Wow...

WebFOCUS 8201, SP 0.1, Windows 7, HTML

 Posts: 190 | Registered: May 19, 2017 IP
Expert
 posted April 17, 2018 06:21 PM Hide Post
A bit of fun, try this...

```ET GREEN = GREY
DEFINE FILE CAR
GREY/A10 = 'GREY' ;
END
TABLE FILE CAR
PRINT GREEN
BY COUNTRY
END
```

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!

 Posts: 6349 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006 IP
Virtuoso
 posted April 17, 2018 06:25 PM Hide Post
Shingles,

There are many more "features" to be found!

8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.

 Posts: 1113 | Location: USA | Registered: January 27, 2015 IP
Virtuoso
 posted April 17, 2018 06:26 PM Hide Post
LOLZ, Waz.

8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.

 Posts: 1113 | Location: USA | Registered: January 27, 2015 IP
Master
 posted April 17, 2018 06:33 PM Hide Post
quote:
Originally posted by Waz:

WebFOCUS will check that the field name is a shortened longer name, and use that field.

Great for lazy programmers like me.

Great until a later release and IBI decides to "tighten" their code and all the previous lazily written fexes break.

## Hallway

Prod: 8202M1
Test: 8202M4
Repository:

OS:

Outputs:

 Posts: 608 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015 IP
Expert
 posted April 17, 2018 06:45 PM Hide Post
quote:
IBI decides to "tighten" their code

Depends on whether its a bit of Gerry code....

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!

 Posts: 6349 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006 IP
Virtuoso
 posted April 17, 2018 07:32 PM Hide Post
Shingles

All this field name truncation aside, I would like to explain an important concept. When you COMPUTE a field the name you give it is a virtual name it doesn't have to exist anywhere else like in the synonym, you are creating it on the fly. Additionally when using DEFINE the calculation happens as each record is read but a COMPUTE is done after all the records have been read and they are in memory so you can get different results especially rounding differences. When you are truly doing a calculation you always want to use a COMPUTE to get the most accurate result. When you are doing a counter I think a DEFINE is the best way. My 2 cents...

Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats

 Posts: 2128 | Location: Customer Support | Registered: April 12, 2005 IP
Virtuoso
 posted April 18, 2018 03:58 AM Hide Post
`SET FIELDNAME = NOTRUNC`

Allowing unique truncations (of an existing fieldname to guess what the developer meant) is in my book a candidate for the worst ideas in ICT ever.

The problem is that it has a tendency to mask real errors caused by typos, incomplete renaming actions or lack of coffee.

Unfortunately, once introduced in a product, you can't simply get rid of it without breaking backwards compatibility.

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, 2010 IP
Expert
 posted April 18, 2018 09:16 AM Hide Post
quote:
a candidate for the worst ideas in ICT ever.

Agreed. A new column could be added to a table with the same set of beginning characters, and WebFOCUS would select it instead of the original column. - Correction after clarification by jgelona.

This message has been edited. Last edited by: Francis Mariani,

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

 Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005 IP
Master
 posted April 18, 2018 10:26 AM Hide Post
Shingles, green will not equal grey because green has no 'y' after the first e in green. Also, to be valid, a shorter, truncated, field name has to match only 1 real field otherwise there is an error. For example:
```COMPUTE CNT_OCCS/I9 = CNT_OCC + 1; NOPRINT
COMPUTE CNT_OCCD/I9 = CNT_OCC + 1; NOPRINT
```

Since CNT_OCC is not a real or virtual field, this will give an error because CNT_OCC now matches 2 fields.

On thing you'll learn is there are lots of SET commands (not -SET) that control how the FOCUS/WebFOCUS language works, like SET TRUNCATE. I've been using FOCUS/WebFOCUS since 1985 and this has always been a "feature" of the language.

In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.

 Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006 IP
Platinum Member
 posted April 18, 2018 10:35 AM Hide Post
quote:
Originally posted by jgelona:
Shingles, green will not equal grey because ...

I'm aware, I just took the ridiculousness up a notch. I don't really think that eggs_benedict = french_toast because they are both made with eggs.

WebFOCUS 8201, SP 0.1, Windows 7, HTML

 Posts: 190 | Registered: May 19, 2017 IP
 Powered by Social Strata

Read-Only Topic

Focal Point    Focal Point Forums    WebFOCUS/FOCUS Forum on Focal Point     [Solved] X+1=35 X+2=70?

Copyright © 1996-2020 Information Builders