home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol094 / ter.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-02-10  |  31.9 KB  |  1,663 lines

  1.  
  2. external terms::ter(2);
  3.  
  4.  
  5.  
  6. {COPYRIGHT 1982 (C) BY CRAIG RUDLIN, M.D.  ALL RIGHTS RESERVED.}
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. {*************************** clear screen *******************************}
  14. PROCEDURE CLEAR_SCREEN;
  15. {$C-}
  16. {$R-}
  17. {$M-}
  18. {$F-}
  19. {$U-}
  20.  
  21. var i,j:byte;
  22. BEGIN
  23. write(chr(27),'[2J',chr(27),'[1;1H');
  24. for i:= 1 to 30 do for j:= 1 to 30 do; {delay so terminal can clear screen}
  25.  
  26. END;
  27.  
  28. {*********************** position cursor on screen ***********************}
  29. PROCEDURE MOVE_CURSOR (X,Y:BYTE);
  30. {$C-}
  31. {$F-}
  32. {$M-}
  33. {$U-}
  34. {$R-}
  35. var
  36. lenx,leny:byte;
  37. BEGIN
  38.     begin
  39.     lenx:= trunc(1+ ln(x)/2.30259);
  40.     leny:= trunc(1+ ln(y)/2.30259);
  41.     write(chr(27),'[',y:leny,';',x:lenx,'H');
  42.     end;
  43. END;
  44.  
  45.  
  46. {******************* erase lines of text ****************************}
  47. PROCEDURE ERASE_LINES(STARTING_LINE,NUMBER_OF_LINES:BYTE);
  48. {$C-}
  49. {$F-}
  50. {$M-}
  51. {$U-}
  52. {$R-}
  53. VAR
  54. len,I:BYTE;
  55.  
  56. BEGIN
  57.  
  58. FOR I:= 1 TO NUMBER_OF_LINES DO
  59.   BEGIN
  60.     move_cursor(1,starting_line);
  61.      write(chr(27),'[2K'); {code to erase a line}
  62.  STARTING_LINE:=STARTING_LINE + 1;
  63.  END;
  64. END;
  65.  
  66.  
  67. {**************** place message on screen ****************************}
  68. PROCEDURE PROMPT (X,Y,LENGTH:BYTE; P:$STRING80;
  69.           PROTECTED_FIELD_DESIRED:BOOLEAN);
  70. {$R-}
  71. {$C-}
  72. {$F-}
  73. {$M-}
  74. {$U-}
  75. VARèUNDERLINE:STRING 80;
  76. I:BYTE;
  77.  
  78. BEGIN
  79. if length = 0 then underline:=' ' else UNDERLINE:='_';{don't put any unnec -}
  80.     FOR I:= 1 TO LENGTH DO APPEND(UNDERLINE,'_');
  81. move_cursor(x,y);
  82. if protected_field_desired = false then WRITE(P,UNDERLINE) else
  83.   write(chr(27),'[0m',P,underline,chr(27),'[1m');
  84. END;
  85.  
  86.  
  87. {***************** ASK YES/NO QUESTION *********************************}
  88. FUNCTION QUERY(X,Y:BYTE;MESSAGE:$STRING80):BOOLEAN;
  89. {$C-}
  90. {$M-}
  91. {$F-}
  92. {$R-}
  93. {$U-}
  94. VAR
  95. ANSWER:CHAR;
  96.  
  97. BEGIN
  98. REPEAT
  99. MOVE_CURSOR(X,Y);
  100. WRITE(MESSAGE);
  101. KEYIN(ANSWER);
  102. UNTIL ANSWER IN ['Y','y','N','n'];
  103. QUERY:= ((ANSWER='Y') OR (ANSWER = 'y')); {Equivalent to if then}
  104. ERASE_LINES(Y,1);
  105. END; {OF PROCEDURE}
  106.  
  107.  
  108.  
  109. procedure check_code(new:boolean;xcode:real;recno:integer);
  110. {$C-}
  111. {$M-}
  112. {$F-}
  113. {$R-}
  114. {$U-}
  115. var
  116. dummy:integer;
  117. used,answer:boolean;
  118.  
  119.  
  120. procedure ok_code;  {internal procedure}
  121. {$C-}
  122. {$M-}
  123. {$F-}
  124. {$R-}
  125. {$U-}
  126.  
  127. label 2;
  128.  
  129. var
  130. xcode:real;
  131. field:data;
  132.  
  133. begin
  134.  
  135. answer:=query(1,24,'DO YOU WANT TO USE THE SAME CODE? Y/N ');
  136. if answer = false then
  137.     begin
  138.     field:=blanks;    
  139.  
  140.     end_of_input:=false;
  141.     end_of_record:=false;
  142.     end_of_field:=false;
  143.  
  144.     prompt(1,22,10,'ENTER NEW CODE <TAB>: ',false);
  145.     field:= input(17,22,10, lower_case,alphanumric,field);    
  146.  
  147. 2:xcode:= arraytoreal(field);
  148.     
  149.         if error then 
  150.         begin
  151.         field:=blanks;
  152.         prompt(17,22,10,' ',false); {erase incorrect entry}
  153.         end_of_record:=false;{re-set flag}
  154.         repeat
  155.         field:= input(17,22,10, lower_case,alphanumric,field);
  156.         until (end_of_field) or (end_of_record) ;
  157.         error:=false;
  158.         goto 2; {try this again!}
  159.         end;
  160.  
  161.  
  162.  
  163.  
  164.  
  165.     
  166.     if new then newterms.code:=xcode else terms.code:=xcode;
  167.     end;
  168.  
  169. end; {of internal procedure}
  170.  
  171.  
  172. begin {******* of check code *******}
  173.  
  174.  
  175.  
  176. answer:=true;
  177. used:=false;
  178.  
  179.  
  180. dummy:=2;  {first term is in record number 2}
  181.  
  182. repeat
  183. read(fnumterms:dummy,terms);
  184. if xcode = terms.code then 
  185.         begin
  186.         if used = false then
  187.             begin
  188.             clear_screen;
  189.          prompt(1,1,0,'FOLLOWING TERMS HAVE THE SAME CODE:',false);
  190.             writeln;
  191.             end;
  192.             writeln(terms.term);
  193.             used:=true;
  194.             end;
  195. dummy:=dummy + 1;
  196. until dummy > numrecs - 1; {******** should this be minus 1 or just numrecs?}
  197.  
  198. if used then ok_code;
  199.  
  200. end;
  201.  
  202.  
  203.  
  204. procedure show_information(hardcopy:boolean);
  205. {$C-}
  206. {$R-}
  207. {$F-}
  208. {$M-}
  209. {$U-}
  210. var
  211. output:text;
  212. num:integer;
  213. dummy:byte;
  214. assigned_units:xtest_units;
  215.  
  216. begin
  217. with terms do
  218. begin
  219.  
  220. if hardcopy then rewrite('lst:',output) else rewrite('con:',output);
  221.  
  222. write(output,term:21);
  223. if needs_units = false then writeln(output,code:10:2) else
  224.         begin
  225.         write(output,trunc(code):10);
  226.         num:=trunc(((code-trunc(code))+0.001)*100.0);
  227.         for dummy:= 1 to num do assigned_units:= succ(assigned_units);
  228.         writeln(output,'UNITS: ':10,assigned_units:8);
  229.         end;
  230.  
  231.  
  232. end;
  233. end;
  234.  
  235.  
  236.  
  237.  
  238. function input (x,y,len:byte;xucase,xletters_only:boolean;field:data):data;
  239. {$R-}
  240. {$C-}
  241. {$M-}
  242. {$F-}
  243. {$U-}
  244. var
  245. end_of_field:boolean;
  246. dummy,counter:byte;
  247. letter:char;
  248.  
  249.  
  250.  
  251. procedure delete_letter;
  252. {$C-}
  253. {$R-}
  254. {$M-}
  255. {$F-}
  256. {$U-}
  257.  
  258.  
  259. begin
  260. if counter > 1 then counter:=counter - 1;
  261. write(chr(8),' ',chr(8));
  262. field[counter]:=' ';{erase letter in that position}
  263. end;
  264.  
  265.  
  266. procedure add_letter;
  267. {$C-}
  268. {$R-}
  269. {$M-}
  270. {$F-}
  271. {$U-}
  272.  
  273. begin
  274. field[counter]:=letter;
  275. counter:=counter +1;
  276. write(letter);
  277. end;
  278.  
  279.  
  280. {***** procedure input ******}
  281. begin
  282. counter:=1;
  283. end_of_field:=false;
  284. move_cursor(x,y);
  285. repeat
  286.  
  287.     keyin(letter);
  288.     
  289.     case ord(letter) of
  290.  
  291.     08: {backspace}  delete_letter;
  292.             
  293.     27: {esc}begin
  294.         terminate:=true; {let procedure add know to stop}
  295.          end_of_input:=true;
  296.         end;
  297.     13: {cr}  end_of_field:=true;
  298.  
  299.     09: {tab} end_of_record:=true;
  300.  
  301.     ELSE: begin
  302.  
  303.         if (counter = 1) and (letter = ' ') then delete_letter else
  304.  
  305.         if (xucase) and ((ord(letter) < 123) and (ord(letter) > 96))
  306.  
  307.            THEN
  308.             begin
  309.              letter:=chr(ord(letter)-32); {translate lc to uc}
  310.             add_letter;
  311.             end
  312.         ELSE  {exclude #s, punctuation and ^ chars if letters only}
  313.  
  314.         if (xletters_only) and (not(ord(letter) in
  315.              [0..31,33..64, 91..96, 123..126]))
  316.              THEN  add_letter
  317.                         
  318.         ELSE if (xletters_only = false) and
  319.               (ord(letter) in [32..126])
  320.             then add_letter
  321.  
  322.               end;
  323.  
  324.  
  325.     end; {of case}
  326.  
  327.  
  328. if counter = len+1 then  {don't allow user to enter too many letters}
  329.     begin
  330.     move_cursor(1,24);  {ring bell and place warning message on screen}
  331.     write(chr(7),'YOU HAVE ENTERED MORE THAN ',len:2,
  332.         ' CHARACTERS. PLEASE RE-ENTER.');
  333.     move_cursor(x+len,y); {reposition cursor to end of field}
  334.     for dummy:= 1 to len do delete_letter; {erase entry, re-set counter}
  335.     end;
  336.  
  337.  
  338. until (end_of_input) or (end_of_record) or (end_of_field);
  339. erase_lines(24,1);
  340. writeln;
  341. input:=field;
  342.  
  343. end; {of procedure}
  344.  
  345.  
  346.  
  347.  
  348.  
  349. function arraytoreal(field:data):real;
  350. {$C-}
  351. {$R-}
  352. {$M-}
  353. {$F-}
  354. {$U-}
  355.  
  356.  
  357. var
  358. decval,sign,val:real;
  359. decimal:boolean;
  360. dummy,junk:byte;
  361.  
  362.  
  363. begin
  364. decval:=0.0;
  365. val:=0.0;
  366. error:=false;
  367. decimal:=false;
  368.  
  369. dummy:=1; {first position in array of char}
  370.  
  371. sign:=1.0;
  372.  
  373. while (decimal = false) and (dummy < 81) do
  374. begin
  375.  
  376. case field[dummy] of 
  377.  
  378. '-': sign:=-1.0;
  379.  
  380. '.': decimal:=true;
  381.  
  382. '0','1','2','3','4','5','6','7','8','9': 
  383.     val:=(val*10) + (ord(field[dummy]) - 48);  {48 = ord of zero}
  384.  
  385. ' ': ; {ignore spaces}
  386.  
  387. else: error:=true; {warn if there are letters, control chars, etc}
  388.  
  389. end; {of case}
  390.  
  391. dummy:=dummy + 1;
  392.  
  393. end; {of while}
  394.  
  395.  
  396. junk :=80; {maximum or last position in array of char}
  397.  
  398. while (decimal = true) and (junk > dummy - 1) do  {dummy - 1 because inc above}
  399.  
  400. begin
  401.  
  402.     case field[junk] of 
  403.  
  404.     '0','1','2','3','4','5','6','7','8','9': 
  405.         decval:=(decval* 0.1) + ((ord(field[junk]) - 48) * 0.1);
  406.  
  407.     ' ': ; {ignore spaces}
  408.  
  409.     else: error:= true;  {catch trash}
  410.  
  411.  
  412.     end; {of case}
  413.  
  414.  
  415. junk:= junk - 1;
  416.  
  417.  
  418. end; {of while}
  419.  
  420. if error then prompt(1,24,0,'INVALID CODE. RE-ENTER!', false);
  421.  
  422. if val > 32000 then 
  423.     begin
  424.     error:= true;
  425.     prompt (1,24,0,'CODE MUST NOT EXCEED 32000',FALSE);
  426.     end; 
  427.  
  428.  
  429.  
  430. if val < 1 then
  431.     begin
  432.     error:=true;
  433.     prompt (1,24,0,'CODE CANNOT BE LESS THAN 1.0',false);
  434.     end;
  435.  
  436.  
  437. if needs_units AND (decval > 0) then
  438.     begin
  439.     error:=true;
  440. prompt(1,24,0,'CODE MUST NOT HAVE DIGITS TO THE RIGHT OF THE DECIMAL!',false);
  441.     end;
  442.  
  443.  
  444. arraytoreal:=sign*(decval + val);
  445.  
  446. end; {of procedure} 
  447.  
  448.  
  449.  
  450. function realtoarray(number:real):data;
  451. {$C-}
  452. {$R-}
  453. {$M-}
  454. {$F-}
  455. {$U-}
  456.  
  457. var
  458. digit,d,i:byte;
  459. temp:data;
  460. value,decimal,power:real; 
  461.  
  462.  
  463.  
  464. begin
  465.  
  466. digit:=0;
  467. d:=1;
  468. for i:= 1 to 80 do temp[i]:=' ';
  469.  
  470.  
  471. if number < 0.0 then        {check for minus number}
  472.     begin
  473.     temp[1]:='-';
  474.     number:=number* (-1.0);
  475.     d:=2;
  476.     end;
  477.  
  478.  
  479. {correct for error induced by floating point hardware...recall that }
  480. {Pascal/Z has 4 significant digits..}
  481.  
  482. if number < 1000.0 then number:=number + 0.0001 else 
  483.              number:=number + 0.001;
  484.  
  485.  
  486. {get the decimal part of the number, ie digits to the right of the decimal}
  487.  
  488. decimal:=number-trunc(number);
  489.  
  490.  
  491. {now determine the number of digits to the left of the decimal}
  492.  
  493. power:=10.0;
  494.  
  495. number:=number - decimal;  {remove the digits to right of decimal}
  496.  
  497. while trunc(number/power) > 0 do power:=power * 10.0;
  498.  
  499.  
  500. power:= power/10.0;
  501.  
  502.  
  503. {translate the digits to the left of the decimal into an array of char}
  504.  
  505. while ( d < 81) and ( power >= 1.0) do
  506.  
  507. begin
  508. digit:= trunc(number/power);  {get digit}
  509. temp[d]:=chr(digit + 48);     {48 = ord of zero}
  510. d:= d + 1;
  511. number:= number - (power*digit);
  512. power:= power/10.0;
  513. end;
  514.  
  515.  
  516.  
  517. temp[d]:='.';  {put in the decimal point}
  518. d:= d + 1;
  519.  
  520. {now translate the digits to right of decimal into array of char}
  521. {we know there can be only 4 since accurracy after that is not present}
  522.  
  523.  
  524. for i:= d to d+ 2 do
  525.     begin
  526.     value:=decimal*10.0;
  527.     digit:= trunc(value);
  528.     temp[i]:=chr(digit + 48);
  529.     decimal:= value - digit;
  530.     end;
  531.  
  532. realtoarray:=temp;
  533.  
  534. end;
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541. procedure get_info(new:boolean);
  542. {$R-}
  543. {$M-}
  544. {$C-}
  545. {$F-}
  546. {$u-}
  547. {new is true if this is a new terms;  false if terms already in file}
  548.  
  549. {these constants, types and variables need not be global to entire program;}
  550. {rather, they may be local to procedure that calls function input.....     }
  551.  
  552. {end_of_input is not used at this time since this is not a stand alone     }
  553. {procedure, but is rather called by add and change...hence it is included  }
  554. {only for completeness and future use...                                   } 
  555.  
  556.  
  557. label 2;
  558.  
  559.  
  560. var
  561. field:array[1..2] of data;
  562. num,i,dummy:byte;
  563. des_code:real;
  564. units:char;
  565. assigned_units:xtest_units;
  566.  
  567.  
  568. procedure print_form;  {internal proc display the form for user to "fill in"}
  569. {$C-}
  570. {$R-}
  571. {$M-}
  572. {$F-}
  573. {$U-}
  574.  
  575.  
  576. begin
  577. clear_screen;
  578. prompt(1,2,24,'TERM: ',true); 
  579. prompt(30,2,0,'CODE: ',true);
  580. end;
  581.  
  582.  
  583.  
  584. procedure unit_prompt;
  585.  
  586.  
  587. var
  588. x,y,d:byte;
  589.  
  590. begin
  591.  
  592.  
  593. assigned_units:=fake;
  594. for d:= 1 to 13 do 
  595.     begin
  596.     move_cursor(1,d+2);
  597.     assigned_units:=succ(assigned_units);
  598.     writeln(chr(d + 64),'- ',assigned_units);
  599.     end;
  600.  
  601.  
  602.  
  603. for d:= 14 to 24 do 
  604.     begin
  605.     move_cursor(40,d-11);
  606.     assigned_units:=succ(assigned_units);
  607.     writeln(chr(d+64),'- ',assigned_units);
  608.     end;
  609. prompt(1,18,1,'ENTER LETTER CORRESPONDING TO UNITS: ',false);
  610.  
  611. end;
  612.  
  613.  
  614.  
  615. procedure encode; {internal procedure}
  616.  
  617. var
  618. answer:char;
  619.  
  620. begin
  621.  
  622. repeat
  623. move_cursor(45,18);
  624. keyin(answer);
  625. write(answer);
  626. until answer in ['A'..'X','a'..'x'];
  627.  
  628. {allow for either upper or lower case  letter}
  629.  
  630. if answer in ['A'..'Y'] then num:= ord(answer) - 64 else
  631.                  num:= ord(answer) - 96;
  632. end;
  633.  
  634.  
  635.  
  636. {****************** GET INFO **********************}
  637. begin
  638. with terms do
  639. begin
  640.     end_of_input:=false;
  641.     end_of_record:=false; 
  642.     
  643.  
  644.     {now get the information for each field}
  645.  
  646.     {note the sublte use of "recursion" in that field is passed}
  647.     {as parameter into function that defines it...this allows  }
  648.     {the user to correct a field, or leave it alone, as the user}
  649.     {proceeds through entering information for record}
  650.  
  651.     {field #    variable        length of variable                 }
  652.  
  653.     {field 1    term                    21            }
  654.     {field 2    code            10             }
  655.     
  656.     {The following are all integers:  parent
  657.                       left
  658.                       right
  659.                                     }
  660.  
  661.  
  662. print_form;  {display the "form" for the user to "fill in"}
  663. prompt(1,20,0,'ENTER A <CR> TO MOVE FROM ITEM TO ITEM.',true);
  664. prompt(1,21,0,'ENTER A <TAB> WHEN ALL INFORMATION IS COMPLETE AND CORRECT.',
  665.     true);
  666. prompt(1,22,0,'ENTER A <ESC> TO RETURN TO THE MAIN MENU.',true);
  667.  
  668.  
  669.  
  670. {initialize field to all spaces}
  671. for dummy:= 1 to 2 do field[dummy]:=blanks;
  672.  
  673. if not new then  {show current values; set fields = current values}
  674.     begin
  675.     move_cursor(6,2);
  676.     write(term);
  677.     move_cursor(35,2);
  678.     if needs_units = false then write(code:5:2) else
  679.         begin
  680.         write(trunc(code):5);
  681.         num:=trunc(((code-trunc(code))+0.001)*100.0);
  682.         for dummy:= 1 to num do assigned_units:= succ(assigned_units);
  683.         writeln('UNITS: ',assigned_units:15);
  684.         end;
  685.  
  686.  
  687.  
  688.     
  689.     {now assign previous values to fields}
  690.  
  691.     for dummy:= 1 to 21 do field[1,dummy]:=term[dummy];
  692.     field[2]:=realtoarray(code);
  693. end;
  694.  
  695.  
  696. dummy:=1;
  697. repeat
  698.         case dummy of 
  699.  
  700.         1:  field[1]:= input( 6,2,21,ucase,alphanumeric,field[1]);
  701.         2:  field[2]:= input(35,2,10, lower_case,alphanumeric,field[2]);
  702.         end;
  703.  
  704.  
  705.         if dummy < 2 then dummy:= dummy + 1 else
  706.                          dummy:= 1;
  707.     
  708. until (end_of_record) or (end_of_input);
  709.  
  710. if not end_of_input then
  711. begin 
  712.  
  713. {now assign each field to record's variable}
  714.  
  715. for dummy:= 1 to 21 do  term[dummy]:=     field[1,dummy];
  716.  
  717. 2:des_code:= arraytoreal(field[2]);
  718.     
  719.         if error then 
  720.         begin
  721.         field[2]:=blanks;
  722.         prompt(35,2,10,' ',true); {erase incorrect entry}
  723.         end_of_record:=false;{re-set flag}
  724.         repeat
  725.         field[2]:= input(35,2,10, lower_case,alphanumric,field[2]);
  726.         until end_of_record ;
  727.         error:=false;
  728.         goto 2; {try this again!}
  729.         end;
  730.  
  731.  
  732. if needs_units then {add a fraction to code that represents units...}
  733.     begin
  734.     unit_prompt;
  735.     encode;
  736.     des_code:= des_code + (num/100) + 0.001;
  737.     end;
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744. case new of
  745. true:     begin
  746.     print_flag:=false; {init this field}
  747.     code:=des_code;
  748.     newterms:=terms;
  749.     end;
  750.  
  751. false:if des_code <> 0.0 then code:=des_code;
  752.  
  753. end;
  754.  
  755. end; {of if not end of input}
  756. end; {of with terms}
  757. end;
  758.  
  759. procedure search(recno:integer;key:real;key1:char21; delete:boolean);
  760. {$R-}
  761. {$C-}
  762. {$F-}
  763. {$M-}
  764. {$U-}
  765. begin
  766. with terms do
  767. begin
  768. found:=false;
  769. reference_number:=0;
  770. last_rec:=0;
  771.  
  772. read(fnumterms:recno,terms);
  773.  
  774. if (key = code) and (key1 <> term) then { = codes stored to left in tree}
  775.                 if left = 0 then found:=false else
  776.                         search(left,key,key1,delete)
  777.  
  778. ELSE
  779.  
  780. if (key = code) and (key1 = term) then
  781.     begin
  782.     found:=true;
  783.     last_rec:=parent;
  784.     reference_number:=recno;
  785.     if (delete = false) {ie only need to change term assigned code}
  786.         then
  787.             begin
  788.             term:=newterms.term;{change term, don't lose pointers}
  789.              write(fnumterms:recno,terms);{rewrite with new term}
  790.             end;
  791.     end
  792.  
  793. ELSE
  794.  
  795. if key < code then if left = 0 then found:=false else
  796.             search (left,key,key1,delete)
  797.  
  798. ELSE
  799.  
  800. if key > code then if right = 0 then found:=false else
  801.             search (right,key, key1, delete);
  802.  
  803.  
  804.  
  805. end;
  806. end;
  807.  
  808. procedure find(code:boolean;flag:byte);
  809.  {flag indicates whether find was called from menu (=0),change (=1)}
  810.  {it also = 1 if called from delete since delete will display term}
  811.  {code indicates whether to search for diagnostic term }
  812.  
  813. {procedure to find if a term exists in the file. The terms is located}
  814. {by a "key" which is the terms.}
  815. {$C-}
  816. {$F-}
  817. {$M-}
  818. {$R-}
  819. {$U-}
  820. label 1;
  821.  
  822. var
  823. found,correct,continue:boolean;
  824. key:char21;
  825. counter,dummy:integer;
  826.  
  827.  
  828. procedure ask_term;  {internal procedure}
  829. {$C-}
  830. {$R-}
  831. {$M-}
  832. {$F-}
  833. {$U-}
  834.  
  835. var
  836. field:data;
  837. dummy,x,y:byte;
  838.  
  839.  
  840. begin
  841. end_of_input:=false;
  842. end_of_record:=false;
  843. field:=blanks;{init}
  844.  
  845. if recursive = false then
  846.         begin
  847.         x:=17;
  848.         y:=1;
  849.          clear_screen;
  850.         end
  851. else begin
  852.     x:=17;
  853.     y:=20;
  854.     end;
  855.  
  856. write('ENTER TERM ---> ');
  857. field:=input(x,y,21,true,false,field);
  858. for dummy:= 1 to 21 do key[dummy]:=field[dummy];
  859.  
  860. end;
  861.  
  862.  
  863. procedure list_terms(letter:char);
  864. {$C-}
  865. {$R-}
  866. {$M-}
  867. {$F-}
  868. {$U-}
  869.  
  870.  
  871. var
  872. dummy:integer;
  873. counter:byte;
  874. scrolling:char;
  875.  
  876. begin
  877.  
  878. counter:=1;
  879.  
  880. with terms do
  881. begin
  882. for dummy:= 2 to numrecs do
  883. begin
  884. read(fterms:dummy,terms);
  885. if (letter = term[1]) and (code <> -999.0){ie not deleted}  then
  886.         begin
  887.         counter:=counter + 1;
  888.         if counter < 19 then move_cursor(1,counter)
  889.                      
  890.               else
  891.             if counter < 38 then move_cursor(45,counter-19)
  892.  
  893.             else
  894.              begin            
  895.         prompt(1,20,0,'ENTER ANY CHARACTER TO CONTINUE. ',false);
  896.             keyin(scrolling);    
  897.             clear_screen;
  898.             counter:=3;
  899.             move_cursor(1,counter);
  900.             end;
  901.  
  902.         write(term:21);
  903.         if needs_units then writeln(trunc(code):10) 
  904.                 ELSE writeln(code:10:3);
  905.         end;
  906. end;
  907. end;{of with}
  908. end; {of internal procedure}
  909.  
  910.  
  911.  
  912.  
  913. procedure search(recno:integer; key:char21); 
  914. {$C-}
  915. {$R-}
  916. {$M-}
  917. {$F-}
  918. {$U-}
  919.  
  920.  
  921. {internal procedure}
  922.  
  923.  
  924. begin
  925. with terms do
  926. begin
  927. found:=false;
  928. reference_number:=0;  {set = 0 as flag to calling procedure}
  929. last_rec:=0;
  930. read(fterms:recno,terms);
  931.  
  932. if (key = term) then
  933.     begin
  934.      found:=true;
  935.     last_rec:=parent;
  936.     reference_number:=recno;  {return the recno for DELETE and CHANGE}
  937.     end
  938.  
  939.  ELSE
  940.  
  941.     if key < term then
  942.         if left = 0 then found:=false
  943.                      ELSE search(left,key)
  944.  
  945.     ELSE 
  946.  
  947.     if key > term then
  948.         if right = 0 then found:=false
  949.  
  950.                       ELSE search(right,key);
  951. end;{of with}
  952. end;{of procedure}
  953.  
  954.  
  955.  
  956. begin {************* of procedure find ***************}
  957.  
  958. continue:=true;
  959.  
  960. while continue do
  961. begin
  962. counter:=0;
  963. correct:=true;{exit condition}
  964. ask_term; 
  965.  
  966. search(1,key);
  967.  
  968. 1: if (found) and (flag = 0) then
  969.     begin
  970.      clear_screen;{don't show if called from CHANGE or DELETE}
  971.     show_information(false);
  972.     end;
  973.     
  974.  
  975. if not found then
  976.     begin
  977.     clear_screen;
  978.     writeln('TERM NOT FOUND! TERMS BEGINNING WITH ',key[1]:1);
  979.     counter:=3;
  980.     list_terms(key[1]);    {list all names with same letter}
  981.     end;
  982.  
  983.  
  984. if (found = false) and (counter <> 0) {counter acts as flag here} then
  985.     begin
  986.     continue:= query(1,20,'WOULD YOU LIKE TO RE-ENTER THE TERM? Y/N  ');
  987.     if continue then
  988.             begin
  989.             recursive:=true;
  990.              find(false,flag);
  991.             end;
  992.     end;
  993.  
  994. if (flag = 0) and (counter = 0) then
  995.  {don't even ask unless find was called from menu}
  996.      continue:= query(1,20,'WOULD YOU LIKE TO FIND ANOTHER TERM? Y/N  ')
  997.  ELSE
  998.     continue:=false;
  999.  
  1000. end; {of while continue}
  1001. end;
  1002.  
  1003.  
  1004.  
  1005. procedure add(change,numfile:boolean);
  1006. {$C-}
  1007. {$M-}
  1008. {$U-}
  1009. {$R-}
  1010. {$F-}
  1011. label 2;
  1012. type
  1013. which_pointer = (xleft,xright);
  1014.  
  1015. var
  1016. num_next,dup_rec_no,dup_left,i,f_numrecs,f_left,f_right,next,dummy:integer;
  1017. key:char21;
  1018. used_code,answer,duplicate: boolean; 
  1019.  
  1020.  
  1021.  
  1022. {*********** find correct place in file and put record there ************}
  1023. procedure update(recnum:integer;d:which_pointer;numfile:boolean);
  1024. {$C-}
  1025. {$R-}
  1026. {$M-}
  1027. {$F-}
  1028. {$U-}
  1029.  
  1030. var
  1031. parent_node:integer;
  1032.  
  1033. begin
  1034. with terms do
  1035. begin
  1036.  
  1037. {load variable terms with proper information; this step is necessary since }
  1038. {when insert checked to see if any codes were used previously, it read the}
  1039. {file, and hence reassigned values to terms different than those last assigned}
  1040. {in procedure insert...                                }
  1041.  
  1042.  
  1043. if numfile = false then
  1044.     begin
  1045.      read(fterms:recnum,terms);
  1046.      {determine pointer to change; make it point to new rec}
  1047.     case d of          
  1048.     xright: right:=next;
  1049.     xleft:  left:=next; 
  1050.     end;
  1051.     end
  1052.  
  1053. ELSE
  1054.     BEGIN
  1055.     read(fnumterms:recnum,terms); 
  1056.     {determine pointer to change; make it point to new rec}
  1057.     case d of          
  1058.     xright: right:=num_next;
  1059.     xleft:  left:=num_next; 
  1060.     end;
  1061.     end;
  1062. parent_node:=recnum;  {set pointer in new record to point to predecessor}
  1063.  
  1064. {update rec; ie point to new rec}
  1065. if numfile = false then write(fterms:recnum,terms)
  1066.                    else write(fnumterms:recnum,terms);
  1067.  
  1068.  
  1069.  
  1070. {now add new rec to end of file}
  1071.  
  1072. terms:=newterms;  {assign new information to the variable terms}
  1073. right:=0;
  1074. left:=0;
  1075.  
  1076. parent:=parent_node; {set pointer to predecessor}
  1077.  
  1078. if duplicate then left:=dup_left; {true only num file since dup terms not poss}
  1079.  
  1080.  
  1081. if numfile = false then write(fterms:next,terms)  {write new record to file}
  1082.            else write(fnumterms:num_next,terms);
  1083.  
  1084.  
  1085. {write code to array in terms.num using a 1:1 correspondence of rec number  }
  1086. {and position in the array...at this point, just update array. At conclusion}
  1087. {when first record is updated, update the actual disk file..................}
  1088.  
  1089. if numfile = false then 
  1090. {update counter for first record of file to reflect increase in # of recs}
  1091. begin
  1092. next:=next +1;{increment number of records}
  1093. f_numrecs:=next;
  1094. numrecs:=next; {update so procedure check will keep searching}
  1095. end
  1096.  
  1097. ELSE num_next:=num_next + 1; {update counter for the .nx file}
  1098.  
  1099. end; {of with}
  1100. end; {of procedure}
  1101.  
  1102.  
  1103.  
  1104.  
  1105. {******************* find where in num file to put record ******************}
  1106. procedure num_insert(rec_no:integer;key:real);
  1107. {$C-}
  1108. {$R-}
  1109. {$M-}
  1110. {$F-}
  1111. {$U-}
  1112.  
  1113.  
  1114. label 1;
  1115. begin
  1116. duplicate:=false;
  1117.  
  1118. with terms do
  1119. begin
  1120.  
  1121.  
  1122. read(fnumterms:rec_no,terms);
  1123.  
  1124. if key = code then
  1125.     begin
  1126.     dup_rec_no:=rec_no;
  1127.     dup_left:=left;
  1128.     duplicate:=true;
  1129.      update(dup_rec_no,xleft,true);
  1130.     goto 1;
  1131.     end;
  1132.  
  1133. if key < code then
  1134.                if left <> 0 then num_INSERT(left,key)  
  1135.                     {keep going until you find appropriate place in tree}
  1136.  
  1137.                             ELSE
  1138.                  UPDATE(rec_no,xleft,true)
  1139.                 
  1140. ELSE
  1141.  
  1142. if key > code then
  1143.              if right <> 0 then num_INSERT(right,key)
  1144.  
  1145.                             ELSE
  1146.                  UPDATE(rec_no,xright,true);
  1147.  
  1148. 1:
  1149. end;
  1150. end;
  1151.  
  1152.  
  1153.  
  1154. {********************* add a term to the file *********************}
  1155. Procedure Insert( rec_no:integer;key:char21);
  1156. {$C-}
  1157. {$R-}
  1158. {$M-}
  1159. {$F-}
  1160. {$U-}
  1161.  
  1162.  
  1163. label 1;
  1164. var
  1165. answer,duplicate: boolean; 
  1166. dup_rec_no,dup_left:integer;
  1167. dummy,dummy1:byte;
  1168.  
  1169.  
  1170. begin  {of procedure insert}
  1171. duplicate:=false;
  1172. used_code:=false;
  1173. with terms do
  1174. begin
  1175. read(fterms:rec_no,terms);
  1176.  
  1177. if key = term then
  1178.     begin
  1179.     prompt(1,24,0,'TERM ALREADY IN FILE!',FALSE);     
  1180.     for dummy:= 1 to 40 do for dummy1:= 1 to 30 do; {delay to read msg}
  1181.     GOTO 1;
  1182.     END;
  1183.  
  1184.  
  1185. if key < term then
  1186.                if left <> 0 then INSERT(left,key)  
  1187.                     {keep going until you find appropriate place in tree}
  1188.  
  1189.                             ELSE
  1190.                 begin
  1191.                 if change = false then { * see note below}
  1192.                     begin
  1193.                     check_code(true,newterms.code,rec_no);
  1194.                      num_insert(1,newterms.code);
  1195.                     end;
  1196.                 UPDATE(rec_no,xleft,false);
  1197.                 end
  1198.                 
  1199. ELSE
  1200.  
  1201. if key > term then
  1202.              if right <> 0 then INSERT(right,key)
  1203.  
  1204.                             ELSE
  1205.                 begin
  1206.                 if change = false then
  1207.                     begin
  1208.                     check_code(true,newterms.code,rec_no);
  1209.                     num_insert(1,newterms.code);
  1210.                     end;
  1211.                  UPDATE(rec_no,xright,false);
  1212.                 end;
  1213. 1:
  1214.  
  1215.  
  1216. end; {of with}
  1217. end; {of procedure}
  1218.  
  1219. { * note: if called from change, do not add to num file from here, since  }
  1220. { if just term was changed, and not code, need not create new record in num}
  1221. { file.  On other hand, if both code and term were changed, procedure change}
  1222. { will make sure both files -- num and dx -- are modified...              }
  1223.  
  1224.  
  1225. {****************** begin of procedure add ****************************}
  1226. begin
  1227. terminate:=false;
  1228. read(fterms:1,terms);  {find next available record number}
  1229. next:=trunc(terms.code);
  1230. numrecs:=next;
  1231.  
  1232. if next > 32700 then 
  1233.     begin
  1234.     clear_screen;
  1235.     writeln('SORRY, FILE IS FULL! NO ADDITIONAL TERMS CAN BE ADDED.');
  1236.     for dummy:= 1 to 40 do for i:= 1 to 40 do; {delay to read message} 
  1237.     goto 2;
  1238.     end;
  1239.  
  1240. read(fnumterms:1,terms);{the number of recs in this file will not = that in}
  1241. num_next:=trunc(terms.code);
  1242.              {.dx file because when a term is changed, it is de-}
  1243.             {leted from .dx, and new term added, thereby incre-}
  1244.             {menting numrecs (next), whereas only the term is  }
  1245.             {modified in .nx and no new record is added}
  1246.  
  1247. if change = false then
  1248. begin
  1249.  
  1250. repeat
  1251. get_info(true); {the parameter true means that this is info for a new record}
  1252. used_code:=false;
  1253. key:=newterms.term;
  1254. if not terminate then
  1255.     BEGIN
  1256.     duplicate:=false;
  1257.      insert(1,key);
  1258.     end;
  1259. until terminate;
  1260.  
  1261.  
  1262.  
  1263. end {of if change = false}
  1264.  
  1265.  
  1266. ELSE {change=true,ie add was called from procedure change }
  1267.  
  1268. if numfile then num_insert(1,newterms.code)  
  1269. ELSE
  1270. begin
  1271. duplicate:=false;
  1272. insert(1,newterms.term);
  1273. end;
  1274.  
  1275.  
  1276. if numfile = false then 
  1277. begin  {update the first record in the .dx file}
  1278. read(fterms:1,terms);
  1279. terms.code:=f_numrecs;
  1280. write(fterms:1,terms);
  1281. end;
  1282.  
  1283. {update the first record of the .nx file since whether change code or term }
  1284. {this value changes...}
  1285. read(fnumterms:1,terms);
  1286. terms.code:=num_next;
  1287. write(fnumterms:1,terms);
  1288.  
  1289. 2:
  1290. terminate:=false;  {reset this global variable so program won't terminate}
  1291. end;
  1292.  
  1293.  
  1294. {procedure to delete a name from the file based on term}
  1295.  
  1296.  
  1297. procedure delete(change,numfile:boolean);
  1298. {$C-}
  1299. {$M-}
  1300. {$F-}
  1301. {$R-}
  1302. {$U-}
  1303. var
  1304. cur_parent,cur_right,cur_left,cur_recno,new_left:integer;
  1305. continue,correct:boolean;
  1306. dummy:byte;
  1307. x:fxterms; {dummy variable to save a lot of if statements!}
  1308. recall_term:char21;
  1309. recall_code:real;
  1310.  
  1311.  
  1312. {************ rewrite pointers thereby deleting record ***************}
  1313. procedure del (recno:integer;numfile:boolean);
  1314. {$C-}
  1315. {$R-}
  1316. {$M-}
  1317. {$F-}
  1318. {$U-}
  1319.  
  1320.  
  1321. label 1;
  1322. var
  1323. point:integer;
  1324.  
  1325. begin
  1326. with terms do
  1327. begin
  1328. if numfile then reset(num_file,x) else reset(term_file,x);
  1329.  
  1330.  
  1331. if (left = 0) or (right = 0) then  {case 1 or no descendents}
  1332.     begin
  1333.     {determine value to place in pointers of last record}
  1334.     if left = 0 then point:=right else point:= left;
  1335.     read(x:last_rec,terms);
  1336.     {determine which pointer of last record to update}
  1337.     if left = recno then left:=point else right:=point;
  1338.     write(x:last_rec,terms);
  1339.     terms.term:='ZZZZZZZZZZZZZZZZZZZZZ';
  1340.     terms.code:=-999.0;
  1341.     write(x:reference_number,terms);{marked rec deleted}
  1342.     goto 1;
  1343.     end;
  1344.  
  1345.  
  1346.  
  1347.  
  1348. {in the case of two descendents, move right most branch of 1st }
  1349. {descendent on left, to the node that is being deleted       }
  1350. {note that right most branch will have pointers of left = 0, right = 0}
  1351. {in essence, just substituting name, address, "vital signs"...pointers}
  1352. {remain intact}
  1353.  
  1354.  
  1355.  
  1356. if (left <> 0) and (right <> 0) then    {case of two descendents}
  1357.     begin
  1358.  
  1359. {store pointers of record being deleted}
  1360.     cur_left:=left;
  1361.     cur_right:=right;
  1362.     cur_recno:=recno;
  1363.     cur_parent:=parent;
  1364.  
  1365. {per algorithm, move one node to left}
  1366.     read(x:cur_left,terms);
  1367.     last_rec:=cur_left;
  1368.  
  1369. {now go as far right as possible}
  1370.     while right <> 0 do
  1371.         begin
  1372.         last_rec:=right;
  1373.           read(x:right,terms); 
  1374.         end;
  1375.  
  1376. {take the terms information in this node, and move it to "deleted" node }
  1377.     right:=cur_right;
  1378.     left:=cur_left;
  1379.     parent:=cur_parent;
  1380.     write(x:cur_recno,terms);
  1381.  
  1382. {set right = 0 for node that used to point to last node on right}
  1383.     read(x:last_rec,terms);
  1384.     right:=0;
  1385.     write(x:last_rec,terms);
  1386.  
  1387.     end;
  1388. {$E-}        
  1389. 1:
  1390. end;{of with}
  1391. end;{of internal procedure del}
  1392.  
  1393.  
  1394. {************************ begin of procedure delete *********************}
  1395.  
  1396. begin
  1397. if change = false then
  1398. begin
  1399. continue:=true;
  1400. while continue do
  1401. begin
  1402. find(false,1);
  1403.  
  1404. recall_code:=terms.code; {need to remember these for del .num since values of}
  1405. recall_term:=terms.term; {term and code change during del .dx                }
  1406.  
  1407. if last_rec = 0 {ie name not found} then
  1408.     begin
  1409.     clear_screen;
  1410.     prompt(1,12,0,'NO DELETION PERFORMED.',false);
  1411.     end
  1412.  
  1413. ELSE
  1414.  
  1415. if last_rec <> 0 {ie name found} then
  1416. begin
  1417. clear_screen;
  1418. show_information(false);
  1419. correct:=query(1,24,'IS IT OK TO DELETE THIS TERM? Y/N');
  1420.     if correct then
  1421.         begin
  1422.          del(reference_number,false);{remove term from file}
  1423.         
  1424.  
  1425.         search(1,recall_code,recall_term,true);
  1426.  
  1427.         del(reference_number,true);
  1428.         clear_screen;
  1429.         prompt(1,12,0,'TERM DELETED FROM FILE!!',false);
  1430.         end;
  1431.  
  1432.  
  1433. end;
  1434.  
  1435. continue:=query(1,24,'WOULD YOU LIKE TO DELETE ANOTHER TERM? Y/N');
  1436. end; {of while continue}
  1437.  
  1438. end {of if change = false}
  1439.  
  1440.  
  1441. ELSE {if delete is called from change}
  1442.  
  1443. if numfile then del(reference_number,true)  {if numfile is to be modified}
  1444.  
  1445.     ELSE del(reference_number,false); {if .dx file is to be modified}
  1446.  
  1447. end;
  1448.  
  1449.  
  1450.  
  1451. procedure change;
  1452. {$C-}
  1453. {$R-}
  1454. {$M-}
  1455. {$F-}
  1456. {$U-}
  1457.  
  1458.  
  1459. label 1;
  1460. var
  1461. continue:boolean;
  1462. recall_code:real;
  1463. recall_term:char21;
  1464.  
  1465.  
  1466. {there are four possibilities or cases with respect to changing the files:}
  1467. {    TERM        CODE    } 
  1468. {                }
  1469. {    same        same    }
  1470. {    changed         changed }
  1471. {    same            changed }
  1472. {    changed        same    }
  1473. {                }
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480. begin
  1481.  
  1482. continue:=true;
  1483. while continue do
  1484. begin
  1485.  
  1486. find(false,1);  {returns,if term is found: found:=true; reference number = }
  1487.             {recno for that term and last rec = parent for that term   }
  1488.  
  1489. if reference_number > 0 {ie terms is in file}  then
  1490.     begin
  1491.     recall_code:=terms.code; {remember the original information}
  1492.     recall_term:=terms.term;
  1493.  
  1494.     newterms:=terms; {save all pointers}
  1495.  
  1496.     get_info(false);  {false means terms already exists;get new info}
  1497.     newterms.term:=terms.term; {assign new values}
  1498.     newterms.code:=terms.code;
  1499.     
  1500.  
  1501. {CASE ONE:}
  1502.     {if neither the term nor the code has changed, SKIP TO QUERY}
  1503.     if (recall_code = newterms.code) and (recall_term = newterms.term)
  1504.         then
  1505.             begin
  1506.             clear_screen;
  1507.              goto 1;
  1508.             end;
  1509.  
  1510.     {if the code has been changed, make sure it is ok}
  1511. {CASE TWO:}
  1512.          
  1513.     {if code has changed, but not term then (1) must change code and}
  1514.     {rewrite record in .dx file, and (2) delete original code's record}
  1515.     {in .num file, and write new record with new code in .num file    }
  1516.  
  1517.  
  1518.  
  1519.     if (recall_code <> newterms.code) and (recall_term = newterms.term)
  1520.          then 
  1521.             begin
  1522.             check_code(false,newterms.code,reference_number);
  1523.  
  1524.             write(fterms:reference_number,newterms);
  1525.  
  1526.             {find orig record in .num file and delete}
  1527.             search(1,recall_code,recall_term,true);
  1528.             {should return, if code found: found:=true,      }
  1529.             {reference number = recno for code, last rec = parent}
  1530.  
  1531.  
  1532.             delete(true,true);{true=called from change; true =}
  1533.                       {modify numfile ...          } 
  1534.  
  1535.             {now add new term and code to .num file}
  1536.             add(true,true);
  1537.             end;
  1538.  
  1539. {CASE THREE:}
  1540.  
  1541.     {if term has changed, but not code then (1) must delete old term from}
  1542.     {.dx file and (2) rewrite new term in file and (3) change term in    }
  1543.     { .num file..if code has changed, then situation taken care of above }
  1544.     
  1545.     if (recall_term <> newterms.term) and (recall_code = newterms.code)
  1546.          then
  1547.     begin
  1548.     delete(true,false); {true=called from change; false=not numfile}
  1549.     add(true,false);
  1550.  
  1551.     search(1,recall_code,recall_term,false);{false means write new info}
  1552.     {in this case, search will change term in .num file}
  1553.     end;
  1554.  
  1555.     
  1556.     {if BOTH code and term changed then must (1) delete orig code from  }
  1557.     {.num file (2) delete orig term from .dx file (3) add new code to   }
  1558.     {.num file (4) add new term and code to .dx file.....            }
  1559.  
  1560.  
  1561. {CASE FOUR:}
  1562.  
  1563.     if (recall_code <> newterms.code) and (recall_term <> newterms.term)
  1564.        then
  1565.         begin
  1566.         delete(true,false);{these two lines handle the .dx file}
  1567.         add(true,false);
  1568.  
  1569.         
  1570.         {find orig record in .num file and delete}
  1571.         search(1,recall_code,recall_term,true);
  1572.         delete(true,true);{true=called from change; true =}
  1573.                   {modify numfile ...          } 
  1574.  
  1575.         {now add new term and code to .num file}
  1576.         add(true,true);
  1577.         end;
  1578.  
  1579.  
  1580.     clear_screen;
  1581.     prompt(1,10,0,'TERM HAS BEEN MODIFIED.',false);
  1582.     end
  1583.  
  1584.  
  1585. else {term was not found so no modification possible}
  1586.     begin
  1587.     clear_screen;
  1588.     prompt(1,10,0,'NO MODIFICATION POSSIBLE!',false);
  1589.     end;
  1590. 1:
  1591. continue:=query
  1592.     (1,24,'WOULD YOU LIKE TO MODIFY INFORMATION ON ANOTHER TERM? Y/N ');
  1593.  
  1594. end; {of while}
  1595.  
  1596. end; {of procedure}
  1597.  
  1598.  
  1599.  
  1600. procedure menu;
  1601. {$R-}
  1602. {$U-}
  1603. {$F-}
  1604. {$M-}
  1605. {$C-}
  1606. var
  1607. selection:char;
  1608. dummy,dummy1:byte;
  1609.  
  1610.  
  1611. begin
  1612. recursive:=false;
  1613. clear_screen;
  1614. writeln;{these two lines delay the program for terminal to react to clear scr}
  1615. writeln; 
  1616. writeln
  1617. ('TERMS MANAGEMENT PROGRAM. COPYRIGHT 1982 BY CRAIG RUDLIN,MD':70);
  1618. writeln;
  1619. writeln;
  1620. writeln('1- ADD a new term ');
  1621. writeln;
  1622. writeln('2- DELETE a term ');
  1623. writeln;
  1624. writeln('3- CHANGE a term or a term''s code');
  1625. writeln;
  1626. writeln('4- DISPLAY a term and it''s code');
  1627. writeln;
  1628. writeln('5- DISPLAY ALL terms on the screen'); 
  1629. writeln;
  1630. writeln('6- PRINT all terms'); 
  1631. writeln;
  1632. writeln;
  1633. writeln('7- SWITCH to another file of terms');
  1634. writeln;
  1635. writeln('0- EXIT this program.');
  1636. writeln;
  1637. writeln;
  1638. write('ENTER THE NUMBER OF YOUR SELECTION ---> ');
  1639. keyin(selection);
  1640. write(selection);
  1641.  
  1642. case selection of
  1643. '1': add(false,false);
  1644. '2': delete(false,false);
  1645. '3': change;
  1646. '4': find(false,0);
  1647. '5': print_terms(false);
  1648. '6': print_terms(true);
  1649. '7': begin
  1650.      command_line:=blanks;
  1651.      initialize;
  1652.      end;
  1653. '0': begin
  1654.      terminate:=true;
  1655.      clear_screen;  {clear screen upon exiting program}
  1656.      end;
  1657. else: menu; {don't except an invalid answer}
  1658.  
  1659. end; {of case}
  1660.  
  1661. end; {of procedure}
  1662.  
  1663. . {end of separate compilation}