home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / tug__002 / flddemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-08-08  |  9.6 KB  |  345 lines

  1. {TUG PDS CERT 1.01 (Pascal)
  2.  
  3. ==========================================================================
  4.  
  5.                   TUG PUBLIC DOMAIN SOFTWARE CERTIFICATION
  6.  
  7. The Turbo User Group (TUG) is recognized by Borland International as the
  8. official support organization for Turbo languages.  This file has been
  9. compiled and verified by the TUG library staff.  We are reasonably certain
  10. that the information contained in this file is public domain material, but
  11. it is also subject to any restrictions applied by its author.
  12.  
  13. This diskette contains PROGRAMS and/or DATA determined to be in the PUBLIC
  14. DOMAIN, provided as a service of TUG for the use of its members.  The
  15. Turbo User Group will not be liable for any damages, including any lost
  16. profits, lost savings or other incidental or consequential damages arising
  17. out of the use of or inability to use the contents, even if TUG has been
  18. advised of the possibility of such damages, or for any claim by any
  19. other party.
  20.  
  21. To the best of our knowledge, the routines in this file compile and function
  22. properly in accordance with the information described below.
  23.  
  24. If you discover an error in this file, we would appreciate it if you would
  25. report it to us.  To report bugs, or to request information on membership
  26. in TUG, please contact us at:
  27.  
  28.              Turbo User Group
  29.              PO Box 1510
  30.              Poulsbo, Washington USA  98370
  31.  
  32. --------------------------------------------------------------------------
  33.                        F i l e    I n f o r m a t i o n
  34.  
  35. * DESCRIPTION
  36. File used with FIELD.PAS.
  37.  
  38. * ASSOCIATED FILES
  39. FIELD.PAS
  40. FLDDEMO.PAS
  41. FLDTEST.PAS
  42. OLDDEMO.PAS
  43. FIELD.TXT
  44.  
  45. * CHECKED BY
  46. DRM 08/08/88
  47.  
  48. * KEYWORDS
  49. TURBO PASCAL V4.0
  50.  
  51. ==========================================================================
  52. }
  53. Program fielddemo;
  54.  
  55. {N+}
  56.  
  57. Uses Crt,Dos,field;
  58.  
  59. Type linestring = String[80];
  60.      namestring = String[16];
  61.      direction  = (up,down,left,right);
  62.      component  = 1..28;
  63.  
  64. Const nextfldnum: Array[component,direction] Of Byte
  65.                   = ((10,2,21,11),
  66.                      (1,3,22,12),
  67.                      (2,4,23,13),
  68.                      (3,5,24,14),
  69.                      (4,6,25,15),
  70.                      (5,7,26,16),
  71.                      (6,8,27,17),
  72.                      (7,9,28,18),
  73.                      (8,10,19,19),
  74.                      (9,1,20,20),
  75.                      (20,12,1,21),
  76.                      (11,13,2,22),
  77.                      (12,14,3,23),
  78.                      (13,15,4,24),
  79.                      (14,16,5,25),
  80.                      (15,17,6,26),
  81.                      (16,18,7,27),
  82.                      (17,19,8,28),
  83.                      (18,20,9,9),
  84.                      (19,11,10,10),
  85.                      (28,22,11,1),
  86.                      (21,23,12,2),
  87.                      (22,24,13,3),
  88.                      (23,25,14,4),
  89.                      (24,26,15,5),
  90.                      (25,27,16,6),
  91.                      (26,28,17,7),
  92.                      (27,21,18,8));
  93.  
  94.       compname: Array[component] Of namestring
  95.                 = ( 'Hydrogen',
  96.                     'Nitrogen',
  97.                     'Oxygen',
  98.                     'Water',
  99.                     'Carbon Monoxide',
  100.                     'Carbon Dioxide',
  101.                     'Hydrogen Sulfide',
  102.                     'Sulfur Dioxide',
  103.                     'Benzene',
  104.                     'Toluene',
  105.                     'Methane',
  106.                     'Ethane',
  107.                     'Propane',
  108.                     'i-Butane',
  109.                     'n-Butane',
  110.                     'Neopentane',
  111.                     'i-Pentane',
  112.                     'n-Pentane',
  113.                     'n-Hexane',
  114.                     'n-Heptane',
  115.                     'Ethylene',
  116.                     'Propylene',
  117.                     'i-Butane',
  118.                     '1-Butene',
  119.                     't-2-Butene',
  120.                     'c-2-Butene',
  121.                     '1-Pentene',
  122.                     '1,3-Butadiene' );
  123.  
  124.       compmolewt: Array[component] Of Real
  125.                  = (  2.016,
  126.                      28.013,
  127.                      31.999,
  128.                      18.015,
  129.                      18.010,
  130.                      44.010,
  131.                      34.076,
  132.                      64.059,
  133.                      78.114,
  134.                      92.141,
  135.                      16.043,
  136.                      30.070,
  137.                      44.097,
  138.                      58.124,
  139.                      58.124,
  140.                      72.151,
  141.                      72.151,
  142.                      72.151,
  143.                      86.178,
  144.                     100.205,
  145.                      28.054,
  146.                      42.081,
  147.                      56.108,
  148.                      56.108,
  149.                      56.108,
  150.                      56.108,
  151.                      70.135,
  152.                      54.092 );
  153.  
  154.       maxcompnum = 28;
  155.  
  156. Var fldnum: Byte;
  157.     maxfldnum: Byte;
  158.     fldlength: Byte;
  159.     decpla: Byte;
  160.     returnkey: Byte;
  161.     startrow: Byte;
  162.     rowcount: Byte;
  163.     compcount: Byte;
  164.     count: Byte;
  165.     compnumber: Byte;
  166.     maxrow: Byte;
  167.  
  168.     col: Array[1..3] Of Byte;
  169.     colindex: Byte;
  170.  
  171.     totalmassflow: Real;
  172.     totalmoleflow: Real;
  173.     moleweight: Real;
  174.  
  175.     text: linestring;
  176.     value: linestring;
  177.  
  178.     success: Boolean;
  179.  
  180.     compmassflow: Array[component] Of Real;
  181.     compmoleflow: Array[component] Of Real;
  182.  
  183.  
  184. Procedure beep;
  185.  
  186. Begin
  187.   Write(chr(7))
  188. End;
  189.  
  190. Begin
  191.   reversevideo:=False;
  192.   zerovoid:=True;
  193.   hitxtcolor:=Yellow;
  194.   lotxtcolor:=LightGray;
  195.   txtbkgnd:=Black;
  196.   cursor(hidden);
  197.   TextMode(CO80);
  198.   TextColor(lotxtcolor);
  199.   TextBackground(txtbkgnd);
  200.  
  201.   Repeat
  202.  
  203.     ClrScr;
  204.     For count:=1 To maxcompnum Do compmassflow[count]:=0;
  205.  
  206.     text:='Refinery Gas Molecular Weight';
  207.     GotoXY(39-(length(text) Div 2),2);
  208.     Write(text);
  209.  
  210.     startrow:=6;
  211.     col[1]:=1;
  212.     col[2]:=31;
  213.     col[3]:=55;
  214.     colindex:=1;
  215.     rowcount:=0;
  216.     compcount:=0;
  217.     maxrow:=10;
  218.  
  219.     Repeat
  220.       Repeat
  221.         GotoXY(col[colindex],startrow+rowcount);
  222.         inc(compcount);
  223.         If compcount <= maxcompnum Then Write(compname[compcount]);
  224.         Inc(rowcount);
  225.       Until rowcount = maxrow;
  226.       Inc(colindex);
  227.       rowcount:=0
  228.     Until compcount >= maxcompnum;
  229.  
  230.     maxfldnum:=maxcompnum;
  231.     fldlength:=7;
  232.     decpla:=0;
  233.     col[1]:=19;
  234.     col[2]:=43;
  235.     col[3]:=70;
  236.     fldnum:=1;
  237.     firstpass:=True;
  238.  
  239.     Repeat
  240.  
  241.       Repeat
  242.         rowcount:=0;
  243.         compnumber:=1;
  244.         colindex:=1;
  245.         success:=False;
  246.  
  247.         Repeat
  248.           Repeat
  249.             If compnumber = fldnum Then
  250.               Begin
  251.                 returnkey:=editfield(col[colindex],
  252.                                      startrow+rowcount,
  253.                                      fldlength,
  254.                                      decpla,
  255.                                      usndec,
  256.                                      optional,
  257.                                      compmassflow[fldnum]);
  258.                 compmoleflow[fldnum]:=compmassflow[fldnum]/compmolewt[fldnum];
  259.                 success:=True
  260.               End;
  261.             Inc(compnumber);
  262.             Inc(rowcount);
  263.           Until rowcount = maxrow;
  264.           Inc(colindex);
  265.           rowcount:=0;
  266.         Until success;
  267.  
  268.         Case returnkey Of
  269.           enterkey:
  270.               If fldnum < maxfldnum
  271.               Then inc(fldnum)
  272.               Else fldnum:=0;
  273.           uparrowkey:
  274.               fldnum:=nextfldnum[fldnum,up];
  275.           dnarrowkey:
  276.               fldnum:=nextfldnum[fldnum,down];
  277.           tabkey:
  278.               fldnum:=nextfldnum[fldnum,right];
  279.           shiftabkey:
  280.               fldnum:=nextfldnum[fldnum,left];
  281.           esckey:
  282.               If firstpass
  283.               Then beep
  284.               Else fldnum:=0
  285.           Else
  286.         End;
  287.  
  288.       Until fldnum = 0;
  289.  
  290.       totalmassflow:=0;
  291.       totalmoleflow:=0;
  292.       For compnumber:= 1 To maxcompnum Do
  293.         Begin
  294.           totalmassflow:=totalmassflow+compmassflow[compnumber];
  295.           totalmoleflow:=totalmoleflow+compmoleflow[compnumber]
  296.         End;
  297.       If totalmoleflow <> 0 Then
  298.         moleweight:=totalmassflow/totalmoleflow
  299.       Else moleweight:=0;
  300.  
  301.       note('END to Accept, ENTER to Edit, ESC to exit');
  302.       Repeat
  303.         returnkey:=getspecialkey;
  304.         If (returnkey <> endkey) And
  305.            (returnkey <> enterkey) And
  306.            (returnkey <> esckey)
  307.         Then
  308.           errmsg('Must be END (Accept), ENTER (Edit), Or ESC (Exit)')
  309.       Until
  310.            (returnkey = endkey) Or
  311.            (returnkey = enterkey) Or
  312.            (returnkey = esckey);
  313.       If returnkey = enterkey Then
  314.         Begin
  315.           firstpass:=False;
  316.           fldnum:=1
  317.         End;
  318.  
  319.  
  320.     Until
  321.          (returnkey = endkey) Or
  322.          (returnkey = esckey);
  323.     If returnkey = endkey Then
  324.       Begin
  325.         GotoXY(1,startrow+13);
  326.         Write('Total Stream Flow Rate lb/hr =      ',totalmassflow:10:0);
  327.         GotoXY(1,startrow+14);
  328.         Write('Total Stream Flow Rate, lb-moles/hr = ',totalmoleflow:8:1);
  329.         GotoXY(1,startrow+15);
  330.         Write('Total Stream Molecular Weight =        ',moleweight:7:3);
  331.         note('ENTER to Run Another Case, or ESC to Exit');
  332.         While ((returnkey <> enterkey) And (returnkey <> esckey)) Do
  333.           Begin
  334.             returnkey:=getspecialkey;
  335.             If ((returnkey <> enterkey) And (returnkey <> esckey)) Then
  336.               errmsg('Must be ENTER (New Case), or ESC (Exit)')
  337.           End
  338.       End
  339.     Else;
  340.  
  341.   Until returnkey = esckey;
  342.   cursor(underline);
  343.   NormVideo;
  344. End.
  345.