Focal Point
DM Challenge to IB Developers

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

May 03, 2007, 08:26 AM
hammo1j
DM Challenge to IB Developers
Can we have

-BLOCK_IF expression ;

-BLOCK_ELSE_IF expression ;

-BLOCK_ELSE
-BLOCK_END_IF

Sometime or even just.

-BLOCK_IF

-BLOCK_ENDIF

This one should be easy as well

-PERFORM label
.
.
.
-label

-RETURN

Can all this be done with a simple push down stack of the current line to be executed.

For reasons unknown, this might be harder than I think - if so could someone post reasons.

It may be because fixing this is not seen as a selling point - however when I show other programmers the -GOTO based syntax in DM, people start to dismiss wf as a cosmetic job on some Mainframe dinosaur language.



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
May 03, 2007, 02:30 PM
RickW
DM HAS been around since the dinosaur mainframe days - early 80's I think. The FOCUS core language and DM are still the heart of the WF product - and there's really nothing wrong with that at all.

http://en.wikipedia.org/wiki/FOCUS

I suppose you could always request CASE/subroutine DM usage as a new feature - makes sense to me.

All these years I still hear people bad mouth FOCUS. These are the same people who also think PERL, PHP, Python are also "dinosaur" languages and are also probably the ones who think anything without a GUI isn't worth using as a programming tool.

It's just different.


WebFOCUS 7.6.6/TomCat/Win2003,SQL Server 2005,Oracle
May 16, 2008, 10:54 AM
Ingas
Hallo!

DM is very frustrating and not for only novices.

I suppose that's the better thing can be done - freeze this language.
It's good enough for some tasks, but many times I've thought how much better if instead of DM was some modern dynamic-typed language.

Python, Perl, Ruby, server-side JavaScript, Lua - all are good enough.

Maybe like embeddable module allowing substitute DM, maybe like in CGI-scripts - first comment is about script-language (by default - DM)


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
May 16, 2008, 11:43 AM
hammo1j
quote:
-PERFORM label
.
.
.
-label

-RETURN

Can all this be done with a simple push down stack of the current line to be executed.


This is the crucial one that would produce huge returns on a minimal effort.

Infact I would say it's the biggest cost benefit that could be realised in the whole of WebFOCUS.

A good coder could do this in less than a day since the dm processor will have address of next statement available.

1. -PERFORM label

is

PUSH next statement
-GOTO label

2. -RETURN

is

POP next statement
-GOTO next statement



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
May 16, 2008, 02:38 PM
Alan B
In the old days, and I haven't done this for years, we used to do:
-TYPE 1
-SET &RETURN = ':LABEL1';
-GOTO :LABEL2
-:LABEL1
-*
-TYPE 2
-*
-EXIT
-*
-:LABEL2
-*
-TYPE 3
-*
-GOTO &RETURN

or something like that, to try and emulate the GOSUB effect. Now I can't be bothered.


Alan.
WF 7.705/8.007
May 16, 2008, 02:52 PM
j.gross
It would not be such a radical departure from the current DM language. An inline-block-oriented control structure already exists:

-REPEAT label n TIMES
...
-label

When n evaluates to false (=0) or or true (=1), this accomplishes the same as the missing inline conditional execution structure.

But at present (7.6.5) n has to be a constant or a DM variable; expressions are not allowed.

Allowing n to be a parenthesized DM expression that yields an integer would not seem to be such a challenge.


And/or, establish a suitable syntax for conditional execution, say

-DO label IF condition;
...
-label

and handle its execution like

-REPEAT label (condition) times.


- Jack Gross
WF through 8.1.05
May 16, 2008, 06:55 PM
jodye
Hi

I know using GOTOs feels ancient, but doesn't this accomplish exactly what you want? Am I missing something?

Jodye

-SET &ECHO=ALL;
-SET &X=2;

-IF &X=1 THEN GOTO DO_1 ELSE IF &X=2 THEN GOTO DO_2 ELSE GOTO DO_ELSE;

-DO_1;
-TYPE DO_1
-*CODE GOES HERE
-GOTO ALLDONE;

-DO_2;
-TYPE DO_2
-*CODE GOES HERE
-GOTO ALLDONE;

-DO_ELSE;
-TYPE DO_ELSE
-*CODE GOES HERE

-ALLDONE;
-TYPE ALLDONE

-EXIT



WF 8.0.0.5M
May 18, 2008, 04:22 AM
Danny-SRL
John,

Between Alan and Jodye one can have all the constructs that one might need. Also, never forget that DM is a pre-processor, a sort of "conditional assembly" that generates the code that will later run against data files. The whole concept of DM is a very powerful one and very few languages can match it.
As for those who look down upon GOTOs, let them try to do with their tools what WF can do with DM.

And a little caveat for Jodye. I know that DM will accept -IF &X=1 THEN GOTO ... but the correct syntax is -IF &X EQ 1 THEN GOTO ...
Also a semi-colon should not appear after a label.
One day, a "tighter" version of WF might not accept it and then OUCH!


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

May 18, 2008, 01:26 PM
susannah
HERE'S the link to the doc on looping
http://documentation.informationbuilders.com/masterinde..._lang436/02cat97.htm
the REPEAT WHILE might be work exploring, john.
i agree whole-heartedly with jodye and alan et.al., DM (being careful to distinguish DM Dialogue Manager from DM Data Migrator) is infinitely flexible and pricelessly valuable, and Danny's well-said explanation that "its a 'pre-processor' that actually structures the code" puts this tool in the proper perspective for the newbies.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
May 18, 2008, 02:27 PM
FrankDutch
I agree on some user complain that DM is not so easy if you are used to modern tools, but a good start would be reading the manuals and ask for a proper course before diving into the coding.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

May 18, 2008, 11:42 PM
Waz
A a dinosaur myself (started on MF Focus 4.5), I agree with Danny.

DM is a scripting language, and with that you can do almost anything, including have DM create or manipulate your reports on the fly.

Just keep in mind that this is FOCUS not "Python, Perl, Ruby, server-side JavaScript, Lua".

If you want to use those, call them from DM. Smiler

Why not try to think like a Focus programmer, learn and use DM. With a little imagination you can accomplish anything. Idea


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!

May 19, 2008, 01:17 AM
Danny-SRL
Waz!

quote:

Why not try to think like a Focus programmer, learn and use DM. With a little imagination you can accomplish anything.


I agree with you wholeheartedly: DM is for the WF magicians: there is no limit. Add to that techniques such as "McGuyver" and "alternate masters" and it is an always renewed challenge with much gratification.


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

May 19, 2008, 04:12 AM
hammo1j
I agree that you can build all modern computing structures with an IF and a GOTO but it is messy and error prone in that logic has to be reversed which is why those new structures were created.

Alan B

Your construct is fine if you have one level of invocation; you would need a stack structure to fully implement psuedo-perform. But your example is very clear in showing how simple it would be for IBI developers to implement.

There is no reason why modern constructs cannot be entered into dm. It is merely a pre-processor of which many languages make use eg C, PL/1 etc but a pre-processor is doubly ideal for an interpreted language since you have code that writes code.

Again out of the box great thinking to come up with using REPEAT WHILE as a simple if block (you would have to disable the condition in the block at some point to ensure only one iteration).

The problem I find with this is that it confuses someone who is maintaining your code and unless it is a standard becomes very difficult to justify.

The other type of IF block I use (got idea off forum) is

-SET &CMNT = IF condition THEN ' ' ELSE '-*' ;
&CMNT.EVAL code1
&CMNT.EVAL code2
...

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



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
May 19, 2008, 12:08 PM
Ingas
Hallo all!
Excuse me, my post was not right thread.

But my opinion remains the same - DM is ...
(it's just a simple preprocessing language. Maybe TOO simple)

I can't understand about "dinosaurs" - most of modern languages influenced by Scheme, Lisp, Smalltalk
I can't understand this "Think like FOCUS programmer".

I'm a fan of FOCUS - it's really powerful language.
I'm not a fan of DM.
And FOCUS is NOT easy, DM IS easy.

And it's so easy today to find good embeddable dynamic-typing language.
With good IO, elegant syntax, powerful string manipulations.


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
May 19, 2008, 01:17 PM
Darin Lee
While I am not opposed to change, I believe that the adage "If it ain't broke, don't fix it" applies very well. They could add some additional functionality to DM that may make some things easier - and then you have more DM commands that you needs to know i.e. more complexity. I could simply ignore the new stuff if I chose to do so. Smiler

With the handful of DM commands that currently exist, all of the funtionality mentioned above can be accomplished. It has existed for thirty-some years with little change, which can be said for VERY few languages/software packages. The highly complex applications I have created simply would not be possible without DM, so in my mind, the FOCUS language and DM are inseparable.

Like butter and toast - if I can't have butter on my toast, I'll skip the toast for today.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
May 19, 2008, 04:22 PM
cburtt
As one who got started with those 'oldies' like BAL, RPG, Fortran, PL/1, COBOL, Clist, and EXEC (and never got into the new stuff like Java, Perl, C, and C++), I think of DM as the programming language that writes your program code.

Programming your program ... what a concept, what flexability, what power!


WIN/2K running WF 7.6.4
Development via DevStudio 7.6.4, MRE, TextEditor.
Data is Oracle, MS-SQL.
May 19, 2008, 06:48 PM
Waz
quote:
DM ROCKS!!!

Its good to know I am in the company of other purists.


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!

May 20, 2008, 07:46 AM
GamP
Don't know about the purity of DM, but it certainly enables the good old-fashioned focus users to do whatever they need to do.
And yes, maybe it would be nice to have some funtionality added that could make our life a little bit easier. Until then we;l just keep on using our existing knowledge of the language and be happy with it.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
May 20, 2008, 08:32 AM
Ingas
I suppose that I'm misunderstood.

I think that:

1. DM is good enough. It does not needed to add functionality in it.
2. It should be good if there was alternatives.

Let me explain second point.
I can even today run scripts written in Perl, python, ruby etc... Because DM can run external programs.

Problem is efficiency - most of this languages have long start. Start interpreter, load script, compile P-code, run P-code in VM ..

This problem not exists when language is embedded. Lua, for example, adds only 4Kb(!) to binaries.
Look at
list of applications using Lua in this mode.

I'm a fan of python.
And I'm thinking now about writing python-FOCUS bridge. Python for IO, SOAP, string manipulation (generation FOCUS statements on fly, master-file definitions on fly, SQL on fly) , FOCUS - for databases and final output.

When I get results, I'll wrote about this.

Best regards,
Alex


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
May 20, 2008, 08:35 AM
linus
I LOVE DM!! It's the heart and soul of FOCUS and WF. And it's FUN to code! Smiler


WF 7.7.05
HP-UX - Reporting Server, Windows 2008 - Client, MSSQL 2008, FOCUS Databases, Flat Files
HTML, Excel, PDF
May 20, 2008, 08:42 AM
Ingas
cburtt,

"Programming your program" this concept have name - Metaprogramming.

It's old as programming itself.
In lisp-family - it's the main concept. "Programmable programming language"

Most languages have support for metaprogramming of some kind. Some strong, some weak.

DM support for metaprogramming is quite weak. Because it's all about string manipulation and DM does not very good for this tasks


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
May 20, 2008, 01:55 PM
jodye
quote:

And a little caveat for Jodye. I know that DM will accept -IF &X=1 THEN GOTO ... but the correct syntax is -IF &X EQ 1 THEN GOTO ...
Also a semi-colon should not appear after a label.


You know what.. I have a nasty habit of sometimes using EQ and sometimes =. It gets me into trouble all the time. And I always use a semicolon with a label and it always works. I guess it is not required though.

I agree with everyone else. DM feels like it is super old... with the gotos. But you can accomplish anything.

Reminds me of learning BASIC in school. Hey anyone else remember LOGO? Man I used to have fun with that in 1983 or so...

http://en.wikipedia.org/wiki/Logo_(programming_language)


WF 8.0.0.5M
May 20, 2008, 02:05 PM
Danny-SRL
Sure I remember LOGO. I even wrote a whole set of functions to output Mandelbrot fractals!


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

May 20, 2008, 07:17 PM
susannah
Danny , you are coming to summit yes??? You i gotta meet!




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
May 20, 2008, 07:47 PM
Dave Ayers
quote:
This one should be easy as well

-PERFORM label
.
.
.
-label

-RETURN



I too, would very much like to see a PERFORM command in Dialog Manager.

I've gotten used to that type of program structuring in Maintain and other languages.

I believe that it promotes better code, both for ease of design, writing, self documentation, and later maintenance. Sure I can write programs with -GOTO's, but I've never been happy with them since I got used to performs, functions, procedures, and such. If IBI can expand DM without a lot of pain, they should do so.

Its not like they have a Microsoft-like lock on the BI market, they need to do all they can to make WebFocus a better product, for many types of programmers !


Regards,
Dave

http://www.daveayers.com

WebFocus/Maintain 7.6.4-8
on Win2000 and 2003 Server
May 20, 2008, 11:40 PM
Waz
Expanding DM would be great, I remember when I first found out about -REPEAT, it was brilliant.

Several years ago, I heard a rumer that DM would be dropped (I think from Dev Studio).

The important thing is that you can still code the process, even if the a single command doesn't exist.


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!

May 21, 2008, 07:25 AM
Danny-SRL
For the PERFORM enthusiasts an idea with a bit of code:
  
-* File perform1.fex
-SET &PERFORM='-GOTO ';
-SET &RETURN='-GOTO ';
-*
-* LOTS OF CODE
-*
-SET &BACK='#NEXT1';
&PERFORM.EVAL #ABC
-#NEXT1
-TYPE RETURNED HERE
-SET &BACK='#NEXT2';
&PERFORM.EVAL #XYZ
-#NEXT2
-TYPE RETURNED ELSEWHERE
-*
-* LOTS OF CODE
-*
-SET &BACK='#NEXT3';
&PERFORM.EVAL #ABC
-#NEXT3
-TYPE RETURNED AGAIN
-*
-EXIT
-*
-#ABC
-TYPE ARRIVED THERE
&RETURN.EVAL &BACK
-*
-#XYZ
-TYPE ARRIVED FURTHER
&RETURN.EVAL &BACK



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

May 21, 2008, 09:01 AM
Tony A
I take it that you are very busy then Daniel? 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 
May 21, 2008, 09:26 AM
jgelona
You guys are making this too hard. Want to do a PERFORM? Just do a -INCLUDE.

Take the code you want to PERFORM, put it in its own fex and do a -INCLUDE.

You can even make the command conditional. Here's some pseudo code.
-SET &PERFORM=IF TEST IS TRUE THEN'-INCLUDE FEXNAME' ELSE '-*';
&PERFORM.EVAL


You can even take it one step further and have FEXNAME be conditional.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
May 21, 2008, 09:34 AM
Danny-SRL
Tony,
A roundabout way to say, toungue-in-cheek, that in 99% of the procedures, a PERFORM is not really necessary. Wouldn't you agree?
BTW, coming to the Summit?


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