0

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.

3
  • Does the error also show when you assign od_cap := '2'? Is this assignment the first assignment in a method or your classes? Commented Oct 13, 2011 at 9:34
  • How are you creating the TOpenDialog? Are you dropping it on the form as a component, or creating it in code? Commented Oct 13, 2011 at 11:00
  • Voted to close. Asker thinks the question has to do with integer-to-string conversion, but it clearly doesn't. Asker appears to have deleted his or her account, so there's no chance of getting further information to clarify the question. Commented Oct 13, 2011 at 16:12

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.