× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On Fri, 13 Feb 2004, Bill wrote:
>
> Has anyone developed a slick way of moving forward and backward amongst
> screen displays without using Goto's?
>

I developed a technique for this long before there was a free-form,
because I've always hated GOTOs and wanted to eliminate this.

My technique works like this:  I write the mainline of my program so that
it does nothing but control the flow of the program.   No other logic is
done here besides deciding which subroutine/subprocedure to call next, and
when to end the program.

Then, each subprocedure is responsible for performing one function,
whether it be loading data using business rules, validating data, saving
data, showing data to the user, or allowing data entry...

If any of the "business logic" subprocedures encounters an error, it
returns a "FAIL" indicator to the mainline, which causes it to go back a
step to the last good location.

If any of the "display logic" subprocedures want to go back (because of
F12, usually) they return FAIL and the mainline goes back to the last
display step.

More recently, I've begun moving the business logic subprocedures into
service programs so that I can have different "display logic" front ends
for GUI, web, and green-screen interfaces to the same program -- but I
haven't completely perfected this technique yet.

Anyway, here's some sample code.  It isn't from a live program, so
there's a good chance that it has bugs in it, but I think it's good enough
to illustrate my technique.

Err, I should probably explain what it does...   this program asks the
user for an item number, and then loads a subfile displaying all the
finished goods inventory for that item and shows it to the user.  When the
user presses enter on the inventory screen, it shows another subfile
displaying the orders for that item.  If an error occurs, or F12 is
pressed, it goes back to the last screen...


     D GetItemNumber   PR             1N
     D   ItemNo                       5P 0

     D LoadInventory   PR             1N
     D   ItemNo                       5P 0 value

     D ShowInventory   PR             1N
     D   ItemNo                       5P 0 value

     D LoadOrders      PR             1N
     D   ItemNo                       5P 0 value

     D ShowOrders      PR             1N
     D   ItemNo                       5P 0 value

     D MyItem          s              5P 0
     D Step            s             10I 0

     D SUCCESS         C                   const('1')
     D FAIL            C                   const('0')

     D STEP_GETITEM    C                   const(0)
     D STEP_LOADINV    C                   const(1)
     D STEP_SHOWINV    C                   const(2)
     D STEP_LOADORDS   C                   const(3)
     D STEP_SHOWORDS   C                   const(4)
     D STEP_EXIT       C                   const(5)

      /free

        dow Step <> STEP_EXIT;

            select;
            when Step = STEP_GETITEM;
               if (GetItemNumber(MyItem) = FAIL);
                  Step = STEP_EXIT;
               else;
                  Step = Step + 1;
               endif;

            when Step = STEP_LOADINV;
               if (LoadInventory(MyItem) = FAIL);
                  Step = STEP_GETITEM;
               else;
                  Step = Step + 1;
               endif;

            when Step = STEP_SHOWINV;
               if (ShowInventory(MyItem) = FAIL);
                  Step = STEP_GETITEM;
               else;
                  Step = Step + 1;
               endif;

            when Step = STEP_LOADORDS;
               if (LoadOrders(MyItem) = FAIL);
                  Step = STEP_SHOWINV;
               else;
                  Step = Step + 1;
               endif;

            when Step = STEP_SHOWORDS;
               if (ShowOrders(MyItem) = FAIL);
                  Step = STEP_SHOWINV;
               else;
                  Step = Step + 1;
               endif;

            endsl;

        enddo;

        *inlr = *on;
        return;

      /end-free


      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      * GetItemNumber():  Ask the user for an item number
      *
      *       ItemNo = (output) Item number retrieved from user
      *
      *  Returns SUCCESS if item was entered, or FAIL if F3 pressed.
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P GetItemNumber   B
     D GetItemNumber   PI             1N
     D   ItemNo                       5P 0
      /free

         dou scMsg = *blanks;

            exfmt WIEITMS1;
            scMsg = *blanks;

            if (key_F3);
               return FAIL;
            endif;

            if (scItem = 0);
               scMsg = 'You must enter an item number!';
            endif;

         enddo;

         ItemNo = scItem;
         return SUCCESS;

      /end-free
     P                 E

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.