Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 20-01-2006
noipa noipa is offline
Miembro
 
Registrado: ene 2006
Posts: 11
Poder: 0
noipa Va por buen camino
Escribir un TEdit en un fichero

hola!
¿como hago para, al escribir algo en un TEdit, me lo guarde en un fichero?¿Y para recuperarlo despues?gracias
Responder Con Cita
  #2  
Antiguo 20-01-2006
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.285
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Para Grabarlo:

Código Delphi [-]
var
  TS:TStringList;
begin
  // proteccion
  try
    TS := TStringList.Create();
    TS.Add(Edit1.Text);
    TS.SaveToFile('C:\temp\Edit_Guardado.txt');
  finally
    FreeAndNil(TS);
  end;


Para recuperarlo:

Código Delphi [-]
var
  TS:TStringList;
begin
  // proteccion
  try
    TS := TStringList.Create();
    TS.LoadFromFile('C:\temp\Edit_Guardado.txt');
    // Hay algo?
    if (TS[0] <> '') then begin
      Edit1.Text := TS[0];
    end;
  finally
    FreeAndNil(TS);
  end;



Es un ejemplo simple, pruébalo y adaptalo como necesites.
Te lo he puesto de memoria, así que el posible que haya algun error de sisntáxis; Ya dirás...


Un saludo.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #3  
Antiguo 23-01-2006
noipa noipa is offline
Miembro
 
Registrado: ene 2006
Posts: 11
Poder: 0
noipa Va por buen camino
try , finally...

a q te refieres al poner try and finally??
No se si es un bucle o a q t puedes referir. muchas gracias
Responder Con Cita
  #4  
Antiguo 23-01-2006
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.285
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
(1) Revisa la ayuda de Delphi o manuales; Try..finally te ayuda a capturar posibles errores que puedan producirse en la ejecución.

En éste caso los try..finally están puestos para que si se produce un error al leer/grabar el fichero de texto se libere la memoria creada y no se pierda.

(2) Al comentar esto, me he dado cuenta de que en ambos casos he cometido un "error de bulto". En ambos casos debes poner la línea:

Código Delphi [-]
TS := TStringList.Create();

antes del try.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #5  
Antiguo 23-01-2006
noipa noipa is offline
Miembro
 
Registrado: ene 2006
Posts: 11
Poder: 0
noipa Va por buen camino
gracias

vale! muchas gracias! va perfecto
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 16:57:40.


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