Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Una pregunta simple (Sumar integer en INI) (https://www.clubdelphi.com/foros/showthread.php?t=67263)

broly7 08-04-2010 16:37:30

Una pregunta simple (Sumar integer en INI)
 
Necesito saber simplemente cómo sumar +1 valor en un archivo INI. Tal que así.

Código Delphi [-]
var
F:Tinifile;
begin
F:= TiniFile.Create ('Settings.ini');
F.Writeinteger('BOOLEANS','Modo0',+1);
end;

No funciona, jaja.
SI Modo0=0 quiero que Modo0=1 luego Modo0=2...
Gracias.

roman 08-04-2010 16:45:21

Un archivo ini simplemente guarda información, así que la única opción es leer el valor, sumarle uno, escribir el resultado.

// Saludos

Caro 08-04-2010 16:49:54

Hola broly, como te dice Roman primero debes leer el valor:

Código Delphi [-]
var
F:Tinifile;
begin
  F:= TiniFile.Create ('Settings.ini');
  Numero := F.ReadInteger('BOOLEANS', 'Modo0', 0);
  F.Writeinteger('BOOLEANS','Modo0',Numero+1);
end;

Saluditos

broly7 08-04-2010 17:57:25

Gracias Roman, tienes razón. Los Archivos INI simplemente guardan la informacion.

Lepe 08-04-2010 18:49:02

¿alguien usaría esto?
Código Delphi [-]
with TInifile.Create('c:\settings') do // que si no se va a la carpeta activa en el OS
begin
 WriteInteger('BOOLEANS', 'Modo0', ReadInteger('BOOLEANS', 'Modo0',0) + 1)
  Free;
end;


La franja horaria es GMT +2. Ahora son las 11:17:49.

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