home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / 18 / commscmd.bas < prev    next >
Encoding:
BASIC Source File  |  1988-08-11  |  3.6 KB  |  96 lines

  1. ' ************************************************************************
  2. ' *                                                                      *
  3. ' *  COMMSCMD                                                            *
  4. ' *                                                                      *
  5. ' *  This routine controls the COMMSCOP program that has been in-        *
  6. ' *  stalled as a resident routine.  The operation performed is de-      *
  7. ' *  termined by the command line.  The COMMSCMD program is invoked      *
  8. ' *  as follows:                                                         *
  9. ' *                                                                      *
  10. ' *             COMMSCMD [[cmd][,port]]                                  *
  11. ' *                                                                      *
  12. ' *  where cmd is the command to be executed                             *
  13. ' *             STOP   -- stop trace                                     *
  14. ' *             START  -- flush trace buffer and start trace             *
  15. ' *             RESUME -- resume a stopped trace                         *
  16. ' *        port is the COMM  port to be traced (1=COM1, 2=COM2, etc.)    *
  17. ' *                                                                      *
  18. ' *  If cmd is omitted, STOP is assumed.  If port is omitted, 1 is       *
  19. ' *  assumed.                                                            *
  20. ' *                                                                      *
  21. ' ************************************************************************
  22.  
  23.         '
  24.         '  Establish system constants and variables
  25.         '
  26.         DEFINT A-Z
  27.  
  28.         DIM INREG(7), OUTREG(7)         'Define register arrays
  29.  
  30.         RAX = 0                         'Establish values for 8086
  31.         RBX = 1                         '  registers
  32.         RCX = 2                         '  .
  33.         RDX = 3                         '  .
  34.         RBP = 4                         '  .
  35.         RSI = 5                         '  .
  36.         RDI = 6                         '  .
  37.         RFL = 7                         '  .
  38.  
  39.         DIM TEXT$(2)
  40.  
  41.         TEXT$(0) = "STOPPED"
  42.         TEXT$(1) = "STARTED"
  43.         TEXT$(2) = "RESUMED"
  44.  
  45.         '
  46.         '  Process command-line tail
  47.         '
  48.         C$ = COMMAND$                   'Get command-line data
  49.  
  50.         IF LEN(C$) = 0 THEN             'If no command line specified
  51.             CMD = 0                     'Set CMD to STOP
  52.             PORT = 0                    'Set PORT to COM1
  53.             GOTO SENDCMD
  54.         END IF
  55.  
  56.         COMMA = INSTR(C$, ", ")         'Extract operands
  57.         IF COMMA = 0 THEN
  58.             CMDTXT$ = C$
  59.             PORT = 0
  60.         ELSE
  61.             CMDTXT$ = LEFT$(C$, COMMA - 1)
  62.             PORT = VAL(MID$(C$, COMMA + 1)) - 1
  63.         END IF
  64.  
  65.         IF PORT < 0 THEN PORT = 0
  66.  
  67.         IF CMDTXT$ = "STOP" THEN
  68.             CMD = 0
  69.         ELSEIF CMDTXT$ = "START" THEN
  70.             CMD = 1
  71.         ELSEIF CMDTXT$ = "RESUME" THEN
  72.             CMD = 2
  73.         ELSE
  74.             CMD = 0
  75.         END IF
  76.  
  77.         '
  78.         '  Send command to COMMSCOP routine
  79.         '
  80. SENDCMD:
  81.         INREG(RAX) = 256 * CMD
  82.         INREG(RDX) = PORT
  83.         CALL INT86(&H60, VARPTR(INREG(0)), VARPTR(OUTREG(0)))
  84.         '
  85.         '  Notify user that action is complete
  86.         '
  87.         PRINT : PRINT
  88.         PRINT "Communications tracing "; TEXT$(CMD);
  89.         IF CMD <> 0 THEN
  90.             PRINT " for port COM"; MID$(STR$(PORT + 1), 2); ":"
  91.         ELSE
  92.             PRINT
  93.         END IF
  94.  
  95.         END
  96.