home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / MATH / VISSIM.ZIP / TESTPDLL.PAS < prev    next >
Pascal/Delphi Source File  |  1994-02-09  |  2KB  |  83 lines

  1. {************************************************}
  2. {                                                }
  3. {   Borland Turbo Pascal                         }
  4. {   VisSim DLL function example for Windows      }
  5. {   Demo Dynamic Link Library                    }
  6. {************************************************}
  7.  
  8. library testpdll;
  9.  
  10. uses WinTypes,WinProcs;
  11.  
  12. procedure getSimTime(var simTime); external 'VisSim';  {* VisSim function *}
  13.  
  14. type
  15. Arraytype1 = array [0..5] of Double;
  16. Arraytype2 = array [0..10] of Double;
  17.  
  18. procedure minmax( var param, inV:Arraytype1; var outV:Arraytype2); export;
  19.  
  20.    { The user function referenced in the VisSim user function block  }
  21.  
  22.  var 
  23.  simTime,min,max,sum,avg :double;
  24.  i:integer;
  25.  
  26.  begin
  27.      
  28.     getSimTime(simTime);   {* simulation time*}
  29.     outV[0]:= simTime;  
  30.  
  31.     min:=inV[0];
  32.     max:=inv[0];
  33.     sum:=inV[0];
  34.     avg:=0;
  35.  
  36.     for i:=1 to 3 do
  37.      begin
  38.        if (inV[i] <= min) then
  39.          min:=inV[i];
  40.        if (inV[i] >= max) then
  41.          max:=inV[i];
  42.        sum:=sum+inV[i];
  43.      end;
  44.   
  45.  
  46.     avg:=sum/4;
  47.     outV[1]:=max;
  48.     outV[2]:=min;
  49.     outV[3]:=avg;
  50.     outV[4]:=param[0]-param[1];
  51.  
  52.  end;
  53.  
  54. function minmaxPA( var pcount:integer):Longint; export;
  55. {Parameter Allocation Function}
  56.  begin
  57.    pCount:=2;   { * number of prompted parametrs *}
  58.    minmaxPA:=sizeof(Double)*pCount;
  59.  end;
  60.   
  61. procedure minmaxPI( var param:Arraytype1); export;
  62. {Parameter Initialization Function}
  63.   begin
  64.     param[0]:=1;  { * parameters *} 
  65.     param[1]:=3;
  66.   end;
  67.  
  68. function minmaxPC( var param:Arraytype1):Pchar; export;
  69. {Parameter Change function }
  70. begin
  71.  minmaxPC:='Upper;Lower';
  72. end;
  73.  
  74. exports
  75. { needed for building a DLL}
  76.   minmax    index 1,
  77.   minmaxPI  index 4,
  78.   minmaxPA  index 5,
  79.   minmaxPC  index 6;
  80.  
  81. begin
  82. end.
  83.