When we make anonymous methods in our project, there's a bug that makes it impossible for the compiler to find System.SysUtils.StrToFloat, even when we namespace it with the System.SysUtils prefix.

When we make anonymous methods in our project, there's a bug that makes it impossible for the compiler to find System.SysUtils.StrToFloat, even when we namespace it with the System.SysUtils prefix.

It complains that it can't find a version of StrToFloat with the given input, even when passing it string literals.

When I start an empty project and do the same, the error does not occur.

Does anyone have any idea why this happens?

Comments

  1. No, but what if you try the function version? StrToFloat(arg)? Generally the older syntax is more efficient.

    ReplyDelete
  2. Start with a blank project, then add piece by piece the existing units and functionality. That usually fixes things like this.

    ReplyDelete
  3. Kasper Brohus Allerslev There are all sorts of bugs in the project management of many Delphi versions. Give it a try and let us know if it fixes your problem.

    ReplyDelete
  4. Generally you'd show the code rather than describe it. If you showed code to reproduce, then you'd get better help.

    ReplyDelete
  5. I know, but the code is strictly confidential, and I'm not taking any chances.

    ReplyDelete
  6. Strip down the unit code to a bare minimum while still being able to reproduce the anomaly.

    ReplyDelete
  7. I'll give it a shot, as soon as time allows for it.

    Is it possible that the error lies in an imported unit?

    ReplyDelete
  8. There's a big lesson in debugging for you here. I hope you take it. Create a minimal reproduction. Do so and you'll discover your mistake. Because the error is in your code. But the act of making the reproduction will reveal the error.

    Thinking that people can diagnose your problem without you presenting the problem is a sign of a lack of appreciation of how coding works. It's all about detail.

    ReplyDelete
  9. Make a new unit, declare a function MyStrToFloat with identical parameters and result, and initially have it return empty string. If that works, have it call System.SysUtils.StrToFloat. Should narrow it down a bit.

    ReplyDelete
  10. You also have the following available on XE6 to XE8,  string.ToSingle(stringval) or string.ToDouble() or string.ToExtended().

    ReplyDelete
  11. +Steve The question is about why a function in SysUtils apparently cannot be called. There will be an explanation. Randomly trying other functions is a cop out. Wouldn't you want to understand?

    ReplyDelete
  12. David, would like to understand the cause of this, would have been easier if some sort of example source was provided though.

    ReplyDelete
  13. Steve van Niekerk  Of course. It's really a waste of time guessing. All the asker had to do was make a simple MCVE.

    ReplyDelete

Post a Comment