exec.red 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. COMMENT This file provides support for calling the EXEC and the system
  2. editor under TOPS-20 or TENEX;
  3. SYMBOLIC;
  4. GLOBAL '(PROGEXT!* PSYSDEV!* CRLFST!* EXECFORK!* EXECFILE!* SYSTEM!*
  5. !$EOL!$);
  6. PROGEXT!* := IF SYSTEM!*>0 THEN '(V A S !.) ELSE '(E X E !.);
  7. PSYSDEV!* := IF SYSTEM!*>0 THEN '(!< S U B S Y S !>) ELSE '(S Y S !:);
  8. CRLFST!* := IF SYSTEM!*<0 THEN LIST(INTERN ASCII 13,INTERN ASCII 10,'!")
  9. ELSE LIST(!$EOL!$,'!");
  10. EXECFORK!* := EXECFILE!* := IF SYSTEM!*<0 THEN "<SYSTEM>EXEC.EXE"
  11. ELSE "<SYSTEM>EXEC.SAV";
  12. SYMBOLIC PROCEDURE PINSTAT;
  13. BEGIN SCALAR X,Y,Z;
  14. Z := CURSYM!*;
  15. IF DELCP(X := NXTSYM!*) THEN GO TO DUN;
  16. Y := REVERSIP EXPLODEC NXTSYM!*;
  17. IF DELCP(X := CRCHAR!*) THEN GO TO DUN;
  18. Y := CRCHAR!* . Y;
  19. CRCHAR!* := '! ;
  20. WHILE NOT DELCP(X := READCHQ()) DO Y := X . Y;
  21. DUN:
  22. NXTSYM!* := X;
  23. TTYPE!* := 3;
  24. SCAN();
  25. RETURN LIST(Z,IF Y THEN MKQUOTE REVERSIP Y ELSE NIL)
  26. END;
  27. SYMBOLIC PROCEDURE READCHQ;
  28. IF !*INT AND NULL IFL!* THEN READCH1() ELSE READCH();
  29. REMPROP('EXEC,'STAT);
  30. REMPROP('PUSH,'STAT);
  31. REMFLAG('(EXEC PUSH),'GO);
  32. SYMBOLIC PROCEDURE PUSH U; EXEC U; %we might as well support both;
  33. SYMBOLIC PROCEDURE EXEC U;
  34. BEGIN SCALAR V,X,Y,Z;
  35. IF NULL U THEN RETURN XEQKEEP('EXECFORK!*,EXECFILE!*,NIL);
  36. V := U;
  37. A: IF CAR U EQ '!: OR CAR U EQ '!< THEN Y := T
  38. ELSE IF CAR U EQ '!. THEN Z := T
  39. ELSE IF SEPRP CAR U THEN GO TO B;
  40. X := CAR U . X;
  41. IF (U := CDR U) THEN GO TO A;
  42. B: X := REVERSIP('!" . IF Z THEN X ELSE APPEND(PROGEXT!*,X));
  43. X := COMPRESS('!" . IF Y THEN X ELSE APPEND(PSYSDEV!*,X));
  44. RETURN XEQKILL(X,LIST COMPRESS('!" . APPEND(V,CRLFST!*)))
  45. END;
  46. PUT('EXEC,'STAT,'PINSTAT);
  47. PUT('PUSH,'STAT,'PINSTAT);
  48. %FLAG('(EXEC PUSH),'GO);
  49. SYMBOLIC PROCEDURE XEQKILL(FILENAME,ARG);
  50. %handles infrequent calls by creating and killing each fork;
  51. <<!%XEQ(FILENAME,T,T,NIL,ARG); TERPRI();
  52. PRIN2T "Returned to REDUCE ..."; NIL>>;
  53. SYMBOLIC EXPR PROCEDURE XEQKEEP(FORKN,FILE,ARG);
  54. %This retains the lower fork for speedy subsequent calls to the same
  55. %program (e.g., PUSH or EDIT), and the ---FILE check will set up the
  56. %fork again after a SAVE;
  57. BEGIN SCALAR A;
  58. A:=ERRORSET(LIST('!%XEQ,FORKN,T,NIL,NIL,MKQUOTE ARG),NIL,NIL);
  59. SET(FORKN,IF ATOM A THEN !%XEQ(FILE,T,NIL,NIL,ARG) ELSE CAR A);
  60. TERPRI();
  61. PRIN2T "Returned to REDUCE ..."
  62. END;
  63. %SYMBOLIC PROCEDURE KFORK U;
  64. % PAIRP ERRORSET(LIST('JSYS,153,MKQUOTE U,0,0,1),NIL,NIL);
  65. %DATE!*:=JSYS(144,'(BUF),-1,604241920,1);
  66. %The following function is called by BEGIN. It checks that terminal
  67. % linelength in REDUCE is shorter than the width of the controlling
  68. % terminal.
  69. % Commented out as it is to sensitive to operating system differences.
  70. %SYMBOLIC PROCEDURE CHKLEN;
  71. % BEGIN SCALAR A,B;
  72. % A := ERRORSET('(JSYS 63 65 24 0 3),NIL,NIL); %Try MTOPR first,
  73. % A := IF PAIRP A THEN CAR A
  74. % ELSE BOOLE(1,LSH(JSYS(71,65,0,0,2),-18),127); % else use RFMOD
  75. % IF A<10 THEN RETURN;
  76. % B := LINELENGTH NIL;
  77. % IF A LEQ B THEN LINELENGTH(A-1);
  78. % RETURN B
  79. % END;
  80. END;