Link to home
Start Free TrialLog in
Avatar of SSSIAN
SSSIANFlag for United Kingdom of Great Britain and Northern Ireland

asked on

manipulating components

Hi
I am managing old Delphi 7 code
I have a form with many TEdit
I use the following code to clear values on my form
My problem is I cannot figure out how to stop certain values from clearing
Example
Edit1.text =’Main Information’
Edit2.text =’General Information’
Edit3.text =’General Information’
Edit4.text =’General Information’

When I use the my following procedure
I need to stop Edit1.text =’Main Information’ from clearing

procedure TForm1.Clear_values
var
j : Integer;
begin
for j := 0 to ComponentCount-1 do
begin
for j := 0 to ComponentCount-1 do
begin

if TEdit(Components[j]).Parent.Name = 'edit2' then showmessage('TEST');

   if (Components[j] is TEdit) then
     (Components[j] as TEdit).Text := '';
   if (Components[j] is Tcheckbox) then
     (Components[j] as Tcheckbox).checked := false;
   if (Components[j] is TRadioButton) then
     (Components[j] as TRadioButton).checked := false;
    if (Components[j] is TComboBox) then
     (Components[j] as TComboBox).Itemindex := -1;
    if (Components[j] is Tmemo) then
     (Components[j] as Tmemo).text := '';
end;

Thank you
ASKER CERTIFIED SOLUTION
Avatar of aflarin
aflarin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aflarin
aflarin

or

procedure TForm1.Clear_values
var
  j : Integer;
begin
  for j := 0 to ComponentCount-1 do
  begin
    for j := 0 to ComponentCount-1 do
    begin

     if (Components[j] is TEdit) then
       if Components[i] <> Edit1 then
         (Components[j] as TEdit).Text := ''
       else
          Edit1.Text:= ’Main Information’;
     if (Components[j] is Tcheckbox) then
       (Components[j] as Tcheckbox).checked := false;
     if (Components[j] is TRadioButton) then
       (Components[j] as TRadioButton).checked := false;
     if (Components[j] is TComboBox) then
       (Components[j] as TComboBox).Itemindex := -1;
     if (Components[j] is Tmemo) then
       (Components[j] as Tmemo).text := '';
end;
Avatar of Geert G
one thing that strikes me as very odd ...
the dubble loop with the same j variable ???

why twice ?
Avatar of SSSIAN

ASKER

SORRY ALL

this is typing error
i was in in rush

the code should be someting
 am managing old Delphi 7 code
I have a form with many TEdit
I use the following code to clear values on my form
My problem is I cannot figure out how to stop certain values from clearing
Example
Edit1.text =’Main Information’
Edit2.text =’General Information’
Edit3.text =’General Information’
Edit4.text =’General Information’
When I use the my following procedure
I need to stop Edit1.text =’Main Information’ from clearing

procedure TForm1.Clear_values
var
j : Integer;
begin
for j := 0 to ComponentCount-1 do
// I need some if edit1.text then do not clear
   if (Components[j] is TEdit) then
     (Components[j] as TEdit).Text := '';
    if (Components[j] is Tmemo) then
     (Components[j] as Tmemo).text := '';
end;





Avatar of SSSIAN

ASKER

Thank you for very quick response from all
As a passing comment, please tell me that you are not actually using components on your form with names like Edit1, Edit2, and Edit3 but are, instead, providing meaningfull names for each of them. ;-)
that's not all that bad
as long as they can remember what Edit34 is for on Form234 out of 654 forms

but don't ever ask me to come and personally help to debug
because i've had that nightmare in once place, and they are never ever seeing me back again !


Geert,
I didn't know you ever worked in Memphis, TN, but you must have because I ran into that sort of nameing convention in several places there . . . none of which would I return to and all of which I raised my rates after seeing the code and before finalizing the contracts.  (I thought it was only a couple of spots in the code each time but figured out later that it was pervasive.)
Avatar of SSSIAN

ASKER

Hi 9080 driver
This was just example, I try and use meaningfull names for
SSSIAN,
Thank you . . . I will sleep easier tonight just knowing that there are more people out there with good sense. ;-)
>>8080_Diver
grrr, i don't do that.
I said I had a problem with debugging that.

After the umpteenth question
What was Edit34 for again ?
I forgot after you told me what Edit23, Edit26, Combobox45, Combobox45_2 and Edit45beta was for
I think I mixed it up with Edit43 ...
Was that for the first name or the last name of the vendor ?
What was Combobox45_2 again ?

Ow, can I ask a silly question ?
I don't completely follow why you use underscore 2, or underscore 3 in your code,
and then later you seem to use beta and gamma.
Not that it's any of my business but that's rather frustrating ...
It's a lot simpler just using the names given by Delphi ?

Ah no, we just had a new recruit and we told him to come up with a better naming convention.
What do you think about it ? I think it's rather good ...

Me: Ow god, what have I gotten myself into now ... Where is the beer ?







Geert,
Where is the beer ?

I actually billed a client (one that had the rate raised per above ;-) for the after work brews one time . . . it was covered under the consultant will be reimbursed for all misc expenses clause. ;-)