obj := new testClass();
obj.test();
type testClass=class()
{$IFDEF LINUX}
const krnl="libTSLkrnl.so";
{$ELSE}
const krnl="tslkrnl.dll";
{$ENDIF}
function test()
begin
t := TSstrtofloat("1.23");
echo datatype(t),"\r\n";
echo t,"\r\n";
end
Function TSstrtofloat(s:string):double;external krnl name "TS_strtofloat";
end
Linux结果:
Windows结果:
范例二:使用常量计算结果指定动态库名称
obj := new testClass();
obj.test();
type testClass=class()
const krnl="tslkrnl";
const ext="dll";
function test()
begin
t := TSstrtofloat("1.23");
echo datatype(t),"\r\n";
echo t,"\r\n";
end
Function TSstrtofloat(s:string):double;external krnl$"."$ext name "TS_strtofloat";
end