Ver Mensaje Individual
  #1  
Antiguo 09-05-2013
manujimenez manujimenez is offline
Miembro
NULL
 
Registrado: abr 2013
Posts: 11
Reputación: 0
manujimenez Va por buen camino
Remplazar texto en fichero

He visto este código aquí en club delphi he intentado utilizarlo y me tira estos errores:

[DCC Warning] CambiaTexto.pas(35): W1019 For loop control variable must be simple local variable
[DCC Error] CambiaTexto.pas(37): E2003 Undeclared identifier: 'StuffString'
[DCC Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'CambiaTexto.pas'

Alguien me puede explicar un poco, incluyo toda la unit. Disculpar las molestias soy muy novato.



unit CambiaTexto;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;
ss : TStringList;
I: integer;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin

ss := TStringList.Create;
ss.LoadFromFile('c:\xxx\archivo.txt');
//ss.Text := StringReplace(ss.text,'22.150 ','22.250 ',[rfReplaceAll]);

for I := 0 to (ss.count -1) do
if sametext(copy(ss.strings[i], 117, length('21.250')), '21.250') then
ss.strings[i] := StuffString('21.250', 117, length('21.250'), '22.250');

ss.SaveToFile('c:\xxx\archivo.txt');
end;

end.
Responder Con Cita