function GetSubStr(var aString:String;
SepChar: String):String;stdcall;
var
MyStr: string;
SepCharPos: integer;
begin
SepCharPos:= Pos(Sepchar, aString);
MyStr:= Copy(aString, 1, SepCharpos-1);
Delete(aString, 1, SepCharPos);
GetSubStr:= MyStr;
end;
function GetSubStrNum(aString: string;
SepChar: string): integer;stdcall;
var
i: integer;
StrLen: integer;
Num: integer;
begin
StrLen:= Length(aString);
Num:= 0;
for i:=1 to StrLendo
if copy(aString, i, 1)= SepChar then
Num:= Num + 1;
GetSubStrNum:= Num;
end;
Function UpLoadData(A:THandle;sSN,sGROUP,sERFlag,sEMP
char)
char;stdcall;
var
DataModule2: TDataModule1;
sSECTION, sMO, sMODEL, sLINE ,iMODATE, iWorkSection : string;
dtUpdateTime : TDateTime;
j: integer;
MyLine, sResult: string;
F : textfile;
begin
sResult:= '';
try
DataModule2:=TDataModule1.Create(nil);
try
if FileExists('c:/ATS.txt') then
begin
AssignFile(F, 'c:/ATS.txt');
try
Reset(F);
while not eof(F)do
begin
Readln(F, MyLine);
with DataModule2.cds_InsUNhrTestItemdo
begin
close;
for j:=1 to GetSubStrNum( MyLine, ',')do
params[j-1].AsString:= trim(GetSubStr(MyLine, ','));
execute;
end;
end;
CloseFile(F);
DeleteFile('c:/ATS.txt');
except
sResult:='Other Error';
end;
result:=AllocMem(Length(sResult)+1);
sResult:=sResult+#0;
StrCopy(Result,Pchar(trim(sResult)));
end else
Result:= pchar('No ATS File');
finally
DataModule2.Free;
end;
except
Result:=pchar('Other Error');
end;
end;
以上大家帮看看