0

I know this is a bit messed up (the code), but, I'm baffled why it isn't working. I know I'm not great at delphi, and I'd really like some help.

var
  Form1: TForm1;
  SteamString : String;
  CommunityString : String;
  ZeroOrOne : String;
  SteamId : String;
  CommunityStringMath : Longint;
  Calc : Integer;
  Number : Longint;

implementation

{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);
begin
SteamString := EditSteam.Text;
ZeroOrOne := Copy(SteamString,3,1);
SteamId := Copy(SteamString,5,9);
Calc := (StrToInt(SteamId))*2;
Number := 76561197960265728;
CommunityStringMath := ((StrToInt(ZeroOrOne)) + (Calc));

CommunityString := (IntToStr(CommunityStringMath+Number));
Label1.Caption := CommunityString;
end;

end.

When SteamString is 0:1:148547, the CommunityString just ends up as double 148547+1. The code never seems to add the 'Number' to it like I want. I thought maybe it was because integers couldn't handle this big number so I made them long ints and still no luck!

Please help. Probably something stupid.

~Sparkles

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by tylcoatc
0

This works in Delphi 5 on XP, so it should work for you:

var
  SteamString : String;
  CommunityString : String;
  ZeroOrOne : String;
  SteamId : String;
  CommunityStringMath : Int64;
  Calc : Integer;
  Number : Int64;
begin
  SteamString := EditSteam.Text;
  ZeroOrOne := Copy(SteamString,3,1);
  SteamId := Copy(SteamString,5,9);
  Calc := (StrToInt(SteamId))*2;
  Number := 76561197960265728;
  CommunityStringMath := ((StrToInt(ZeroOrOne)) + (Calc));

  CommunityString := (IntToStr(CommunityStringMath+Number));
  Label1.Caption := CommunityString;
end;
1

The most important thing, to my mind in Protaeas's answer is using Int64. You MUST look at the limits of each numeric type. Even LongInt only goes to 10 digits and your Number is 17 digits.
I think you should follow that Delphi Help study route on Integer types and mark this as answered/solved.

Votes + Comments
Good point which I failed to mention.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.