SRL Archive - Research & Development Lounge

Need help with strings


Shatterhand

2012-02-20 10:19:16

Hey everyone. I have a problem with strings:

text, levelString: String;

levelString:= 'Str';
text:= levelString+' XP/H: '+IntToStr(XPHour);

I get this error: Type mismatch at line X.
The problem is with levelString. XPHour is integer.
How can I concatenate them?

Thanks in advance,
hunt3rx3

Shatterhand

2012-02-20 15:14:54

Anyone? :)

x[Warrior]x3500

2012-02-20 15:20:53

wat variable type XPhour?

Shatterhand

2012-02-20 15:28:04

From: x[Warrior]x3500
wat variable type XPhour?

Its integer. The problem is with levelString. Sorry I edited post. :)

Nebula

2012-02-20 15:49:24

Use IntToStr()

or

ToStr()

Shatterhand

2012-02-20 16:21:25

From: Nebula
Use IntToStr()

or

ToStr()

The problem is with levelString. ToStr(levelString) wont work either.

Rezozo

2012-02-20 16:32:47

levelString: String;

Put that under variable again.

var
levelString: String;
text: text;
XPHour: integer;

Kyle Undefined

2012-02-20 16:36:18

This compiles fine, the error must be somewhere else.

program new;

var
text, levelString : string;
XPHour : Integer;

begin
levelString:= 'Str';
text:= levelString+' XP/H: '+IntToStr(XPHour);
end.

Shatterhand

2012-02-20 16:44:43

From: Kyle Undefined
This compiles fine, the error must be somewhere else.

program new;

var
text, levelString : string;
XPHour : Integer;

begin
levelString:= 'Str';
text:= levelString+' XP/H: '+IntToStr(XPHour);
end.

You are right. The problem was: XPHour was Extended, but rounded. I thought if its rounded, then its like Integer…
Changed IntToStr to FloatToStr.
Thanks anyway. :)

Rezozo

2012-02-20 17:12:57

From: hunt3rx3
You are right. The problem was: XPHour was Extended, but rounded. Changed IntToStr to FloatToStr.
Thanks anyway. :)


Lol you kept saying LevelString had the problem. Was beating my self the last 20 mins for the answer! ;)

Anyway, thanks kyle for helping him anyway.