Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Problemas con tstringfield (https://www.clubdelphi.com/foros/showthread.php?t=39050)

mierda 09-01-2007 14:26:51

Problemas con tstringfield
 
Hola muy buenas .... teniendo el siguiente codigo:

Código Delphi [-]
            
variabletemp := TstringField.Create(self);
variabletemp.FieldName := trim(DataModule1.qtemp1.fieldbyname('etiqueta').AsString);
variabletemp.DisplayLabel := trim(DataModule1.qtemp1.fieldbyname('etiqueta').AsString);
variabletemp.DataSet := DataModule1.adotemp;
variabletemp.Name := trim(DataModule1.qtemp1.fieldbyname('etiqueta').AsString);
variabletemp.FieldKind := fkData;
DataModule1.adotemp.FieldDefs.Update;

como puedo eliminar el tstringfield q he creado???
con variabletemp.free? variabletemp.clear? variabletemp.destroy? variabletemp := nil?

Gracias de antemano

mierda 09-01-2007 18:50:26

bueno ... yo mismo me respondo
 
Hola, como ya he encontrado la respuesta la pongo por si a alguien le interesa.

Código Delphi [-]
 
var
TC: TComponent;
 
begin
tc := FindComponent('nombrecampo');
if not (tc = nil) then
   tc.free; // liberamos la memoria
end;

Un saludo

DarKraZY 10-01-2007 10:15:51

La respuesta que tú mismo has puesto es muy válida. Pero si el uso de la variable se limita dentro de un mismo procedure o function tal vez deberías hacerlo así
  1. Porque es más claro
  2. Porque te aseguras que siempre se libera
Código Delphi [-]
var
  VariableTemp: TStringField;
begin
  VariableTemp := TStringField.Create(Self);
  try
    // código fuente aquí
  finally
    VariableTemp.Free;
  end;
end;


La franja horaria es GMT +2. Ahora son las 16:44:52.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi