![]() |
Dienst/Service bleibt hängen bei StrToFloat()
Ich habe einen kleinen Dienst geschrieben der eine Datei einliest und diese soll dann später mit einer Datenbank abgeglichen werden.
Jedoch gibt es ein Problem wenn ich die Funktion StrToFloat() verwende dann bleibt der Dienst hängen.
Delphi-Quellcode:
Konvertiere ich in der folgenden Prozedur 2 Stings nach Real mit der Funktion 'StrToFloat' so ergibt die Logdatei das der Dienst hängen bleibt.
procedure TService1.Execute;
begin while NOT Terminated do begin //Log=> 'starte update' pLoad_File(db_File); //... Update routinen //Log=> 'beende update' end; end; Zitat:
Zitat:
Delphi-Quellcode:
Procedure pLoad_File(Var db_File tDbFile);
Var FHandle : System.Text; Index : Integer; strRow : String; strID : String; strName : String; strType : String; strSupplier : String; strPrice : String; strPriceDiv : String; Begin //init db_File := nil; Index := 0; //Länge setzen SetLength(db_File, 32768); //Einlesen der Artikelinformationen Assign(FHandle, FilePath); {$I-} Reset(FHandle); {$I+} If IoResult = 0 Then Begin While NOT EOF(FHandle) Do Begin Readln(FHandle,strRow); strID := Copy(strRow,64,6); strName := Copy(strRow,1,25); strType := Copy(strRow,27,15); strSupplier := Copy(strRow,43,3); strPrice := Copy(strRow,76,7); strPriceDiv := Copy(strRow,136,4); db_File[Index].ID := fDeleteChar(' ',fAsciiToAnsi(strID)); db_File[Index].Name := fAsciiToAnsi(strName); db_File[Index].Typ := fAsciiToAnsi(strType); db_File[Index].Supplier := fAsciiToAnsi(strSupplier); db_File[Index].Price := 0; db_File[Index].PriceDiv := 1; //Preis If (Length(strPrice) > 0) AND fCheckChars(strPrice,'0123456789.') Then db_File[Index].Price := StrToFloat(strPrice) Else db_File[Index].Price := 0.0; //Preisdivisor If {(Length(strPriceDiv) > 0) AND} fCheckChars(strPriceDiv,'0123456789.') Then db_File[Index].PriceDiv := StrToFloat(strPriceDiv) Else db_File[Index].PriceDiv := 1; Inc(Index); End;{while} Close(FHandle); End;{if IoResult} //Array auf korrekte Länge abschneiden SetLength(db_File, Index); End; |
Re: Dienst/Service bleibt hängen bei StrToFloat()
TryStrToFloat ist StrToFloat immer vorzuziehen
|
Re: Dienst/Service bleibt hängen bei StrToFloat()
StrToFloat schmeißt vermutlich eine Exception die du nicht behandelst.
|
Re: Dienst/Service bleibt hängen bei StrToFloat()
Zitat:
![]() |
Re: Dienst/Service bleibt hängen bei StrToFloat()
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:35 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz