Focal Point
[SHARING] Code indentation with dialog manager

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

August 26, 2015, 05:04 AM
Wep5622
[SHARING] Code indentation with dialog manager
Let me start with a little anecdote about how this post came to be:

We have a fairly fresh colleague here with a background in programming C on embedded systems. This person was using some existing WebFOCUS code (by yours truly) as an example of how to implement a nested loop in his own report. So far so good.

What he added into the mix was that he indented the bodies of the nested loops to make the code more readable.

For some reason this resulted in the server becoming rather unresponsive, and upon investigation it turned out that the tscom3 process serving his request had eaten up over 8GB of system memory already! There was nothing in the report to warrant that, so obviously something was wrong.

Removing the indentation, the report behaved as normal again, so that was the obvious solution. However, we did like the indentation that we just lost. Obviously, we didn't give up there, or this would have been a different kind of post.

As it turns out, it is possible to indent dialog manager code as long as you keep the dash at the first column instead of indenting it along with the rest of the statement!

Here's an example:
-TYPE Here we start a loop
-REPEAT :LOOP1 FOR &I1 FROM 1 TO 10;
-	TYPE Looping... &I1
-	REPEAT :LOOP2 FOR &I2 FROM 1 TO 3;
-*		Here's a comment; unfortunately indenting the * causes the editor to
-*		no longer recognize the lines as a comment. Not sure about the parser.

-		SET &ITEM = (&I1 -1)*3 + &I2 -1;
-		TYPE Sub-loop &ITEM
-	:LOOP2
-:LOOP1


I don't know whether this is officially supported and from which version it is if so. Any official word? It seems useful.


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 :
August 26, 2015, 11:03 AM
Tamra
Wep5622

I am following up with your "Sharing" topic.

From my training (Noreen - FOCwizard) many years ago I was taught that dialogue manager commands must always start in column 1 only. This goes back to MainFrame days.

The following is from the FOCUS 7.7 Developing Reporting Applications user's manual

Without a leading hyphen, this is interpreted as a FOCUS command.

The following is from the WebFOCUS 7.7.05 Developing Reporting Applications user's manual -


When creating a procedure , you must follow these rules:
◾Dialogue Manager commands begin with a hyphen. Other commands do not.
◾At least one space must be inserted between the Dialogue Manager command and other text.
◾If a Dialogue Manager command exceeds one line, the following line must begin with a hyphen (-) in the first position. The continuation line can begin immediately after the hyphen, or you may insert a space between the hyphen and the rest of the line.

For those who might be interested this is how Dialogue Manager processes the lines within a focexec that has '-' statements (again from the above documentation) :


Dialogue Manager Processing:

You can modify your application at run time with user input and environment conditions by using Dialogue Manager procedures, which include commands and variables. It is important to understand how Dialogue Manager processes commands and variables of an application, using a procedure.

Dialogue Manager executes a procedure as follows:

1.Dialogue Manager reads each line of the procedure one by one, and substitutes values for variables when encountered.
You must make sure to assign values or identify defaults for all variables. Otherwise, you will receive an error message indicating a missing value. In Developer Studio, you are prompted for values not already assigned.

2.All Dialogue Manager commands execute as soon as Dialogue Manager reads them.
Other WebFOCUS commands are temporarily stored for subsequent execution, which are called stacked commands.

3.The -RUN and -EXIT commands execute any stacked commands.


I hope the above helps provide some clarity. Dialogue manager commands must start in column 1.

Thank you for participating in the Focal Point Forum.

Kindest regards,
Tamra Colangelo
Focal Point Moderator
Information Builders Inc.


WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
August 26, 2015, 11:43 AM
Wep5622
What you just pointed out is precisely the reason I shared the info at the top, as it isn't obvious from the description from IBI that it is (apparently) also legal to have spaces between the hyphen and the actual dialog manager statement.

Apparently, these are identical from the point of view of DM:
-TYPE Looping... &I1
-	TYPE Looping... &I1


That is NOT obvious! All the docs talk about DM statements such as -TYPE, -SET, etc.
I only thought of experimenting with this because I know that when continuing a DM statement on a next line you must start the line with a hyphen, but are allowed to add white-space after the hyphen.

It looks like the starting hyphen in DM statements is only used to indicate that the following keyword will be a DM keyword, regardless of whether that comes immediately after the hyphen or after some white-space.


This is a behaviour of the DM parser that doesn't appear to be documented.
Whether it is safe to assume that it will also behave as such in the future is perhaps another matter. That's one of the reasons that I figured sharing this info might be useful - I would like to know whether that's a sage assumption or not?


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 :
August 26, 2015, 06:02 PM
Waz
Interesting......


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

August 27, 2015, 09:30 AM
jgelona
To be honest, I have never given this much thought, but have a different method of making DM more readable. I space things vertically instead of horizontally.
-TYPE .
-TYPE . Here we start a loop
-TYPE .
-*
-REPEAT :LOOP1 FOR &I1 FROM 1 TO 10;
-*
-TYPE .
-TYPE . Looping... &I1
-TYPE .
-*
-REPEAT :LOOP2 FOR &I2 FROM 1 TO 3;
-*
-*		Here's a comment; unfortunately indenting the * causes the editor to
-*		no longer recognize the lines as a comment. Not sure about the parser.
-*
-SET &ITEM = (&I1 -1)*3 + &I2 -1;
-TYPE .
-TYPE . Sub-loop &ITEM
-TYPE .
-*
-:LOOP2
-*
-:LOOP1


I will concur that FOCUS/WebFOCUS does not like '- *'. We did that by accident once and ran the job. It was a comment in the middle of a TABLE request and the Reporting Server froze. I've also had the Reporting Server freeze because of a missing ; in a COMPUTE statement in MODIFY.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
August 27, 2015, 05:51 PM
David Briars
quote:
...making DM more readable. I space things vertically instead of horizontally.

+1




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
August 27, 2015, 06:02 PM
Waz
Agreed,

Dialog Manager can be difficult to read when its all bunched up.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

August 28, 2015, 02:18 AM
Dave
-******************************************
-* BEGIN: customer loop
-******************************************

CODE
CODE
CODE

-******************************************
-* END: customer loop
-******************************************


That's what I usually do.
Mind you, in the editor I've set the backgroundcolor of the comment to something else than the default. For better visibility.

G'luck,
Dave



Post 500 ! Music


_____________________
WF: 8.0.0.9 > going 8.2.0.5
August 28, 2015, 03:35 AM
Tony A
quote:
Post 500 !

Congratulations Dave - Just don't go calling people "grasshopper"!

Or is that too 70's for people and therefore before many peoples memories? Wink

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 28, 2015, 06:01 PM
George Patton
But Dave, If you subsequently happen to open the fex in the GUI, all the nice white space in between the sections gets eliminated - and of course comments within TABLE aren't allowed ....


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
August 31, 2015, 02:33 AM
Dave
George,

that is sad, but true.


_____________________
WF: 8.0.0.9 > going 8.2.0.5
August 31, 2015, 06:19 AM
Danny-SRL
quote:
it is possible to indent dialog manager code as long as you keep the dash at the first column

Goodness!
Who ever thought of doing it otherwise???


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

August 31, 2015, 09:05 AM
jgelona
quote:
Originally posted by George Patton:
But Dave, If you subsequently happen to open the fex in the GUI, all the nice white space in between the sections gets eliminated - and of course comments within TABLE aren't allowed ....


Which is another reason why that I almost never use the GUI.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
September 02, 2015, 01:00 PM
GavinL
Code indention is a Windows code standard, so most of us Windows developers prefer that over vertical spacing.. Though I'm not opposed to vertical spacing, I just use it within my indented code as well. Smiler

Good find!



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
September 02, 2015, 01:16 PM
j.gross
quote:
as long as you keep the dash at the first column


Historically, first or second (apparently to facilitate dynamically generated code)


- Jack Gross
WF through 8.1.05