Trapping an Update

Bruce Easton bruce at stn.com
Sat Dec 4 08:07:46 PST 2010


Here's another way of doing capturing 'U' to initiate totaling of dummy 
fields
on a special control file screen - without ever putting user in update mode.
(If it were up to me, I'd make the user press 'T' for total and let them 
always
think 'U' is reserved for really doing an update to something, but hey.):

    1 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If: '(input table)
        Then: end
    2 -------   -   -   -   -   -   -   -   -   -   -   -   -
@entsel  If: @sn ne "2"
        Then: end  'not on totaling scrn, give fp normal ctrl
    3 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If:
        Then: cls("22")
    4 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If:           'could add H/F to this for print opts
        Then: eb="\r U \r-Total, Screen Number, \r X \r-Exit"
    5 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If:           'allow U, X or another valid scrn#
        Then: errorbox ("22","") eb,"","UX13"
    6 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If: @sk eq "BRKY"   'ignore cancel key
        Then: goto @entsel
    7 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If: @bk eq "X"      'wants to exit
        Then: pushkey "X"; end
    8 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If: @bk ne "U"      'wants to go to another scrn#
        Then: pushkey @bk; end
    9 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If:   'fell thru - U pressed--total dets into 'tl'
        Then: tl(10,.0)=""
   10 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If:
        Then: lookup dets = totdetails@  k=("BBB") i=A -nx
   11 -------   -   -   -   -   -   -   -   -   -   -   -   -
detsloo  If: not dets           'done totaling BBB
        Then: display; goto @entsel
   12 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If: dets(1) ne "BBB"   'done totaling BBB
        Then: display; goto @entsel
   13 -------   -   -   -   -   -   -   -   -   -   -   -   -
          If:
        Then: tl=tl+dets(2); getnext dets; goto detsloo

Here, I'm trying to total all details that match 'BBB' from the file
'totdetails', and screen 2 is the 'special' screen with dummy field 'tl'
to show a total.  This control file also has a screen 1 and a screen 3
where real updates to the record can occur.

Assumptions:

1. This is a control file where, for the purposes of this function,
only one record needs to be accesssed.
2. No writing is necessary to the control file record from the special 
screen.

This could easily be modified to work for several screens of the same
record where each had a different set of dummy fields.

Lines 5-8 could be easily redone with a combo of show statements
and waitkey I believe to give a more precise look and feel to what
you have now (instead of using errorbox).

I have to wonder, though, why not just do the totaling as soon as
someone arrives at the special screen (from @entsel and just test
for the screen number)?  Unless it takes a really long time and
they might hit that screen number by mistake.  But even in that case,
you could just ask before starting the totaling with a (i.e., yes/no
errorbox) and then switch/restore a previous screen if they really didn't
mean to go there.  That would also keep control of this in just
@entsel.

Bruce

Bruce Easton
STN, Inc.




On 12/3/10 11:00 PM, Boaz Bezborodko wrote:
> I'm sure that many of you probably already have this as a tool in your
> toolbox, but I figured I'd just share a simple way I used to trap an
> Update in a specific screen.
>
> The core of our software was written about 20 years ago and included a
> control file that also contained pertinent daily information such as
> daily and monthly sales totals.  One screen was used to allow you to
> total up all existing open AR invoices, open AP invoices, and open
> orders.  It would do this in one screen that contained a slew of dummy
> variables.  Once we started doing a lot of business that required large
> amounts of dropship orders (each package requires its own order,
> invoice, etc.) this record started to get a lot of activity and totaling
> up these numbers in the screen could freeze other people until the
> totals were completed and unlocked.  The totaling routine looked at
> other files and didn't touch anything in the record itself.
>
> Obviously totaling from within the record was not a good idea and I
> wanted to have this done from within @entsel which wouldn't lock the
> record.  But I didn't want to change the look and feel of the program
> which entailed that people hit "U" to start the process.  I was thinking
> of trapping "U" with an @keyU, but that meant that I would have to have
> a different line to jump to each of the other screens someone might want
> to update.
>
> The solution was to have a @WEF for the first field in this screen's
> cursor path that looked something like this:
> @wefaa     if:
>                   then: DECLARE What_Mode(7,*,g)
>                       if:
>                   then: What_Mode="Totals" ; ESCAPE
>
> @Entsel     if: What_Mode="Totals"
>                   then: Gosub (routine) ; What_Mode="" ; GOTO @Entsel
>
> Now the users can run this routine to their hearts content without
> interrupting anyone else.  The @Entsel and "What_Mode" trick I learned
> from John Esak.
>
> Just in case this helps anyone else.
>
> Boaz
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.celestial.com/pipermail/filepro-list/attachments/20101204/730b258e/attachment.html 


More information about the Filepro-list mailing list