Recent

Author Topic: [SOLVED] Using temp variable to point to form object  (Read 2813 times)

wpflum

  • Sr. Member
  • ****
  • Posts: 276
[SOLVED] Using temp variable to point to form object
« on: March 23, 2012, 03:02:26 pm »
Is there a way to set a temp variable to point to a form object?  I'd like to use a couple of temp variables in a function  based on the TObject sent into the function.  Basically if the incoming TObject is a TMaskEdit called  TIn0 then I want to set variable TimeIn to TIn0 and another variable TimeOut to TOut0 which is TIn0s partner on the form so I can use these in the validation routine instead of a findcomponent each time I want to use the TOut0 object, setting them both to temps will just make the code look cleaner.

I've tried to declare the object and then just use' temp := IncommingObject' but I'm getting a crash in the TObjects code when the Variable is used somewhere.

I guess I'm missing something simple, like how a reference is made  :-[

Ideas?? 
« Last Edit: March 23, 2012, 04:09:52 pm by wpflum »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Using temp variable to point to form object
« Reply #1 on: March 23, 2012, 03:16:03 pm »
Post your full function code so we can suggest improvements.
Do you test for (temp = nil) at all?

wpflum

  • Sr. Member
  • ****
  • Posts: 276
SOLVED Using temp variable to point to form object
« Reply #2 on: March 23, 2012, 04:08:12 pm »
NOTE TO SELF, Next time CLEAN UP CODE *B*E*F*O*R*E* asking dumb question.  >:(

When I went to 'clean up' the code to post it I realized that I wasn't generating the right name for the other TMaskEdit object so the program didn't find it with FindComponent and consequently the TMaskedit variable was empty thus throwing off everything.

It's funny though, this morning in the shower I got to wondering if the way I was setting the temp variable to the TMaskEdit was wrong which was leaving it empty giving me the error.  I was half right but it wasn't the way I was setting it by using  :=  just the way I found the TMaskEdit object I was setting it with  :-[

I have got to start charging my shower time 'programming' to the company.  :D







 

TinyPortal © 2005-2018