home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / packer / arc / arctool / flddemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-09-29  |  8.0 KB  |  307 lines

  1. {                      F i l e    I n f o r m a t i o n
  2.  
  3. * DESCRIPTION
  4. File used with FIELD.PAS.
  5.  
  6. * ASSOCIATED FILES
  7. FIELD.PAS
  8. FLDDEMO.PAS
  9. FLDTEST.PAS
  10. OLDDEMO.PAS
  11. FIELD.TXT
  12.  
  13. }
  14. Program fielddemo;
  15.  
  16. {N+}
  17.  
  18. Uses Crt,Dos,field;
  19.  
  20. Type linestring = String[80];
  21.      namestring = String[16];
  22.      direction  = (up,down,left,right);
  23.      component  = 1..28;
  24.  
  25. Const nextfldnum: Array[component,direction] Of Byte
  26.                   = ((10,2,21,11),
  27.                      (1,3,22,12),
  28.                      (2,4,23,13),
  29.                      (3,5,24,14),
  30.                      (4,6,25,15),
  31.                      (5,7,26,16),
  32.                      (6,8,27,17),
  33.                      (7,9,28,18),
  34.                      (8,10,19,19),
  35.                      (9,1,20,20),
  36.                      (20,12,1,21),
  37.                      (11,13,2,22),
  38.                      (12,14,3,23),
  39.                      (13,15,4,24),
  40.                      (14,16,5,25),
  41.                      (15,17,6,26),
  42.                      (16,18,7,27),
  43.                      (17,19,8,28),
  44.                      (18,20,9,9),
  45.                      (19,11,10,10),
  46.                      (28,22,11,1),
  47.                      (21,23,12,2),
  48.                      (22,24,13,3),
  49.                      (23,25,14,4),
  50.                      (24,26,15,5),
  51.                      (25,27,16,6),
  52.                      (26,28,17,7),
  53.                      (27,21,18,8));
  54.  
  55.       compname: Array[component] Of namestring
  56.                 = ( 'Hydrogen',
  57.                     'Nitrogen',
  58.                     'Oxygen',
  59.                     'Water',
  60.                     'Carbon Monoxide',
  61.                     'Carbon Dioxide',
  62.                     'Hydrogen Sulfide',
  63.                     'Sulfur Dioxide',
  64.                     'Benzene',
  65.                     'Toluene',
  66.                     'Methane',
  67.                     'Ethane',
  68.                     'Propane',
  69.                     'i-Butane',
  70.                     'n-Butane',
  71.                     'Neopentane',
  72.                     'i-Pentane',
  73.                     'n-Pentane',
  74.                     'n-Hexane',
  75.                     'n-Heptane',
  76.                     'Ethylene',
  77.                     'Propylene',
  78.                     'i-Butane',
  79.                     '1-Butene',
  80.                     't-2-Butene',
  81.                     'c-2-Butene',
  82.                     '1-Pentene',
  83.                     '1,3-Butadiene' );
  84.  
  85.       compmolewt: Array[component] Of Real
  86.                  = (  2.016,
  87.                      28.013,
  88.                      31.999,
  89.                      18.015,
  90.                      18.010,
  91.                      44.010,
  92.                      34.076,
  93.                      64.059,
  94.                      78.114,
  95.                      92.141,
  96.                      16.043,
  97.                      30.070,
  98.                      44.097,
  99.                      58.124,
  100.                      58.124,
  101.                      72.151,
  102.                      72.151,
  103.                      72.151,
  104.                      86.178,
  105.                     100.205,
  106.                      28.054,
  107.                      42.081,
  108.                      56.108,
  109.                      56.108,
  110.                      56.108,
  111.                      56.108,
  112.                      70.135,
  113.                      54.092 );
  114.  
  115.       maxcompnum = 28;
  116.  
  117. Var fldnum: Byte;
  118.     maxfldnum: Byte;
  119.     fldlength: Byte;
  120.     decpla: Byte;
  121.     returnkey: Byte;
  122.     startrow: Byte;
  123.     rowcount: Byte;
  124.     compcount: Byte;
  125.     count: Byte;
  126.     compnumber: Byte;
  127.     maxrow: Byte;
  128.  
  129.     col: Array[1..3] Of Byte;
  130.     colindex: Byte;
  131.  
  132.     totalmassflow: Real;
  133.     totalmoleflow: Real;
  134.     moleweight: Real;
  135.  
  136.     text: linestring;
  137.     value: linestring;
  138.  
  139.     success: Boolean;
  140.  
  141.     compmassflow: Array[component] Of Real;
  142.     compmoleflow: Array[component] Of Real;
  143.  
  144.  
  145. Procedure beep;
  146.  
  147. Begin
  148.   Write(chr(7))
  149. End;
  150.  
  151. Begin
  152.   reversevideo:=False;
  153.   zerovoid:=True;
  154.   hitxtcolor:=Yellow;
  155.   lotxtcolor:=LightGray;
  156.   txtbkgnd:=Black;
  157.   cursor(hidden);
  158.   TextMode(CO80);
  159.   TextColor(lotxtcolor);
  160.   TextBackground(txtbkgnd);
  161.  
  162.   Repeat
  163.  
  164.     ClrScr;
  165.     For count:=1 To maxcompnum Do compmassflow[count]:=0;
  166.  
  167.     text:='Refinery Gas Molecular Weight';
  168.     GotoXY(39-(length(text) Div 2),2);
  169.     Write(text);
  170.  
  171.     startrow:=6;
  172.     col[1]:=1;
  173.     col[2]:=31;
  174.     col[3]:=55;
  175.     colindex:=1;
  176.     rowcount:=0;
  177.     compcount:=0;
  178.     maxrow:=10;
  179.  
  180.     Repeat
  181.       Repeat
  182.         GotoXY(col[colindex],startrow+rowcount);
  183.         inc(compcount);
  184.         If compcount <= maxcompnum Then Write(compname[compcount]);
  185.         Inc(rowcount);
  186.       Until rowcount = maxrow;
  187.       Inc(colindex);
  188.       rowcount:=0
  189.     Until compcount >= maxcompnum;
  190.  
  191.     maxfldnum:=maxcompnum;
  192.     fldlength:=7;
  193.     decpla:=0;
  194.     col[1]:=19;
  195.     col[2]:=43;
  196.     col[3]:=70;
  197.     fldnum:=1;
  198.     firstpass:=True;
  199.  
  200.     Repeat
  201.  
  202.       Repeat
  203.         rowcount:=0;
  204.         compnumber:=1;
  205.         colindex:=1;
  206.         success:=False;
  207.  
  208.         Repeat
  209.           Repeat
  210.             If compnumber = fldnum Then
  211.               Begin
  212.                 returnkey:=editfield(col[colindex],
  213.                                      startrow+rowcount,
  214.                                      fldlength,
  215.                                      decpla,
  216.                                      usndec,
  217.                                      optional,
  218.                                      compmassflow[fldnum]);
  219.                 compmoleflow[fldnum]:=compmassflow[fldnum]/compmolewt[fldnum];
  220.                 success:=True
  221.               End;
  222.             Inc(compnumber);
  223.             Inc(rowcount);
  224.           Until rowcount = maxrow;
  225.           Inc(colindex);
  226.           rowcount:=0;
  227.         Until success;
  228.  
  229.         Case returnkey Of
  230.           enterkey:
  231.               If fldnum < maxfldnum
  232.               Then inc(fldnum)
  233.               Else fldnum:=0;
  234.           uparrowkey:
  235.               fldnum:=nextfldnum[fldnum,up];
  236.           dnarrowkey:
  237.               fldnum:=nextfldnum[fldnum,down];
  238.           tabkey:
  239.               fldnum:=nextfldnum[fldnum,right];
  240.           shiftabkey:
  241.               fldnum:=nextfldnum[fldnum,left];
  242.           esckey:
  243.               If firstpass
  244.               Then beep
  245.               Else fldnum:=0
  246.           Else
  247.         End;
  248.  
  249.       Until fldnum = 0;
  250.  
  251.       totalmassflow:=0;
  252.       totalmoleflow:=0;
  253.       For compnumber:= 1 To maxcompnum Do
  254.         Begin
  255.           totalmassflow:=totalmassflow+compmassflow[compnumber];
  256.           totalmoleflow:=totalmoleflow+compmoleflow[compnumber]
  257.         End;
  258.       If totalmoleflow <> 0 Then
  259.         moleweight:=totalmassflow/totalmoleflow
  260.       Else moleweight:=0;
  261.  
  262.       note('END to Accept, ENTER to Edit, ESC to exit');
  263.       Repeat
  264.         returnkey:=getspecialkey;
  265.         If (returnkey <> endkey) And
  266.            (returnkey <> enterkey) And
  267.            (returnkey <> esckey)
  268.         Then
  269.           errmsg('Must be END (Accept), ENTER (Edit), Or ESC (Exit)')
  270.       Until
  271.            (returnkey = endkey) Or
  272.            (returnkey = enterkey) Or
  273.            (returnkey = esckey);
  274.       If returnkey = enterkey Then
  275.         Begin
  276.           firstpass:=False;
  277.           fldnum:=1
  278.         End;
  279.  
  280.  
  281.     Until
  282.          (returnkey = endkey) Or
  283.          (returnkey = esckey);
  284.     If returnkey = endkey Then
  285.       Begin
  286.         GotoXY(1,startrow+13);
  287.         Write('Total Stream Flow Rate lb/hr =      ',totalmassflow:10:0);
  288.         GotoXY(1,startrow+14);
  289.         Write('Total Stream Flow Rate, lb-moles/hr = ',totalmoleflow:8:1);
  290.         GotoXY(1,startrow+15);
  291.         Write('Total Stream Molecular Weight =        ',moleweight:7:3);
  292.         note('ENTER to Run Another Case, or ESC to Exit');
  293.         While ((returnkey <> enterkey) And (returnkey <> esckey)) Do
  294.           Begin
  295.             returnkey:=getspecialkey;
  296.             If ((returnkey <> enterkey) And (returnkey <> esckey)) Then
  297.               errmsg('Must be ENTER (New Case), or ESC (Exit)')
  298.           End
  299.       End
  300.     Else;
  301.  
  302.   Until returnkey = esckey;
  303.   cursor(underline);
  304.   NormVideo;
  305. End.
  306. 
  307.