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 17-11-2014
obum1 obum1 is offline
Miembro
NULL
 
Registrado: jun 2014
Posts: 24
Poder: 0
obum1 Va por buen camino
Post Ayuda INI Files

Hola amigos tengo una problema con los inifiles a la hora de que el programa lo lea por ejemplo:

[secion]
iden=dfakldsjklñdajklñfdsajklfdsajklfdsajklfdsaklñfdsajklñdsafjklfjlkfñalkdsf <======== Valor.

al crear todo el proecedmiento y cargar la ini a un edit lo que sucede, que no carga todo el string si no casi muy
poco por ello queria saber como solucionarlo ya que no deja cargargar todo. Gracias.
Responder Con Cita
  #2  
Antiguo 17-11-2014
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
¿Que código estás usando?

Saludos.
Responder Con Cita
  #3  
Antiguo 17-11-2014
obum1 obum1 is offline
Miembro
NULL
 
Registrado: jun 2014
Posts: 24
Poder: 0
obum1 Va por buen camino
dsa

var
ini : tinifiles
begin
ini := tinifiles. create(exfilepatch(exename)+'key.key');
edit1.text := ini.readstring('ubicacion','llave',''
end;
esta es el codigo que uso para cargar pero no carga completamente el string si no a medias
Responder Con Cita
  #4  
Antiguo 17-11-2014
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
obum1,

Cita:
Empezado por obum1
...tengo una problema con los inifiles a la hora de que el programa lo lea...no carga todo el string...a un edit...


Pregunto:

1- ¿Que versión de Windows y Delphi utilizas?.

2- ¿El componente TEdit en cuestión, tiene la propiedad MaxLength con algún valor diferente de cero?.

3- ¿Has hecho un debug para verificar si los valores son leídos correctamente del archivo .ini?

4- ¿Puedes publicar el código real que usas en el programa?, el código que publicastes en el Msg #3 no es el correcto

Revisa este código:
Código Delphi [-]
// GUARDANDO OPCIONES EN UN ARCHIVO INI

procedure TFPrincipal.GuardarINI;
var INI: TIniFile;
begin
  // Creamos el archivo INI
  INI := TINIFile.Create( ExtractFilePath( Application.ExeName ) + 'opciones.ini' );

  // Guardamos las opciones
  INI.WriteString( 'OPCIONES', 'IMPRESORA', IMPRESORA.Text );
  INI.WriteInteger( 'OPCIONES', 'COPIAS', COPIAS.Value );
  INI.WriteBool( 'OPCIONES', 'VISTAPREVIA', VISTAPREVIA.Checked );
  INI.WriteDate( 'OPCIONES', 'FECHA', FECHA.Date );
  INI.WriteTime( 'OPCIONES', 'HORA', StrToTime( HORA.Text ) );
  INI.WriteFloat( 'OPCIONES', 'MARGEN', MARGEN.Value );

  // Al liberar el archivo INI se cierra el archivo opciones.ini
  INI.Free;
end;

// CARGANDO OPCIONES DE UN ARCHIVO INI

procedure TFPrincipal.CargarINI;
var INI: TIniFile;
begin
  // Si no existe el archivo no hacemos nada
  if not FileExists( ExtractFilePath( Application.ExeName ) + 'opciones.ini' ) then
    Exit;

  // Creamos el archivo INI
  INI := TINIFile.Create( ExtractFilePath( Application.ExeName ) + 'opciones.ini' );

  // Guardamos las opciones
  IMPRESORA.Text := INI.ReadString( 'OPCIONES', 'IMPRESORA', '' );
  COPIAS.Value := INI.ReadInteger( 'OPCIONES', 'COPIAS', 0 );
  VISTAPREVIA.Checked := INI.ReadBool( 'OPCIONES', 'VISTAPREVIA', False );
  FECHA.Date := INI.ReadDate( 'OPCIONES', 'FECHA', Date );
  HORA.Text := TimeToStr( INI.ReadTime( 'OPCIONES', 'HORA', Time ) );
  MARGEN.Value := INI.ReadFloat( 'OPCIONES', 'MARGEN', 0.00 );

  // Al liberar el archivo INI se cierra el archivo opciones.ini
  INI.Free;
end;
Tomado de : Delphi al Límite - Guardando y cargando opciones

Espero sea útil

Nelson.
Responder Con Cita
  #5  
Antiguo 17-11-2014
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola obum1.

Por favor vuelve a leer la Guía de estilo y cuando incluyas código en tus mensajes usa las etiquetas como explica la imágen:



Ese código no puede siquiera ser compilado, te señalo los errores de sintáxis:
Código Delphi [-]
var
  ini : tinifiles //;
begin
  ini := tinifiles.{ }create(exfilepatch(exename)+'key.key');
  edit1.text := ini.readstring('ubicacion','llave','' // );
end;

La sintáxis correcta:
Código Delphi [-]
var
  ini : TiniFile;
begin
  ini := TIniFile.Create(ExtractFilePath(Application.ExeName)+'key.key');
  Edit1.Text := ini.ReadString('ubicacion','llave','');
end;
Eso como para que compile, pero no puedo asegurar que los valores obtenidos sean correctos... También sería necesario ver como se guardan los valores.

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #6  
Antiguo 17-11-2014
obum1 obum1 is offline
Miembro
NULL
 
Registrado: jun 2014
Posts: 24
Poder: 0
obum1 Va por buen camino
Cita:
Empezado por nlsgarcia Ver Mensaje
obum1,




Pregunto:

1- ¿Que versión de Windows y Delphi utilizas?.

2- ¿El componente TEdit en cuestión, tiene la propiedad MaxLength con algún valor diferente de cero?.

3- ¿Has hecho un debug para verificar si los valores son leídos correctamente del archivo .ini?

4- ¿Puedes publicar el código real que usas en el programa?, el código que publicastes en el Msg #3 no es el correcto

Revisa este código:
Código Delphi [-]
// GUARDANDO OPCIONES EN UN ARCHIVO INI

procedure TFPrincipal.GuardarINI;
var INI: TIniFile;
begin
  // Creamos el archivo INI
  INI := TINIFile.Create( ExtractFilePath( Application.ExeName ) + 'opciones.ini' );

  // Guardamos las opciones
  INI.WriteString( 'OPCIONES', 'IMPRESORA', IMPRESORA.Text );
  INI.WriteInteger( 'OPCIONES', 'COPIAS', COPIAS.Value );
  INI.WriteBool( 'OPCIONES', 'VISTAPREVIA', VISTAPREVIA.Checked );
  INI.WriteDate( 'OPCIONES', 'FECHA', FECHA.Date );
  INI.WriteTime( 'OPCIONES', 'HORA', StrToTime( HORA.Text ) );
  INI.WriteFloat( 'OPCIONES', 'MARGEN', MARGEN.Value );

  // Al liberar el archivo INI se cierra el archivo opciones.ini
  INI.Free;
end;

// CARGANDO OPCIONES DE UN ARCHIVO INI

procedure TFPrincipal.CargarINI;
var INI: TIniFile;
begin
  // Si no existe el archivo no hacemos nada
  if not FileExists( ExtractFilePath( Application.ExeName ) + 'opciones.ini' ) then
    Exit;

  // Creamos el archivo INI
  INI := TINIFile.Create( ExtractFilePath( Application.ExeName ) + 'opciones.ini' );

  // Guardamos las opciones
  IMPRESORA.Text := INI.ReadString( 'OPCIONES', 'IMPRESORA', '' );
  COPIAS.Value := INI.ReadInteger( 'OPCIONES', 'COPIAS', 0 );
  VISTAPREVIA.Checked := INI.ReadBool( 'OPCIONES', 'VISTAPREVIA', False );
  FECHA.Date := INI.ReadDate( 'OPCIONES', 'FECHA', Date );
  HORA.Text := TimeToStr( INI.ReadTime( 'OPCIONES', 'HORA', Time ) );
  MARGEN.Value := INI.ReadFloat( 'OPCIONES', 'MARGEN', 0.00 );

  // Al liberar el archivo INI se cierra el archivo opciones.ini
  INI.Free;
end;
Tomado de : Delphi al Límite - Guardando y cargando opciones

Espero sea útil

Nelson.
bueno es similaar a tu codigo, el problema guarda el ini pero cargar carga el string al edit pero no completamente y el edit esta por deafault no modifique ningun valor en maxlength.
Responder Con Cita
  #7  
Antiguo 17-11-2014
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
obum1,

Cita:
Empezado por obum1
...es similar a tu código...no modifique ningún valor en MaxLength...


Pregunto:

1- ¿Que versión de Windows y Delphi utilizas?.

2- ¿Has hecho un debug para verificar si los valores son leídos correctamente del archivo .ini?

Espero sea útil

Nelson.
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
WINI (Windows Ini Files) Khronos Trucos 0 26-11-2008 17:14:16
detectar directorio Program Files mjjj API de Windows 4 01-07-2008 14:45:38
Resource files Delar Varios 4 25-07-2007 12:48:38
Delphi resource files español marceloalegre Varios 1 28-06-2006 22:21:35
bufrs i files xrc Varios 2 17-12-2005 11:51:22


La franja horaria es GMT +2. Ahora son las 04:51:58.


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