Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>switch.exe chain executable files</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
SWITCH.EXE         Chain executable files


Syntax:        SWITCH <executable file list>

Arguments:     <executable file list> is a list of .EXE files
               separated by spaces to execute in the order specified.

               Note: Arguments can only be separated with spaces;
               any other delimiter aborts the execution of SWITCH.  Note
               also that batch files or other instances of SWITCH cannot
               be specified as arguments.

Description:   SWITCH.EXE is a utility that can be used to chain the
               execution of .EXE files.  These can include
               Clipper-compiled, spreadsheet, word-processing, or
               utility programs.

               SWITCH works by assigning each argument--at start-up--a
               number specifying its ordinal position in the list of
               arguments.  The numbering begins with zero for the first
               argument.  SWITCH then executes the first program in the
               list.  Switching to another program in the list is
               accomplished by setting the Clipper return code--using
               ERRORLEVEL()--to its position in the argument list and
               then QUITting the current process.  SWITCH then executes
               that process.  Setting the return code to zero from any
               of the called processes returns control to the first
               process in the list.

               Exiting SWITCH: You can only exit SWITCH from the
               first program in the argument list.  To exit, set the
               return code to zero using ERRORLEVEL() before QUITting.

Notes:         . Passing parameters: Because SWITCH treats each item
                 in the argument list delimited by spaces as an actual
                 parameter, you cannot pass parameters to a Clipper
                 application program as you would normally.  Instead,
                 you can use a memory (.mem) file containing the memory
                 variables you want to pass between programs.  For
                 example, in the calling program:

                     SAVE ALL LIKE parms* to Parms.mem

                 Then, in the called program:

                    IF FILE("Parms.mem")
                        RESTORE FROM Parms ADDITIVE
                    ELSE
                        <initialize parameter variables to default values>...
                    ENDIF

               . Technical specs: SWITCH uses INT 21 Function 4D to
                 query the return code of a child process.  Clipper uses
                 INT 21 Function 4C to set the Clipper process return
                 code.  The return code of a Clipper process is either
                 the value set by the last execution of ERRORLEVEL(),
                 the value of the last DOS error, or zero.


----------------------------------- Example --------------------------------

   In DOS:

     C>SWITCH MENU PROG1 PROG2


   In Clipper:

     * Menu.prg
     CLEAR SCREEN

     @ 10, 10 PROMPT "Program 1"
     @ 11, 10 PROMPT "Program 2"
     MENU TO choice                && Press Esc to return to DOS.

     ERRORLEVEL(choice)
     RETURN


     * Prog1.prg
     ? "Program 1"
     WAIT
     ERRORLEVEL(0)                 && Return to MENU.EXE.
     RETURN


     * Prog2.prg
     ? "Program 2"
     WAIT
     ERRORLEVEL(0)                 && Return to MENU.EXE.
     RETURN



See Also: QUIT ERRORLEVEL()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson