palmtree with sun behind it CONTACT US
Phone: (412) 835-9417
Email: sales@vss3.com

TIP # 13 Defaults and Prompts

Supplying default answers to questions will make programming run faster and help the data entry person know what the usual response is to a question. Here are some tricks I use to do this in my filePro databases.

WHEN PROCESSING

1 @wef5 If: 5 eq ""
  Then: 5="Y"; display; end
2 If:  
 

Then:

end

This will put a value in field 5 as the field is approached during data entry. The user can see the default before they leave the field and press <ENTER> to go to the next field. I like this better than after the fact defaults that fill in fields after the screen is displayed. You might add a routine that checks all the fields that should have defaults applied and fill in any that are blank when the record has been saved. I have also seen this routine run before the data entry begins. That would replace the need for the @wef processing. This routine might look like this:

1 noblank If:

Then:

5 eq ""

5="Y"

2 If:

Then:

' continue with all other default fields.

return

This would catch any that you did not move through during data entry. Just activate this routine before ending the input processing for this record.

I often use the control file for the system to enter common defaults, and lookup these defaults and supply them as prompts when the question appears.

1 If:

Then:

'Current year is set in control file

rn(8,.0)="1"

2 If:

Then:



lookup ctrl=control r=rn -n
3 If:

Then:



yr(4,.0)=ctrl(10) 'assign current year number
4 If:

Then:



pushkey yr{"[ltab]"
5 If:

Then:



input popup ys(5,.0,g) "Year to Select: "

Use a variable for the input that is longer than the default or it will not wait for an answer. (Chalk this up to experience. Use 2 character, Yes/No, Dates are tricky.)

The data entry person can press <ENTER> to accept the response, or type over it with a change. This is very handy.

Version 5.0 added a great way to simply the supply for a default.  Instead of using pushkey, change the INPUT POPUP line as follows:

input popup ys(5,.0,g) "Year to Select: " default yr

This will allow a default answer to be more easily supplied. It can be any expression, so a literal or variable can be used to supply the prompt.  This works great for Yes NO questions because you can supply the value that is your default to insure the user knows what to expect if they just press ENTER.

Another way to supply answers is to put answers to the question on the command line. This will allow the report to be run manually or as an unattended batch file. For example,

/fp/dreport file -f report -v scan -a -r "YY1234"

In the scan table:

1

If:

Then:

pa ne ""

goto pick

2 If:

Then:

'Open invoices New only Account

pa(4,,g)=@pm; ya=mid(pa,"1","1"); yb=mid(pa,"2","1"); yc(4,.0,g)=mid(pa,"3","4")

3 If:

Then:

mid(pa,"1","1") eq ""

input popup ya(1,yesno,g) "Select Only Open Invoices? (Y/N) > "

4 If:

Then:

mid(pa,"2","1") eq ""

input popup yb(1,yesno,g) "Select Only New Invoices? (Y/N) > "

5 If:

Then:

yc eq ""

input popup yc "Enter Customer Code to Select (\kZ for ALL) > "

6 If:

Then:

@pm ne ""

goto pick 'Skip exit question if running unattended

7 If:

Then:



input popup yn(1,yesno,g) "Cancel Report? (Y/N) > "
8 If:

Then:

If: yn eq "Y" or @sk eq "BRKY"

exit 'Good trick to let the user out if they change their minds

9 pick If:

Then:

If: yc ne "" and yc ne 1 ' Not correct Customer
10 If:

Then:

yb eq "Y" and 15 eq "Y" 'already printed not new invoice

end

11 If:

Then:

yb eq "Y" and 32 eq "0" 'Balance 0 not open

end

12 If:

Then:



select; end

This should give you an idea about how this might be used to make the same report unattended with some default answers supplied on the command line.


Written by Nancy Palmquist

Copyright, 1997 by Virtual Software Systems.  All rights reserved.


Contact Us by: Email to Virtual Software Systems or Phone: (412) 835-9417