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 / SIMTEL / CPMUG / CPMUG052.ARK / VARBATCH.1 < prev    next >
Text File  |  1985-02-10  |  23KB  |  760 lines

  1. $This is program BATCH.
  2.  
  3. $Operation of this program is described in the BATCH Reference Manual.
  4.  
  5. $This program is entered into the public domain by its author, Daniel
  6. $Ross.  Please do not remove this notice.
  7.  
  8. $The mixed-upper-lower-case version of this file constitutes the 1st
  9. $module of program BATCH.  The upper-case-only version of this file
  10. $constitutes the 2nd module of program BATCH.
  11.  
  12. $Coded by Daniel Ross, in the computer language SIL80Z80, starting
  13. $Jan. 20, 1981.
  14.  
  15. $Revised Feb. 12, 1981
  16.  
  17. $For more information contact:
  18. $Daniel Ross
  19. $Succinct Systems
  20. $1346 River St.
  21. $Santa Cruz, Calif. 95060
  22. $Phone (408) 426-4197
  23.  
  24. DEF  FALSE            = 0;
  25. DEF  TRUE            = 1;
  26. IGNORE1STSPACE  1;
  27. DEF  OPTIMIZED_COMPILATION    = TRUE;
  28.  
  29. DEF  NoInitialValue        = 0;
  30. XREF OF  NoInitialValue : 0;
  31. DEF  PatchMe            = 0;
  32.  
  33. DEF  NrOfVariables        = 10;
  34. DEF  MaxDepthOfBatchStack    = NrOfVariables;
  35.  
  36. $ASCII characters
  37. DEF  EndOfText            = #03;    $Ctrl-C
  38. DEF  Bell            = #07;
  39. DEF  LineFeed            = #0A;
  40. DEF  CarriageReturn        = #0D;
  41. DEF  DataLinkEscape        = #10;    $Ctrl-P
  42. DEF  NegativeAck        = #15;    $Ctrl-U
  43. DEF  Substitute            = #1A;    $Ctrl-Z
  44. DEF  FileSeparator        = #1C;
  45. DEF  RecordSeparator        = #1E;
  46. DEF  NonexistentChar        = #80;
  47. DEF  TextTerminator        = NonexistentChar + RecordSeparator;
  48. DEF  FileTerminator        = NonexistentChar + FileSeparator;
  49.  
  50. DEF  AdrOf_JMP_WBOOT        = #0001;$Addr. of the JMP WBOOT
  51.                     $instruction in the table at
  52.                     $the beginning of BIOS
  53. DEF  WarmBoot            = #0000;$Entry addr. of procedure WBOOT
  54. DEF  CPMProgramStart        = #0100;$Starting addr. of all CP/M
  55.                     $user programs
  56.  
  57. ASM IF  ^ = 0;    $Assemble if this is the model which will be copied
  58.         $into safe memory
  59.  
  60. DEF  ^ = CPMProgramStart;
  61. :Start    GO.  Main;
  62.  
  63. :SafeMemory            WORD  PatchMe;
  64.                     $Addr. of the start of safe
  65.                     $memory
  66. :SizeOfSafeMemory        WORD  PatchMe;
  67.                     $Size in bytes of safe memory
  68. :SizeOfCodeInSafeMemory        WORD  SizeOfModel;
  69.                     $Do not alter the contents of
  70.                     $this word; just examine it.
  71.                     $This is the size of safe
  72.                     $memory needed just to hold the
  73.                     $code, not including any batch
  74.                     $text.  If you have insufficient
  75.                     $safe memory, this program will
  76.                     $not execute correctly.
  77. :AdrOfModels            WORD  Model, MODEL;
  78.                     $Do not alter the contents of
  79.                     $these words; just examine them.
  80.                     $They contain the starting
  81.                     $addresses for corresponding
  82.                     $patches in each of the models.
  83. :AdrOfYourPatchProc        WORD  YourPatchProc;
  84.                     $Do not alter the contents of
  85.                     $this word; just examine it to
  86.                     $determine where your patch
  87.                     $procedure should be located
  88. :DiagnosticInfo            WORD  0,0,0,0;
  89.                     $This space may be used as
  90.                     $desired, to hold diagnostic
  91.                     $info. in case of error
  92.  
  93. :JUST_BEFORE_MODEL 
  94. END ASMIF;
  95.  
  96. $If this is the model which is used to discover relocatable addresses,
  97. $make sure that both bytes of the addresses will differ from those of
  98. $the model which will be copied into safe memory.
  99. ASM IF  
  100.    (<>(^ - JUST_BEFORE_MODEL) ~= 0) & (><(^ - JUST_BEFORE_MODEL) = 0);
  101. SKIP OVER  1;                $Force the LSB of the addresses
  102.                     $to differ
  103. END ASMIF;
  104.  
  105. $**********************************************************************
  106.  
  107. :Model 
  108.  
  109. SHOW  ^;  $'Start of a model module
  110.  
  111. $The following variables and/or constants may be patched to change their
  112. $initial/permanent values
  113. :BatchCONSTReport        BYTE  0;
  114.                     $This byte contains the value of
  115.                     $the output param from CONST,
  116.                     $when batched chars. are being
  117.                     $read
  118. :RingForAttn            BYTE  FALSE;
  119.                     $0 means quiet, any nonzero
  120.                     $value means ring for attention
  121.                     $when the user must start typing
  122.                     $in chars.
  123. :Escape                BYTE  #01;    $StartOfHeading, Ctrl-A
  124.                     $This must be the 1st char. of
  125.                     $any 2-char. command to BATCH
  126.  
  127. $Table of valid 2nd chars., for 2-char. commands to BATCH, and the
  128. $addresses of their interpretation procedures
  129. :TableOf2ndChars 
  130.    BYTE  "I";  WORD  RequestTypedInput;
  131.    BYTE  "B";  WORD  RequestBatchInput;
  132.    BYTE  "R";  WORD  RequestRingForAttn;
  133.    BYTE  "Q";  WORD  RequestQuiet;
  134.    BYTE  "Y";  WORD  RequestYesFromCONST;
  135.    BYTE  "N";  WORD  RequestNoFromCONST;
  136.    BYTE  "X";  WORD  NoOp;
  137.    BYTE  "Z";  WORD  TerminateBatchProcessing;
  138.    BYTE  "F";  WORD  RequestFetchFromVariable;
  139.    BYTE  "O";  WORD  RequestTypedOutput;
  140.    BYTE  "A";  WORD  RequestAnswer;
  141.    BYTE  "V";  WORD  RequestVariableVariable;
  142.    BYTE  "S";  WORD  RequestStoreIntoVariable;
  143.    BYTE  FileTerminator;  WORD  TerminateBatchProcessing;
  144. :AfterTableOf2ndChars 
  145.  
  146. :AdrOf_JMP_CONST        WORD  NoInitialValue;
  147. :GO_OriginalCONST        GO.   NoInitialValue;
  148. :GO_OriginalCONIN        GO.   NoInitialValue;
  149. :GO_OriginalCONOUT        GO.   NoInitialValue;
  150. :AfterGO_Original 
  151.  
  152. :CommandErrRecoverySP        WORD  NoInitialValue;
  153.  
  154. :ControlPByte            BYTE  DataLinkEscape, CarriageReturn;
  155. :ControlZByte            BYTE  Substitute, CarriageReturn;
  156. :ControlCByte            BYTE  EndOfText;
  157. :CarriageReturnByte        BYTE  CarriageReturn;
  158.  
  159. :SelectedVariable        BYTE  NoInitialValue;
  160.  
  161. :AdrsOfVariables        ASM TIMES  NrOfVariables - 3;
  162.                 WORD  CarriageReturnByte;
  163.                     $Addr. of the value string of a
  164.                     $variable, initialized to the
  165.                     $addr. of the empty string
  166.                 END ASMTIMES;
  167.                 WORD  ControlPByte;
  168.                     $Addr. of the value string of
  169.                     $the 3rd-highest-numbered
  170.                     $variable, initialized to the
  171.                     $addr. of a string consisting
  172.                     $of just Ctrl-P
  173.                 WORD  ControlZByte;
  174.                     $Addr. of the value string of
  175.                     $the 2nd-highest-numbered
  176.                     $variable, initialized to the
  177.                     $addr. of a string consisting
  178.                     $of just Ctrl-Z
  179.                 WORD  ControlCByte;
  180.                     $Addr. of the value string of
  181.                     $the highest-numbered variable,
  182.                     $initialized to the addr. of a
  183.                     $string consisting of just
  184.                     $Ctrl-C
  185.  
  186. :CurrentDepthOfBatchStack    BYTE  0;
  187.                 BYTE  0;$This is a constant byte
  188. $NOTE:  The conceptually single "BatchStack" actually is implemented as
  189. $2 stacks which are pushed simultaneously, or popped simultaneously.
  190. $The 2 stacks are:  NormalSourceForCurrentLine, and BatchInputCursor.
  191. DEF  BatchStack = 0;            $The definition merely provides
  192.                     $a symbol which can be cross-
  193.                     $referenced
  194.  
  195. :MiddleOfInputLine        BYTE  FALSE;
  196.                     $0 means input is at the start
  197.                     $of a line, any nonzero value
  198.                     $means input is in the middle of
  199.                     $a line
  200. :UnsolicitedCharWasTypedIn    BYTE  FALSE;
  201.                     $0 means there has not been an
  202.                     $unsolicited char. typed in, any
  203.                     $nonzero value means an
  204.                     $unsolicited char. was typed in
  205. :UnsolicitedChar        BYTE  NonexistentChar;
  206.                     $If an unsolicited char. ~= the
  207.                     $escape char. was typed in, and
  208.                     $detected during a call of
  209.                     $CONST, this byte will contain
  210.                     $the char.; otherwise this byte
  211.                     $will contain NonexistentChar
  212.  
  213. MENTION  BatchStack;            $The following is part of the
  214.                     $conceptual BatchStack
  215. :NormalSourceForCurrentLine    BYTE  0;$0 means batch input, any
  216.                     $nonzero value means typed
  217.                     $input
  218.                 ASM TIMES  MaxDepthOfBatchStack - 1;
  219.                 BYTE  NoInitialValue;
  220.                 END ASMTIMES;
  221.  
  222. :NormalSourceForNextLine    BYTE  0;$0 means batch input, any
  223.                     $nonzero value means typed
  224.                     $input
  225. :AfterBatchText            WORD  NoInitialValue;
  226.                     $1st addr. after the end of
  227.                     $batch text, updated after
  228.                     $storing into a variable if the
  229.                     $source of char. input is the
  230.                     $console terminal
  231. :AfterSafeMemory        WORD  NoInitialValue;
  232.  
  233. MENTION  BatchStack;            $The following is part of the
  234.                     $conceptual BatchStack
  235. :BatchInputCursor        WORD  AfterModel;
  236.                     $Addr. of the next batch input
  237.                     $char.
  238.                 ASM TIMES  MaxDepthOfBatchStack - 1;
  239.                 WORD  NoInitialValue;
  240.                 END ASMTIMES;
  241.  
  242. :BatchCONST 
  243.    PROCEDURE;
  244.       CALL  DiscoverNormalSourceForCurrentLine;
  245.       IF 0 THEN;
  246.      CALL  GO_OriginalCONST;  A >> ?;
  247.      IF 0 THEN;
  248.         A <- .  BatchCONSTReport;
  249.      ELSE;
  250.         CALL  Input1Char;
  251.         HL <-  Escape;  A - .HL >> ?;
  252.         IF = THEN;
  253.            CALL  InputAndInterpretCommandChar;
  254.            A <- .  BatchCONSTReport;
  255.         ELSE;
  256.            A -> .  UnsolicitedChar;
  257.            A <-  #FF;
  258.         END IF;
  259.      END IF;
  260.       ELSE;
  261.      CALL  GO_OriginalCONST;
  262.       END IF;
  263.       A >> ?;
  264.    END PROCEDURE;
  265.  
  266. :BatchCONIN 
  267.    PROCEDURE;
  268.       ? << A <- .  MiddleOfInputLine;
  269.       IF 0 THEN;
  270.      $Starting a new input line
  271.      IF;
  272.         CALL  DiscoverNormalSourceForCurrentLine;
  273.      IS 0 AND;
  274.         CALL  DiscoverNormalSourceForNextLine;
  275.      IS ~0 AND;
  276.         CALL  GO_OriginalCONST;  A >> ?;
  277.      IS 0 THEN;
  278.         CALL  RingBellIfEnabled;
  279.      END IF;
  280.      CALL  AdrOfTopOfSourceStackToHL;
  281.      A <- .  NormalSourceForNextLine;  A -> .HL;
  282.       END IF;
  283.       CALL  Input1Char;
  284.       HL <-  Escape;  A - .HL >> ?;
  285.       IF = THEN;
  286.      CALL  InputAndInterpretCommandChar;
  287.      REPEAT;
  288.       END IF;
  289.       A -> B;                $Copy the char. that was input
  290.       CALL  TestWhetherUnsolicitedCharForcesSourceToBeConsole;
  291.       IF ~0 THEN;
  292.      CALL  AdrOfTopOfSourceStackToHL;  A -> .HL;
  293.      A -> .  NormalSourceForNextLine;
  294.      0 -> A;  A -> .  UnsolicitedCharWasTypedIn;
  295.       END IF;
  296.       CALL  DiscoverNormalSourceForCurrentLine;
  297.       IF ~0 THEN;
  298.      B -> A;            $Copy the char. that was typed
  299.                     $in
  300.      ? << A -  CarriageReturn;
  301.      IF = THEN;
  302.         0 -> A;  A -> .  NormalSourceForNextLine;
  303.      END IF;
  304.      ? << A -  LineFeed;
  305.      IF = THEN;
  306.         B <-  CarriageReturn;    $Change the input char.
  307.      END IF;
  308.       END IF;
  309.       IF;
  310.      B -> A;  ? << A -  LineFeed;
  311.       IS = AND;
  312.      CALL  DiscoverCurrentDepthOfBatchStack;
  313.       IS ~0 THEN;
  314.      B <-  CarriageReturn;        $Change the input char.
  315.       END IF;
  316.       B -> A;                $Copy the char. that was input
  317.       IF;
  318.      ? << A -  CarriageReturn;
  319.       IS = OR;
  320.      ? << A -  NegativeAck;
  321.       IS = OR;
  322.      ? << A -  EndOfText;
  323.       IS = THEN;
  324.      $The next char. will start an input line
  325.      0 -> A;
  326.       ELSE;
  327.      $The next char. will be in the middle of an input line
  328.      A <-  TRUE;            $Just in case the char. was Null
  329.       END IF;
  330.       A -> .  MiddleOfInputLine;
  331.       B -> A;                $Copy the char. that was input
  332.    END PROCEDURE;
  333.  
  334. :TypeOutChar_rC 
  335.    PROCEDURE;
  336.       BC\/;
  337.       CALL  GO_OriginalCONOUT;
  338.       /\BC;  C -> A;  ? << A -  CarriageReturn;
  339.                     $Set the condition codes
  340.       C <-  LineFeed;  IF = CALL  GO_OriginalCONOUT;
  341.    END PROCEDURE;
  342.  
  343. :Input1CharFromConsoleAndEcho 
  344.    PROCEDURE;
  345.       CALL  GO_OriginalCONIN;
  346.       A -> C;  BC\/;
  347.       CALL  TypeOutChar_rC;
  348.       /\BC;  C -> A;
  349.    END PROCEDURE;
  350.  
  351. :DiscoverCurrentDepthOfBatchStack 
  352.    PROCEDURE;
  353.       ? << A <- .  CurrentDepthOfBatchStack;
  354.    END PROCEDURE;
  355.  
  356. :TestWhetherUnsolicitedCharForcesSourceToBeConsole 
  357.    PROCEDURE;
  358.       ? << A <- .  UnsolicitedCharWasTypedIn;
  359.    END PROCEDURE;
  360.  
  361. :DiscoverNormalSourceForNextLine 
  362.    PROCEDURE;
  363.       ? << A <- .  NormalSourceForNextLine;
  364.    END PROCEDURE;
  365.  
  366. :AdrOfTopOfSourceStackToHL 
  367.    PROCEDURE;
  368.       HL <- .  CurrentDepthOfBatchStack;
  369.      DE <-  NormalSourceForCurrentLine;  HL + DE -> HL;
  370.    END PROCEDURE;
  371.  
  372. :AdrOfTopOfCursorStackToHL 
  373.    PROCEDURE;
  374.       HL <- .  CurrentDepthOfBatchStack;  HL * 2 -> HL;
  375.      DE <-  BatchInputCursor;  HL + DE -> HL;
  376.    END PROCEDURE;
  377.  
  378. :DiscoverNormalSourceForCurrentLine 
  379.    PROCEDURE;
  380.       CALL  AdrOfTopOfSourceStackToHL;
  381.       ? << A <-  .HL;
  382.    END PROCEDURE;
  383.  
  384. :CursorToDE 
  385.    PROCEDURE;
  386.       CALL  AdrOfTopOfCursorStackToHL;
  387.       .HL -> E;  HL + 1 -> HL;  .HL -> D;
  388.    END PROCEDURE;
  389.  
  390. :Fetch1BatchCharAndAdvanceTheCursor 
  391.    PROCEDURE;
  392.       CALL  CursorToDE;
  393.       .DE -> A;                    $Input char.
  394.       DE + 1 -> DE;  D -> .HL;  HL - 1 -> HL;  E -> .HL;
  395.                         $Advance the cursor
  396.    END PROCEDURE;
  397.  
  398. $Given rA containing the number of the designated variable, return with
  399. $rHL containing the addr. of the table entry for that variable
  400. :VariableNrToEntryAdr 
  401.    PROCEDURE;
  402.       A -> L;  H <-  0;  HL * 2 -> HL;  DE <-  AdrsOfVariables;
  403.      HL + DE -> HL;
  404.    END PROCEDURE;
  405.  
  406. $Given rA containing the number of the designated variable
  407. :PushTheBatchStack 
  408.    PROCEDURE;
  409.       $There is no test for stack overflow.  Overflow is extremely
  410.       $unlikely under the anticipated conditions of use, and even if it
  411.       $occurs, probably will not cause serious damage.
  412.       HL <-  CurrentDepthOfBatchStack;  .HL + 1 -> .HL;
  413.       CALL  AdrOfTopOfSourceStackToHL;  .HL <-  0;
  414.                     $Source of input will be batch
  415.                     $text
  416.       CALL  VariableNrToEntryAdr;
  417.       .HL -> C;  HL + 1 -> HL;  .HL -> B;
  418.                     $Addr. of start of the
  419.                     $designated variable -> BC
  420.       CALL  AdrOfTopOfCursorStackToHL;
  421.       C -> .HL;  HL + 1 -> HL;  B -> .HL;
  422.                     $Addr. of start of the
  423.                     $designated variable -> top of
  424.                     $cursor stack
  425.    END PROCEDURE;
  426.  
  427. :PopTheBatchStack 
  428.    PROCEDURE;
  429.       $If this code is free of bugs, stack underflow is impossible
  430.       HL <-  CurrentDepthOfBatchStack;  .HL - 1 -> .HL;
  431.    END PROCEDURE;
  432.  
  433. :Input1Char 
  434.    PROCEDURE;
  435.       HL <-  UnsolicitedChar;  .HL -> A;  ? << A -  NonexistentChar;
  436.       IF ~= THEN;
  437.      .HL <-  NonexistentChar;
  438.      ? << A -  CarriageReturn;  IF ~= EXIT;
  439.      $Test for the end of a variable
  440.      CALL  DiscoverCurrentDepthOfBatchStack;
  441.      IF ~0 THEN;
  442.         CALL  PopTheBatchStack;
  443.         REPEAT;
  444.      END IF;
  445.      A <-  CarriageReturn;
  446.      EXIT;
  447.       END IF;
  448.       IF;
  449.      CALL  DiscoverNormalSourceForCurrentLine;
  450.       IS 0 AND;
  451.      CALL  GO_OriginalCONST;  A >> ?;
  452.      IF ~0 THEN;
  453.         A -> .  UnsolicitedCharWasTypedIn;
  454.      END IF;
  455.       IS 0 THEN;
  456.      CALL  Fetch1BatchCharAndAdvanceTheCursor;
  457.       ELSE;
  458.      CALL  GO_OriginalCONIN;
  459.      ? << A -  EndOfText;
  460.      IF = THEN;
  461.         CALL  TestWhetherUnsolicitedCharForcesSourceToBeConsole;
  462.            IF ~0 CALL  TerminateBatchProcessing;
  463.         A <-  EndOfText;
  464.      END IF;
  465.       END IF;
  466.       ? << A -  CarriageReturn;  IF ~= EXIT;
  467.       $Test for the end of a variable
  468.       CALL  DiscoverCurrentDepthOfBatchStack;
  469.       IF ~0 THEN;
  470.      CALL  PopTheBatchStack;
  471.      REPEAT;
  472.       END IF;
  473.       A <-  CarriageReturn;
  474.    END PROCEDURE;
  475.  
  476. $This procedure is callable only during interpretation of a command
  477. :Input1CharFromSameSourceAsLastChar 
  478.    PROCEDURE;
  479.       IF;
  480.      CALL  DiscoverNormalSourceForCurrentLine;
  481.       IS 0 AND;
  482.      CALL  TestWhetherUnsolicitedCharForcesSourceToBeConsole;
  483.       IS 0 THEN;
  484.      CALL  Fetch1BatchCharAndAdvanceTheCursor;
  485.       ELSE;
  486.      CALL  GO_OriginalCONIN;
  487.       END IF;
  488.    END PROCEDURE;
  489.  
  490. :SelectAVariable 
  491.    PROCEDURE;
  492.       CALL  Input1CharFromSameSourceAsLastChar;
  493.       A <- A -  "0";  IF - GO.  ErrInCommand;
  494.       ? << A -  NrOfVariables;  IF |>=| GO  ErrInCommand;
  495.    END PROCEDURE;
  496.  
  497. :ErrInCommand                $*** Not a procedure ***
  498.    HL <- .  CommandErrRecoverySP;  HL -> SP;
  499.    GO  ReportAndRecoverFromCommandErr;
  500.  
  501. :InputAndInterpretCommandChar 
  502.    PROCEDURE;
  503.       HL <-  0;  HL + SP -> HL;  HL -> .  CommandErrRecoverySP;
  504.       $The char. must be input from the same source as the escape char.,
  505.       $regardless of any new unsolicited typed input
  506.       CALL  Input1CharFromSameSourceAsLastChar;
  507.       $Look up the char. in the table
  508.       HL <-  TableOf2ndChars;
  509.       B <-  (AfterTableOf2ndChars - TableOf2ndChars) / 3;
  510.       DO;
  511.      A - .HL >> ?;
  512.      IF = THEN;
  513.         $Interpret the char.
  514.         HL + 1 -> HL;  .HL -> E;  HL + 1 -> HL;  .HL -> D;
  515.            HL <-> DE;        $Addr. of interpretation
  516.                     $procedure -> HL
  517.         CALL  GO_rHL;
  518.         CALL  TestWhetherUnsolicitedCharForcesSourceToBeConsole;
  519.         IF ~0 THEN;
  520.            0 -> A;  A -> .  UnsolicitedCharWasTypedIn;
  521.         END IF;
  522.         EXIT  InputAndInterpretCommandChar;
  523.      END IF;
  524.      HL + 1 -> HL;  HL + 1 -> HL;  HL + 1 -> HL;
  525.      B - 1 -> B;  IF ~0 REPEAT;
  526.       END DO;
  527.       $If execution passes through here, no match was found
  528. :ReportAndRecoverFromCommandErr 
  529.       CALL  RingBell;
  530.       C <-  "E";  CALL  GO_OriginalCONOUT;
  531.       C <-  "R";  CALL  GO_OriginalCONOUT;
  532.       C <-  "R";  CALL  GO_OriginalCONOUT;
  533.       $Test whether the erroneous command char. was input from batch
  534.       $text
  535.       IF;
  536.      CALL  DiscoverNormalSourceForCurrentLine;
  537.       IS 0 AND;
  538.      CALL  TestWhetherUnsolicitedCharForcesSourceToBeConsole;
  539.       IS 0 THEN;
  540.      CALL  TerminateBatchProcessing;
  541.       END IF;
  542.       REPEAT;
  543.    END PROCEDURE;
  544.  
  545. :GO_rHL   GO .HL;
  546.  
  547. :RingBell 
  548.    PROCEDURE;
  549.       C <-  Bell;  CALL  GO_OriginalCONOUT;
  550.    END PROCEDURE;
  551.  
  552. :RingBellIfEnabled 
  553.    PROCEDURE;
  554.       ? << A <- .  RingForAttn;  IF ~0 CALL  RingBell;
  555.    END PROCEDURE;
  556.  
  557. :RingBellIfEnabledAndSourceWasBatchText 
  558.    PROCEDURE;
  559.       CALL  DiscoverNormalSourceForCurrentLine;
  560.       IF 0 THEN;
  561.      CALL  TestWhetherUnsolicitedCharForcesSourceToBeConsole;
  562.         IF 0 CALL  RingBellIfEnabled;
  563.       END IF;
  564.    END PROCEDURE;
  565.  
  566. :MakeSourceBeConsoleAndRingBellIfChangingAndEnabled 
  567.    PROCEDURE;
  568.       CALL  RingBellIfEnabledAndSourceWasBatchText;
  569.       CALL  AdrOfTopOfSourceStackToHL;  .HL <-  1;
  570.    END PROCEDURE;
  571.  
  572. :RequestTypedInput 
  573.    PROCEDURE;
  574.       A <-  1;  A -> .  NormalSourceForNextLine;
  575.       CALL  MakeSourceBeConsoleAndRingBellIfChangingAndEnabled;
  576.    END PROCEDURE;
  577.  
  578. :RequestBatchInput 
  579.    PROCEDURE;
  580.       CALL  AdrOfTopOfSourceStackToHL;
  581.       0 -> A;  A -> .HL;  A -> .  NormalSourceForNextLine;
  582.    END PROCEDURE;
  583.  
  584. :FirstPartOfRequestStoreIntoVariable 
  585.    PROCEDURE;
  586.       $It is forbidden to fetch from a variable and store into a
  587.       $variable simultaneously.  Otherwise, there would be no guarantee
  588.       $that the source of character input is unchanging.  If the source
  589.       $could change, then any value string which is fetched from batch
  590.       $text, would have to be stored a 2nd time in the batch text.
  591.       CALL  DiscoverCurrentDepthOfBatchStack;  IF ~0 GO.  ErrInCommand;
  592.                     $Error if fetching from a
  593.                     $variable
  594.       CALL  SelectAVariable;  A -> .  SelectedVariable;
  595.    END PROCEDURE;
  596.  
  597. :SecondPartOfRequestStoreIntoVariable 
  598.    PROCEDURE;
  599.       A <- .  SelectedVariable;
  600.       CALL  VariableNrToEntryAdr;  HL\/;  MENTION  AdrsOfVariables;
  601.                     $Addr. of entry in table
  602.       $Determine the source of character input
  603.       IF;
  604.      CALL  DiscoverNormalSourceForCurrentLine;
  605.       IS 0 AND;
  606.      CALL  TestWhetherUnsolicitedCharForcesSourceToBeConsole;
  607.       IS 0 THEN;
  608.      $The source of character input is batch text
  609.      CALL  CursorToDE;  /\HL;  E -> .HL;  HL + 1 -> HL;  D -> .HL;
  610.         MENTION  AdrsOfVariables;    $Copy the current value of the
  611.                     $cursor, into the entry in
  612.                     $table AdrsOfVariables for the
  613.                     $designated variable
  614.      $Input and disregard all chars. until the carriage return
  615.      $that terminates the variable, except that it is necessary to
  616.      $test for the end of batch text
  617.      DO;
  618.         CALL  Fetch1BatchCharAndAdvanceTheCursor;
  619.         ? << A -  CarriageReturn;  IF = EXIT;
  620.         HL <-  Escape;  A - .HL >> ?;  IF ~= REPEAT;
  621.         CALL  Fetch1BatchCharAndAdvanceTheCursor;
  622.         ? << A -  FileTerminator;  IF ~= REPEAT;
  623.         CALL  TerminateBatchProcessing;
  624.      END DO;
  625.       ELSE;
  626.      $The source of character input is the console terminal
  627.      HL <- .  AfterBatchText;  HL\/;  HL\/;
  628.                     $Addr. where the 1st char. of
  629.                     $the variable will be stored
  630.      $Input and store all chars. until the carriage return that
  631.      $terminates the variable.  Do not interpret any chars.
  632.      DO;
  633.         CALL  Input1CharFromConsoleAndEcho;
  634.         $Verify that there is at least 1 available byte remaining
  635.         $in safe memory
  636.         /\DE;            $Addr. where the char. will be
  637.                     $stored
  638.         HL <- .  AfterSafeMemory;
  639.         IF;
  640.            E -> A;  A - L >> ?;
  641.         IS = AND;
  642.            D -> A;  A - H >> ?;
  643.         IS = THEN;
  644.            GO.  ErrInCommand;
  645.         END IF;
  646.         C -> A;  A -> .DE;        $Copy the char. into safe
  647.                     $memory
  648.         DE + 1 -> DE;  DE\/;    $Addr. where next char. will
  649.                     $be stored
  650.         ? << A -  CarriageReturn;  IF ~= REPEAT;
  651.         /\HL;  HL -> .  AfterBatchText;
  652.         /\DE;  /\HL;  E -> .HL;  HL + 1 -> HL;  D -> .HL;
  653.            MENTION  AdrsOfVariables;$Copy the addr. of the 1st
  654.                     $char. of the value, into the
  655.                     $entry in table AdrsOfVariables
  656.                     $for the designated variable
  657.      END DO;
  658.       END IF;
  659.       0 -> A;  A -> .  MiddleOfInputLine;
  660.    END PROCEDURE;
  661.  
  662. :RequestStoreIntoVariable 
  663.    PROCEDURE;
  664.       CALL  FirstPartOfRequestStoreIntoVariable;
  665.       CALL  SecondPartOfRequestStoreIntoVariable;
  666.    END PROCEDURE;
  667.  
  668. :RequestAnswer 
  669.    PROCEDURE;
  670.       CALL  FirstPartOfRequestStoreIntoVariable;
  671.       CALL  MakeSourceBeConsoleAndRingBellIfChangingAndEnabled;
  672.       CALL  SecondPartOfRequestStoreIntoVariable;
  673.    END PROCEDURE;
  674.  
  675. :RequestFetchFromVariable 
  676.    PROCEDURE;
  677.       CALL  SelectAVariable;
  678.       CALL  PushTheBatchStack;
  679.    END PROCEDURE;
  680.  
  681. :RequestVariableVariable 
  682.    PROCEDURE;
  683.       CALL  RingBellIfEnabledAndSourceWasBatchText;
  684.       CALL  Input1CharFromConsoleAndEcho;
  685.       IF;
  686.      A <- A -  "0";
  687.       IS - OR;
  688.      ? << A -  NrOfVariables;
  689.       IS |>=| THEN;
  690.      CALL  RingBell;
  691.      REPEAT;
  692.       END IF;
  693.       CALL  PushTheBatchStack;
  694.    END PROCEDURE;
  695.  
  696. :RequestTypedOutput 
  697.    PROCEDURE;
  698.       CALL  Input1Char;  A -> C;
  699.       IF;
  700.      ? << A -  LineFeed;
  701.       IS = AND;
  702.      CALL  DiscoverCurrentDepthOfBatchStack;
  703.       IS ~0 THEN;
  704.      C <-  CarriageReturn;        $Change the input char.
  705.       END IF;
  706.       BC\/;
  707.       CALL  TypeOutChar_rC;        $Echo the char.
  708.       /\BC;  C -> A;            $Copy the char.
  709.       IF;
  710.      HL <-  Escape;  A - .HL >> ?;
  711.       IS = OR;
  712.      IF;
  713.         ? << A -  EndOfText;
  714.      IS = AND;
  715.         IF;
  716.            CALL  DiscoverNormalSourceForCurrentLine;
  717.         IS ~0 OR;
  718.            CALL  TestWhetherUnsolicitedCharForcesSourceToBeConsole;
  719.         IS ~0 THEN;
  720.      IF THE ABOVE THEN;
  721.       IF THE ABOVE THEN;
  722.      C -> A;  A -> .  UnsolicitedChar;
  723.                     $This will cause the char. to
  724.                     $be input again
  725.       ELSE;
  726.      REPEAT;
  727.       END IF;
  728.    END PROCEDURE;
  729.  
  730. :TerminateBatchProcessing 
  731.    PROCEDURE;
  732.       CALL  RingBellIfEnabled;
  733.       HL <- .  AdrOf_JMP_CONST;  DE <-  GO_OriginalCONST;  HL <-> DE;
  734.       B <-  AFTER_GO_BATCH - GO_BATCH_CONST;
  735.       DO;
  736.      .HL -> A;  A -> .DE;
  737.      HL + 1 -> HL;  DE + 1 -> DE;
  738.      B - 1 -> B;  IF ~0 REPEAT;
  739.       END DO;
  740.       A <-  1;  A üƒüƒƒ!        1    !#Çα߃ƒƒƒƒƒ'#ƒâǃƒ!        1    8        #Çα߃ƒƒƒƒƒ9ƒâǃƒ 3 9Çα߃ƒƒƒƒƒ3 ÇαßΣƒ<ƒÇüƒü'#ÇαßΣƒ'#ƒÇƒîƒÇüƒ'#ÇαßΣƒ9ƒÇƒîƒÇüƒ9ǃƒ$1ƒŃ    00<Çα߃ƒƒƒƒƒ0!3ƒ3 Çα߃ƒƒ0!3ƒ     803    0Çαßαßü! ƒα߃ƒƒ     803    0Çα߃ƒƒ0!3ƒ     803    0Çαßαßü     1    8 !ƒα߃ƒƒ     803    0Çα߃ƒƒƒƒƒ<ƒâǃƒÿ11ǃƒ<ƒÇüƒüƒƒ98 !TReport;
  741.    END PROCEDURE;
  742.  
  743. :RequestNoFromCONST 
  744.    PROCEDURE;
  745.       0 -> A;  A -> .  BatchCONSTReport;
  746.    END PROCEDURE;
  747.  
  748. :RequestRingForAttn 
  749.    PROCEDURE;
  750.       A <-  TRUE;  A -> .  RingForAttn;
  751.    END PROCEDURE;
  752.  
  753. :RequestQuiet 
  754.    PROCEDURE;
  755.       0 -> A;  A -> .  RingForAttn;
  756.    END PROCEDURE;
  757.  
  758. :AfterModel 
  759. $**********************************************************************
  760.