home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / LANGUAGS / MODULA2 / SHELLIF.MOD < prev    next >
Text File  |  2000-06-30  |  3KB  |  83 lines

  1. ;
  2. ; MODIFICATION TO ZCPR3 CP TO ALLOW IF/ELSE STATEMENTS INSIDE A SHELL CMD
  3. ;
  4. ;    If you are a heavy user of aliases and arunz alias.cmd
  5. ;    files which contain flow control statements, and you
  6. ;    also use the SHSET FNAME1;FNAME2;CMD sequence to create
  7. ;    shells from non-shell programs; you have probably had
  8. ;    problems if FNAME2 or FNAME2 were aliases which contained
  9. ;    flow control statements.
  10. ;
  11. ;    The source of the difficulty is in the following section
  12. ;    of ZCPR3 CP code. The code was originally included so that
  13. ;    a false flow control state would not prevent re-entry to
  14. ;    a shell. However, if you are willing to allow that to occur;
  15. ;    the modification shown below will greatly increase the
  16. ;    flexibility of the ZCPR3 system by allowing flow control
  17. ;    statements to be included inside a shell command.  I have
  18. ;    been using this modification for several months (along with
  19. ;    CMD11.COM) and have had no problems introduced by doing so.
  20. ;
  21. ;    Just insert the conditional assembly statements as shown, into
  22. ;    the ZCPR3 CP source code, assemble, & link.  The code below
  23. ;    is from ZCPR3 ver 3.0, but it shouldn't be to difficult to
  24. ;    find the proper place to modify if you are using the latest
  25. ;    release.
  26. ;                Royce Shofner....4/15/87
  27.  
  28.  
  29.  
  30. RS3:
  31.     LD    (NXTCHR),HL    ;SET PTR TO FIRST CHAR OF NEW COMMAND LINE
  32.     LD    (CURCMD),HL    ;SAVE PTR TO COMMAND LINE FOR ERROR RETURN
  33. ;
  34. ; PARSE COMMAND LINE PTED TO BY HL
  35. ;
  36.     CALL    PARSER        ;PARSE ENTIRE COMMAND LINE
  37. ;***************************************************************
  38. ;
  39. ; CHECK FOR SHELL INVOCATION AND RUN IT IF SO
  40. ;
  41. ;    THIS IS THE CODE WHICH PREVENTS FLOW CONTROL PROCESSING
  42. ;    FROM WITHIN A (FNAME1;FNAME2;CMD) SEQUENCE WHERE FNAME1,
  43. ;    FNAME2 ARE ALIASES CONTAINING FLOW CONTROL STATEMENTS
  44. ;    IF SHELLIF IS DECLARED TRUE, THIS SECTION OF CODE IS NOT
  45. ;    INCLUDED IN THE ZCPR3 COMMAND PROCESSOR, & FLOW CONTROL
  46. ;    STATEMENTS MAY BE INCLUDED INSIDE A SHELL COMMAND
  47. ;
  48. ;    THE SHELLIF EQUATE MAY BE LOCATED INSIDE THE ZCPR3 CP
  49. ;    AS IS SHOWN HERE, OR IT MAY BE PLACED INSIDE Z3HDR.LIB
  50. ;    SOMEWHERE IN THE FLOW CONTROL DEFINITION AREA
  51.  
  52. SHELLIF    EQU    TRUE        ;ALLOWS IF PROCESSING FROM SHELL
  53.  
  54.     IF    Z3MSG NE 0
  55.     IF    NOT SHELLIF
  56.     LD    A,(Z3MSG+3)        ;GET COMMAND STATUS
  57.     CP    1            ;SHELL?
  58.     JP    Z,RS4
  59.     ENDIF        ;SHELLIF
  60.     ENDIF        ;Z3MSG NE 0
  61. ;***************************************************************
  62. ;
  63. ; IF IFON AND FCP AVAILABLE, TRY TO RUN FROM FCP
  64. ;
  65.     IF    IFON AND [FCP NE 0]
  66.     LD    HL,FCP+5        ;PT TO COMMAND TABLE
  67.     CALL    CMDSCAN        ;SCAN TABLE
  68.     JP    Z,CALLP        ;RUN IF FOUND (NO LEADING CRLF)
  69.     ENDIF        ;IFON AND (FCP NE 0)
  70. ;
  71. ; IF IFON, THEN CHECK FOR RUNNING IF AND FLUSH COMMAND LINE IF ENABLED
  72. ;
  73.     IF    IFON
  74.     LD    HL,Z3MSG+1    ;PT TO IF BYTE
  75.     LD    A,(HL)        ;GET IT
  76.     OR    A        ;SEE IF ANY IF
  77.     JR    Z,RS4        ;CONTINUE IF NOT
  78.     INC    HL        ;PT TO IF ACTIVE BYTE
  79.     AND    (HL)        ;SEE IF CURRENT IF IS ACTIVE
  80.     JR    Z,RS1        ;SKIP IF NOT
  81.     ENDIF        ;IFON
  82. RS4:
  83.