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