I'm trying to do something I guess I have never tried before, and so far, am feeling stupid. What I want to do is pass any of three or four different types of TFields (TIntegerField, TFloadField, and TStringField will be primary) as a parameter in a method call. So far, I have not found a workable declaration for the parameter.

I'm trying to do something I guess I have never tried before, and so far, am feeling stupid. What I want to do is pass any of three or four different types of TFields (TIntegerField, TFloadField, and TStringField will be primary) as a parameter in a method call. So far, I have not found a workable declaration for the parameter. 

I would have thought it a fairly obvious thing to do, but have turned up nothing useful on Google, either.

I did find an example from Marco's Mastering Delphi 7, where I see (Sender: TField). However, when I tried (AField: TField) in my own code, the compiler complained. Perhaps something in XE7 I haven't puzzled out?

Comments

  1. I am not on that machine right now. I will get back to it after my chores are done. ;)

    Yes, it will handle each differently. The usage is in filling cells in a spreadsheet. I could use overloaded methods, but that would merely sidestep the puzzle. I'd like instead to understand it.

    ReplyDelete
  2. TField should definitely work for value parameters. Are you maybe using var ?

    ReplyDelete
  3. It was along day, yesterday. Not sure what happened, but I just went through things again, and now I am able to do just as I wanted.

    ReplyDelete

Post a Comment