Heading703
PC Commands
UTL0502

The RPG to run PC Commands

      **********************************************************************
      *     ___             _    _     __ __             _    _            *
      *    | . > ___  ___ _| |_ | |_  |  \  \ ___  _ _ _| |_ <_>._ _       *
      *    | . \/ . \/ . \ | |  | . | |     |<_> || '_> | |  | || ' |      *
      *    |___/\___/\___/ |_|  |_|_| |_|_|_|<___||_|   |_|  |_||_|_|      *
      *                                                                    *
      *    A program to demonstrate interactions with a PC from RPG.       *
      *     (Uses STRPCCMD)                                                *
      *                                                                    *
      *                                                                    *
      *     1/2008                                     ‚booth@martinvt.com€*
      **********************************************************************
     H COPYRIGHT('Booth Martin, All rights reserved.')

     **--------------------------------------------------------------------*
     ** FILES                                                              *
     **--------------------------------------------------------------------*
     H option(*nodebugio)
     FUTL05D    cf   e             workstn

      * Prototypes.
     D pQcmdExc        pr                  ExtPgm('QCMDEXC')
     D                             1024    const
     D                               15  5 const

     **--------------------------------------------------------------------*
     ** DEFINITIONS                                                        *
     **--------------------------------------------------------------------*
      * Working fields.
     D wS1Exit         s              1
     D wCommand        s           1024
     D wCmdString      s           1024    varying

     **====================================================================*
     ** MAIN CALCULATIONS                                                  *
     **====================================================================*
      * Display screen.
     C                   exsr      S1Main
      * Exit.
     C                   exsr      ExitPgm

     **====================================================================*
     ** MAINLINE-END                                                       *
     **====================================================================*
      *-------------------------------*  Sub-Routine  *
      * *inzsr()                      *---------------*
      * Initialize variables, set constants.          *
      *-----------------------------------------------*
     C     *inzsr        begsr
     C                   endsr

      *-------------------------------*  Sub-Routine  *
      * ExitPgm()                     *---------------*
      * Exit program.                                 *
      *-----------------------------------------------*
     C     ExitPgm       begsr
     C                   eval      *inlr = *on
     C                   return
     C                   endsr

     **--------------------------------------------------------------------*
     ** Screen 1 procedures.        Screen1                                *
     **--------------------------------------------------------------------*
      *-------------------------------*  Sub-Routine  *
      * S1Main()                      *---------------*
      * Screen - Main processing.                     *
      *-----------------------------------------------*
     C     S1Main        begsr
      * Setup.
     C                   exsr      S1Fill

      * Loop until exit.
     C                   eval      wS1Exit = 'N'
     C                   dow       wS1Exit = 'N'
      *   Display screen.
     C                   exsr      S1ReFill
     C                   exfmt     S1
      *   Perform keypress.
     C                   select
      *     F3=Exit.
     C                   when      *inkc = *on
     C                   exsr      ExitPgm
      *     Radio button selected.
     C                   when      PB1 > 0
     C                   exsr      S1KeyEnter
      *     everything else; go around again.
     C                   other
     C                   endsl
     C                   enddo
     C                   endsr

      *-------------------------------*  Sub-Routine  *
      * S1Fill()                      *---------------*
      * Screen - Fill screen.                         *
      *-----------------------------------------------*
     C     S1Fill        begsr
     C                   endsr

      *-------------------------------*  Sub-Routine  *
      * S1ReFill()                    *---------------*
      * Screen - Refill screen.                       *
      *-----------------------------------------------*
     C     S1ReFill      begsr
     C                   eval      PB1 = 0
     C                   endsr

      *-------------------------------*  Sub-Routine  *
      * S1KeyEnter()                  *---------------*
      * Enter key                                     *
      *-----------------------------------------------*
     C     S1KeyEnter    begsr
     C                   exsr      S1Validate
      * If no errors then proceed.
     C                   if        *in90 = *off
     C                   exsr      S1Process
     C                   endif
     C                   endsr

      *-------------------------------*  Sub-Routine  *
      * S1Validate()                  *---------------*
      * Screen - Validate entry fields.               *
      *-----------------------------------------------*
     C     S1Validate    begsr
     C                   eval      *in90 = *off
     C                   endsr

      *-------------------------------*  Sub-Routine  *
      * S1Process()                   *---------------*
      * Process screen 1                              *
      *-----------------------------------------------*
     C     S1Process     begsr
      * Start PC Organizer if not started.
     C                   eval      wCmdString = 'STRPCO PCTA(*NO)'
     C                   callp(e)  pQCmdExc(wCmdString:
     C                              %len(%trim(wCmdString)) )
      * Establish the command to perform.
     C                   select
     C                   when      PB1 = 1
     C                   eval      wCommand =
     C                               'start http://www.martinvt.com'
     C                   when      PB1 = 2
     C                   eval      wCommand =
     C                               'notepad.exe'
     C                   when      PB1 = 3
     C                   eval      wCommand =
     C                               'excel.exe'
     C                   when      PB1 = 4
     C                   eval      wCommand = 'start soffice -o '
     C*                  eval      wCommand = 'start soffice -pt AFP ' +           
     C*                             '"C:\Documents and Settings\?????\'
     C*                             + 'Desktop\???????\'
     C*                             + '????????.jpg"'
     C                   endsl
      * Run the command from the screen.
     C                   eval      wCmdString = 'strpccmd pccmd('''
     C                               + %trim(wCommand)
     C                               + ''') pause(*NO)'
     C                   callp     pQCmdExc(wCmdString:
     C                              %len(%trim(wCmdString)) )
     C                   endsr








The DDS to run PC Commands from a display screen


      ****************************************************************
      *   ___             _    _     __ __             _    _        *
      *  | . > ___  ___ _| |_ | |_  |  \  \ ___  _ _ _| |_ <_>._ _   *
      *  | . \/ . \/ . \ | |  | . | |     |<_> || '_> | |  | || ' |  *
      *  |___/\___/\___/ |_|  |_|_| |_|_|_|<___||_|   |_|  |_||_|_|  *
      *                                                              *
      *  A program to demonstrate interactions with a PC from RPG.   *
      *                                                              *
      *                                                              *
      *                                                              *
      *   1/2008                                 booth@martinvt.com  *
      ****************************************************************
                                            DSPSIZ(24 80 *DS3)
                                            CHGINPDFT(HI UL)
                                            ERRSFL
                                            CA03(03 'Exit')
                                            MOUBTN(*ULD ENTER)
                R S1
                                        2  2'   ___             _    _     __ _-   
                                            _             _    _       '
                                            COLOR(RED)
                                        3  2'  | . > ___  ___ _| |_ | |_  |  \ -
                                             \ ___  _ _ _| |_ <_>._ _  '
                                            COLOR(RED)
                                        4  2'  | . \/ . \/ . \ | |  | . | |    -
                                             |<_> || ''_> | |  | || '' | '
                                            COLOR(RED)
                                        5  2'  |___/\___/\___/ |_|  |_|_| |_|_|-
                                             |<___||_|   |_|  |_||_|_| '
                                            COLOR(RED)
                                        7 53'& Friends   '
                                            COLOR(WHT)
                                        1 69DATE
                                            EDTCDE(Y)
                                        2 69TIME
                                        3 69'system i'
                                        4 69USER
                                       10  7'      Sample commands that can be -
                                            executed from RPG or CL       '
                                            COLOR(TRQ)
                                            DSPATR(UL)
                  PB1            2Y 0B 12  8SNGCHCFLD
                                            CHOICE(1 'Open Browser    ')
                                            CHOICE(2 'Open Notepad    ')
                                            CHOICE(3 'Open Excel      ')
                                            CHOICE(4 'Print a PC file ')
                                       16 49' Note: Select/unselect   '
                                            DSPATR(RI)
                                            COLOR(BLU)
                                       17 49'       a choice with     '
                                            DSPATR(RI)
                                            COLOR(BLU)
                                       18 49'       either the mouse  '
                                            DSPATR(RI)
                                            COLOR(BLU)
                                       19 49'       or the space bar. '
                                            DSPATR(RI)
                                            COLOR(BLU)
                                       23  3'F3=Exit'
                                            COLOR(BLU)
 

Please contact our Webmaster with questions or comments.
© Copyright 2010, Contract Programming All rights reserved.