IB - Developer Center    Forums  Hop To Forum Categories  FOCUS/WebFOCUS    How to set default values for user input parameter
Go
New
Search
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Gold member
Posted
Hello, I'm launching my FOCEXEC files via custom HTML pages. On the page, I have a date text box - if the user doesn't fill it in, I want it to default to, say, 01/31/2001.

I tried:

-DEFAULT &FromDate = '20010131';

TABLE FILE T1
PRINT
COMPUTE temp/YYMD = &FromDate; AS 'From Date'
..
END

This always prints temp as a blank if I do not specify a date in the HTML start page. Am I doing something wrong?
 
Posts: 51 | Registered: September 29, 2004Reply With QuoteEdit or Delete MessageReport This Post
Platinum Member
Posted Hide Post
Hi There

Use this..

-DEFAULTS &FromDate = '20010131';

Jodye.
 
Posts: 163 | Registered: October 01, 2003Reply With QuoteEdit or Delete MessageReport This Post
Gold member
Posted Hide Post
Jodye, thank you for the reply. I tried changing "DEFAULT" to "DEFAULTS" but it did not fix the problem... Any other ideas?
 
Posts: 51 | Registered: September 29, 2004Reply With QuoteEdit or Delete MessageReport This Post
Platinum Member
Posted Hide Post
Hi BIGPGO

Yes. you must disable the "prompt for parameters" flag in dev studio. Uncheck it. Then try it. I just did that for this and it works.

-DEFAULTS &FromDate = '20010131';
TABLE FILE CAR
PRINT
MODEL
COMPUTE temp/YYMD = &FromDate; AS 'From Date'
END
 
Posts: 163 | Registered: October 01, 2003Reply With QuoteEdit or Delete MessageReport This Post
Master
Posted Hide Post
Put the COMPUTE value in quotes:

COMPUTE temp/YYMD = '&FromDate'; ...

Assignment to a date variable expects a date variable, or date variable +/- integer offset, or string constant representing a compatible date, on the RHS.
 
Posts: 532 | Location: NYC | Registered: January 11, 2005Reply With QuoteEdit or Delete MessageReport This Post
Gold member
Posted Hide Post
Thank you for the replies. I put the COMPUTE field on quotes, however, I'm not using dev studio (I'm on webFOCUS 4.x), so I dont know where to disable the prompt for parameters flag (also, I still want some other parameters to be prompted for - fromDate is not the only user-input field). I guess I'll just use a trick that I found (do a manual assigment of the variable if it equals a '' date)
 
Posts: 51 | Registered: September 29, 2004Reply With QuoteEdit or Delete MessageReport This Post
Platinum Member
Posted Hide Post
Hi

You mean
-SET &FromDate = IF &FromDate ='' THEN '20010131' ELSE &FromDate;

Yes that will work.

If you are not using dev studio, I am not sure where to disable the prompt for params. That's a good question. We always turn off the prompt for params. We don't need that since we are always submitting via ASP pages, so we have total control over all of the params that are submitted.

OK Back to work...

Jodye
 
Posts: 163 | Registered: October 01, 2003Reply With QuoteEdit or Delete MessageReport This Post
<WFUser>
Posted
Your code works fine in version 5.x. Could be version 4 was picky about the syntax. Try removing the ampersand and semicolon from the -DEFAULT.

-DEFAULT FromDate = '20010131'
 
Reply With QuoteEdit or Delete MessageReport This Post
Guru
Posted Hide Post
Since you are using version 4 I believe it does not like mixed case variables and the semicolon in the -DEFAULT statement.

Try something like this:
-DEFAULT &FROMDATE = '20010131'
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Reply With QuoteEdit or Delete MessageReport This Post
Gold member
Posted Hide Post
Thank you all for the replies. I got it to work using this:

-DEFAULT &FromDate = '20010131';
-SET &FromDate = IF &FromDate EQ '' THEN '20010131' ELSE &FromDate;

//the rest as before

I guess saying "default .." is not enough - you then have to explicitely set it to that value. Thanks for the help again.
 
Posts: 51 | Registered: September 29, 2004Reply With QuoteEdit or Delete MessageReport This Post
Master
Posted Hide Post
Sounds like the HTML form is explicitly setting FromDate to blanks (e.g., "?...&FromDate=&..."), thereby overriding the -DEFAULT.

Add
-? &
at start of the fex and see what &vars are initially set.
 
Posts: 532 | Location: NYC | Registered: January 11, 2005Reply With QuoteEdit or Delete MessageReport This Post
Master
Posted Hide Post
Yea, If &FromDate is a text box it will alway exist thus -DEFAULT will not work. Try This

-SET &FromDate = IF '&FromDate' EQ '' THEN '20010131' ELSE &FromDate;

Good Luck
 
Posts: 610 | Location: Dallas, Texas | Registered: May 24, 2004Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

IB - Developer Center    Forums  Hop To Forum Categories  FOCUS/WebFOCUS    How to set default values for user input parameter

Copyright © 1996-2008 Information Builders, leaders in enterprise business intelligence.