home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / UTILS / SHELL3A / SRC.ZIP / OPL / SETPR.OPL < prev    next >
Encoding:
Text File  |  1996-09-03  |  1.2 KB  |  54 lines

  1. Rem ****************************************
  2. Rem * Shell3a external command - setpr.opl
  3. Rem * ╕ Nick Murray May 1996
  4. Rem *
  5. Rem * setpr - Change the priority of the
  6. Rem *        specified process
  7. Rem ****************************************
  8. PROC setpr%:(n%)
  9. LOCAL ax%,bx%,cx%,dx%,si%,di%
  10. LOCAL ret%,buf$(15),str%,addr%,pattern$(2)
  11.     ONERR ErrTrap::
  12.     If n%<>3
  13.         IF n%=2
  14.             bx%=CALL($0088)    Rem no process so use current one
  15.         ELSE
  16.             PRINT "Usage: setpr <priority> <process id>"
  17.             RETURN
  18.         ENDIF
  19.     ELSE
  20. Rem get the name of the process to change the priority of
  21.         bx%=EVAL(PEEK$(argv%(3)))
  22.         addr%=ADDR(buf$)
  23.         pattern$="*"+CHR$(0)
  24.         DO
  25.             str%=ret%
  26.             ret%=CALL($0B88,ret%,0,0,UADD(addr%,1),UADD(ADDR(pattern$),1))
  27.             IF ret%=bx%
  28.                 POKEB addr%,CALL($B9,0,0,0,0,UADD(addr%,1))
  29.                 ret%=EVAL(RIGHT$(buf$,2))
  30.                 IF ret%<7
  31.                     PRINT "System process:",buf$
  32.                 ELSE
  33.                     GOTO Found::
  34.                 ENDIF
  35.                 RETURN
  36.             ENDIF
  37.         UNTIL ret%=str%
  38.         PRINT "Process not found"
  39.         RETURN
  40.     ENDIF    
  41. Found::    Rem bx%=valid process id
  42.     ax%=EVAL(PEEK$(argv%(2)))
  43.     IF ax%>255 OR ax%<0
  44.         PRINT "Priority must be 0-255"
  45.         RETURN
  46.     ENDIF
  47.     ax%=ax%+$300
  48.     OS($88,ADDR(ax%))
  49.     RETURN
  50. ErrTrap::
  51.     ONERR off
  52.     PRINT err$:(ERR)
  53. ENDP
  54.