Focal Point
DEFAULTing an &VAR with another &VAR.. cool trick

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

June 22, 2007, 11:03 PM
susannah
DEFAULTing an &VAR with another &VAR.. cool trick
at Summit, i learned this
-DEFAULT &STARTDAY = &YYMD.EVAL ;
-TYPE &STARTDAY

sometime back, one of us had wanted to initialize a startdate with a variable value like a system date, and then allow the launch page to override it.
And I learned how to do this at dinner at Summit from the FocWizard himself. Its just the .EVAL that makes it work! So simple, but who knew?




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
June 23, 2007, 04:37 AM
FrankDutch
O Sussanah....
that was me who asked this and I knew the .eval but the thing is I still want the prompt to appear with that calculted day, so the enduser can overwrite that value, I'm afraid that does not work.
it needs some javascripting...




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

June 23, 2007, 06:41 AM
<JJI>
Susannah,

Sorry, but Frank is absolutly right. Even with the wfdescribe = XMLPROMT is does not work, I tested this in WF 7.1.4 and in 7.6.0.
This will never work unless Information Builders start handeling the autopromt differently. The reason why it does not work now is very simple. WF cannot distinct the amper variables to prompt for and the amper variables to resolve before the autoprompt starts. The new -DEFAULTH won't change that!
June 23, 2007, 10:47 AM
susannah
rats. well, lets see if Focwizard has his ears on...and see what he can do for us...
I've got it working fine from a ss launch page...not autoprompt, tho .. hmmm.

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




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
June 25, 2007, 12:52 PM
FocWizard
Unfortunately, that's a problem with how AutoPrompting is done. It only does a SCAN of the lines, NOT an execution, looking for amper variables which have not been initialized. Since a '.EVAL' function would require execution, it's not done. This is the same reason, if you code:

-INCLUDE &FILE

the contents of '&FILE' can NOT be scanned, as the value of &FILE is only known at execution time.

The closest I can get to doing what you want, is to set a -DEFAULT for the variables you want, with the values you want, PRIOR to execution (perhaps created by a batch job each night).

For example, if I want 'STARTDATE' to default to a value of YESTERDAY, I can run a batch job, which creates a FEX (I'll call it DEF_STARTDATE), which looks like:

-DEFAULT &STARTDATE= whatever ;

Where 'whatever' has the VALUE needed. If run on 07/06/25, and you need it to have the prior days' date, it would say:

-DEFAULT &STARTDATE = 070624;

Then, any procedure which NEEDS this default, could code:

-INCLUDE DEF_STARTDATE

since we CAN look at 'real' included files.
June 25, 2007, 03:05 PM
Francis Mariani
What about something like this:

- filedef a temp fex file
- write into the fex file
- include the fex file

SET DEFCENT = '20';

FILEDEF DEFAULT1 DISK DEFAULT.FEX
-RUN

-WRITE DEFAULT1 -DEFAULT &|DATE1='&MDY.EVAL' 

-INCLUDE DEFAULT1

TABLE FILE GGORDER
PRINT
*
WHERE ORDER_DATE LE '&DATE1'
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
June 25, 2007, 04:34 PM
susannah
so,Francis, can the user override the &DATE1 from a launch page or from a prompt?
(i'm prompt-impaired in devstu, at the moment).




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
June 25, 2007, 04:53 PM
Francis Mariani
My guess is Yes, because the -DEFAULT line that's generated by the -WRITE and -INCLUDE is a normal one, with no .EVAL in it.


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
June 25, 2007, 05:38 PM
Alan B
The point about autoprompt, as FocWizard said, is that there is only a scan of the code prior to the autoprompt generation. The code is not run, ergo a -WRITE or FILEDEF etc cannot be completed before the autoprompt kicks in.

What will happen in this case is that the user would enter a value and then the -WRITE and -INCLUDE kick in when the code does run, after the autoprompt.

The only way is to have a pre-existing file to -INCLUDE. Then the user will get a value displayed that can be overridden by the user.


Alan.
WF 7.705/8.007
June 25, 2007, 05:41 PM
Francis Mariani
Understood. But why would the pre-existing -INCLUDE execute before the auto-prompt?

And what, really, is the use of auto-prompt? Most of the users I have worked with would be bewildered if they get a screen of the type that auto-prompt generates. Wouldn't it be nicer to develop an HTML page that collects the required user input?


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
June 26, 2007, 01:27 AM
Alan B
The pre-existing -INCLUDE is brought in as its content is part of the host process, and may effect what the autoprompt needs to generate.

And whilst I agree that an HTML page is superior, the number of posts that it generates tells us that many find it useful.


Alan.
WF 7.705/8.007
June 26, 2007, 02:47 AM
Tony A
Alan is absolutely correct in that the HTML page is superior (or preferable for some) over the auto-prompt screen.

That said, my current Client's user base is very used to the auto-prompt screen (and in fact loves it?) but there are occasions when the need to chain some inputs is required. So what I have done is mimiced the auto-prompt screen with a combination of base page with a frameset and a parm screen so that the chaining can be achieved without too huge a change to the experience - we all know that Users hate change!! There is even the option to run in new window, blat the output frame of a report, or refresh the page. The end users know little difference but they moved over to it easily.

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 26, 2007, 03:45 AM
Alan B
Back to the original question, how to set a date as a default value for automprompt.

Taking another slight step on the techniques that FocWizard and Francis have come up with, a method by which you can now calculate a date (or other values) and have it displayed as a default in autoprompt, without having to run to batch type approach, though it is a bit of overkill.

In the server edasprof (ibi\srvnn\wfs\etc\edasprof.prf), add
FILEDEF DEFAULT1 DISK DEFAULT.FEX
-RUN
-WRITE DEFAULT1 -DEFAULT &|DATE1='&MDY' 
-*You can also do date calculations here as well.


In your focexec
-INCLUDE DEFAULT1
.
.
WHERE dateField EQ '&DATE1';
.
.

(Thanks to Francis and FocWizard)


Alan.
WF 7.705/8.007
June 26, 2007, 09:10 AM
Francis Mariani
A good solution Alan, that I hope to never have to use, since I hope I'm never asked to use auto-prompting!

Cheers.


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
June 26, 2007, 09:26 AM
FrankDutch
I like that solution Alan, especially if I can calculate the actual and previous month and write more than one versions of the default fex.
this can be done unattended and daily (monthly)
I would put those fexes in my baseapp.




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