Autor Beitrag
JeanvanHees
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Mi 18.02.04 13:30 
Tag Leute, :wink2:

bei Inttostr bekomme ich einen econvert error.
Ich denke das das nur passiert wenn der inhalt des LongWords nicht in einen integer passt.
Gibt es da etwas besseres?

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
teebee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 109


D6 Prof
BeitragVerfasst: Mi 18.02.04 13:43 
JeanvanHees hat folgendes geschrieben:
bei Inttostr bekomme ich einen econvert error.
Was machst Du, um das auszulösen??
JeanvanHees hat folgendes geschrieben:
Ich denke das das nur passiert wenn der inhalt des LongWords nicht in einen integer passt.
Das kapier ich nicht...
Vielleicht postest Du mal etwas Code,

Gruß, teebee
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Mi 18.02.04 14:56 
naja erst hatte ich das hier:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
function CombineFourValues(Segment,Page,StartPoint: integer): LongWord;
begin
result:=(FileArray[Segment,Page,StartPoint].DecData) + (FileArray[Segment,Page,StartPoint+1].DecData * 256) + (FileArray[Segment,Page,StartPoint+2].DecData * 65536) + (FileArray[Segment,Page,StartPoint+3].DecData * 256 * 65536);
end;


da bekam ich negative werte raus manchmal

Jetzt hab ich das hier

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
function CombineFourValues(Segment,Page,StartPoint: integer): LongWord;
var
b1, b2, b3, b4: Byte;
begin
b1:= FileArray[Segment,Page,StartPoint].DecData;
b2:= FileArray[Segment,Page,StartPoint+1].DecData;
b3:= FileArray[Segment,Page,StartPoint+2].DecData;
b4:= FileArray[Segment,Page,StartPoint+3].DecData;
result := dword(b1) or (dword(b2) shl 8or (dword(b3) shl 16or (dword(b4) shl 24);


Da hatte ich das problem von einen Econvert error wenn ich den retournierten wert nach einen string umwandle mit InttoStr.

Da hab ich das hier gemacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
CombStr = record
    case Integer of
      0: (Aslongword: longword);
      1: (AsString: array[0..3of Char);
    end;

var
   csStrLong     : CombStr;


und zum beispiel es so benutzt>>>
ausblenden Delphi-Quelltext
1:
2:
csStrLong.Aslongword :=CombineFourValues (Segm,Pag,OffPag+00);
        Edit159.Text:=csStrLong.AsString;


aber krieg ich wieder einen error
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
         csStrLong.Aslongword := CombineFourValues(2,226,OffsetInPage);
          Cells[i,j] := csStrLong.AsString;
          csStrLong.Aslongword := StrToInt(Cells[i,18])+csStrLong.Aslongword;
          Cells[i,18] := csStrLong.AsString;
          OffsetInPage:=OffsetInPage+8;



Entschuldige für den haufen code....aber ich weis nicht wie ich mich anders ausdrücken soll.
Ich weiss total nicht mehr weiter.... :cry:


Moderiert von user profile icontommie-lie: Code- durch Delphi-Tags ersetzt (*uff*)

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 18.02.04 15:04 
Hi!

Hast Du mal per Debugger nachgesehen, welcher Wert vor der Konvertierung in dem String steht?
(auszuwertenden Ausdruck markieren und Strg + F7 drücken, falls Du das nicht weißt)

MfG,
S.J.
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Mi 18.02.04 15:08 
naja, die error message sagt: "-^Ü' is not a valid integer value...und die message bekomme ich nach diese instruktion:
ausblenden Quelltext
1:
csStrLong.Aslongword := StrToInt(Cells[i,18])+csStrLong.Aslongword;					

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
Chatfix
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mi 18.02.04 15:19 
@JeanvanHees vielleicht kannst du mal in zukunft den Button "Delphi" und nicht "Code" nutzen.
Dann formatiert das DF Deine Beiträge etwas übersichtlicher (Syntax-HighLighting).

Danke

Zum Problem:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  StrVar: String;
  LwVar: Longword;

StrVar := String(LwVar);

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Mi 18.02.04 15:43 
@ ChatFix: entschuldigung... :D

Ich habe jedoch dein vorschlag probiert aber ich bekomme wieder ein error nach diese instruction:
ausblenden Delphi-Quelltext
1:
Cells[i,j] := String(CombineFourValues(2,226,OffsetInPage));					


Ich bekomme einen acces violation error in module 'rtl60.bpl'
Aber ich weiss nicht ob das ein standard bpl ist..

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 18.02.04 15:57 
Speichere das Projekt und starte Delphi mal neu.

BTW gibt es von IntToStr eine überladenen Version:
ausblenden Delphi-Quelltext
1:
2:
function IntToStr(Value: Integer): stringoverload;
function IntToStr(Value: Int64): stringoverload;

Zweitere sollte auch mit LongWords zurecht kommen, da ein LongWord nicht größer wie ein Int64. Genau genommen ist ein LongWord ein unsigned Int-32-Bit, also doppelt so groß wie ein Integer im positiven Wertebereich und zwar immer, unabhängig davon wie ein Integer auf der aktuellen CPU implementiert ist.
Chatfix
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mi 18.02.04 15:59 
Funktioniert denn das überhaupt?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  LwVar: LongWord;

LwVar := CombineFourValues(2,226,OffsetInPage);


Wenn nein dann liegt der Fehler nicht an der TypUmwandlung.

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Mi 18.02.04 16:29 
@ Lucky: ok, aber gibt es den kein problem weil ein integer signed ist?
Longword ist einen cardinal.
Ich habe neugestart und ich habe dasselbe problem.

@ChatFix: Ich hab die procedur wo das problem auftritt isoliert...es liegt absolut an die instruction...in andere proceduren functioniert Combinefourvalues gut

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Do 19.02.04 10:09 
ich habe es jetzt :

ausblenden Delphi-Quelltext
1:
Cells[i,j] := InttoStr(int64(CombineFourValues(2,226,OffsetInPage)));					


so funktioniert die instruction...
jetzt habe ich jedoch in dieselbe procedur mit diese zeile:
ausblenden Delphi-Quelltext
1:
TotalPercentage:=int64(int64(StrToInt64(Cells[01,18]) + StrToInt64(Cells[02,18])) + int64(StrToInt64(Cells[03,18]) + StrToInt64(Cells[04,18])))					


Wie ihr sieht 'typecaste' ich bei jede berechnung...aber das hat mich auch nicht weiter geholfen erst hatte ich das hier
ausblenden Delphi-Quelltext
1:
TotalPercentage:=StrToInt(Cells[01,18]) + StrToInt(Cells[02,18])) + StrToInt(Cells[03,18]) + StrToInt(Cells[04,18]);					

und eigentlich hätte ich erwartet das er nachdem ich von den StrToInt, StrToInt64 mache funktionieren würde.

Ich bekomme wieder den error also das einen bestimmten wert kein valid integer value ist :(

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Do 19.02.04 12:59 
Ok, ich habe es entlich alles gut am functionieren :D

Leute, wenn ihr sowie mich mehr als 3 bytes in hex format zusammen fügen möchtet mach es sowie hier>>

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
function CombineFourValues(Segment,Page,StartPoint: integer): String;
var
TempString:String;
begin
SetLength(TempString,5);
SetLength(result,10);
result[1] := '0';
result[2] := 'x';
TempString:= FileArray[Segment,Page,StartPoint].HexData;
result[3] := TempString[3];
result[4] := TempString[4];
TempString:= FileArray[Segment,Page,StartPoint+1].HexData;
result[5] := TempString[3];
result[6] := TempString[4];
TempString:= FileArray[Segment,Page,StartPoint+2].HexData;
result[7] := TempString[3];
result[8] := TempString[4];
TempString:= FileArray[Segment,Page,StartPoint+3].HexData;
result[9] := TempString[3];
result[10] := TempString[4];


Wenn ihr dann in eine function den decimalen wert haben wollt:
ausblenden Delphi-Quelltext
1:
StrToInt64(CombineFourValues(Seg,Pag,OffsetInPage))					

oder den string>>>
ausblenden Delphi-Quelltext
1:
IntToStr(StrToInt64(CombineFourValues(Seg,Pag,OffsetInPage)))					


Ich hoffe das mein problem andere leute weiterhilft :D

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!