user993111
user993111

Reputation:

An error with integer to string conversion

I am programming in Delphi 7 on Windows XP. This part of the program is defining a caption for the opendialog and I have a really strange problem.

The code with the error is as below

od_cap := 'Select data set ' + intToStr(n_data_sets);

where od_cap is a string and n_data_sets is an integer. The error that arises is EAccessViolation at address 0040459a... I have narrowed the problem down to being caused by the inttostr conversion because it still crashes when I have od_cap := inttostr(2). The more strange thing is that first time it computes this line, it works but then crashes the 2nd time round every time.

I cannot think of any reason why this might be and I am not experienced enough to know any bugs that might cause this. I think this is all the information you should need but feel free to ask for more.

Upvotes: 0

Views: 395

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 595792

IntToStr() does not raise an AV during conversion. What is more likely happening is the od_cap variable is not a valid String variable, such as if it is a member of an object that has been freed, so an AV occurs when it is assigned to.

Upvotes: 1

Related Questions