[Fortran] 纯文本查看 复制代码 type Tvar=function(a:integer;b:array of real):real;stdcall; procedure TForm1.Button1Click(Sender: TObject); var shuzu:TFarProc; onehandle:THandle; myf:Tvar; sz:array of Real; i:Integer; begin SetLength(sz,StrToInt(Edit2.Text)); for I := Low(sz) to High(sz) do begin sz[i]:=Random(100); Memo1.Lines.Add(FloatToStr(sz[i])); end; onehandle:=LoadLibrary('D:\TestDll.dll'); try if onehandle <> 0 then begin shuzu:=GetProcAddress(onehandle,'Sortandfindmax'); end; if shuzu <> nil then begin myf:=tvar(shuzu); Edit1.Text:=FloatToStr(myf(Length(sz),sz)); for I := Low(sz) to High(sz) do Memo2.Lines.Add(FloatToStr(sz[i])); end; finally FreeLibrary(onehandle); end; end; 或 [Fortran] 纯文本查看 复制代码 FUNCTION SORTANDFINDMAX(LENGTH,ARRAY) !------------------------------如果将变量的顺序调换为 ARRAY,LENGTH,那么就出现传输数组时数组长度少一位 !DEC$ ATTRIBUTES DLLEXPORT::SORTANDFINDMAX !DEC$ ATTRIBUTES STDCALL,ALIAS:'Sortandfindmax'::SORTANDFINDMAX DOUBLE PRECISION ::ARRAY(LENGTH) INTEGER::I,J DOUBLE PRECISION::SORTANDFINDMAX,TEMP SORTANDFINDMAX=ARRAY(1) DO I=1,LENGTH-1 DO J=I+1,LENGTH IF(ARRAY(I).GT.ARRAY(J)) THEN TEMP=ARRAY(I) ARRAY(I)=ARRAY(J) ARRAY(J)=TEMP 不讨论算法效率 SORTANDFINDMAX=ARRAY(J) END IF END DO END DO END 都没有,编译器凭啥认定length就是整数?! |
我手上没有 Delphi,你能不能把 数组在前,数组在后,分别编译成2个exe,然后压缩以后传上来? |
捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )
GMT+8, 2024-11-24 01:59