Correção de palavras em uma tabela DBF
13/03/2003
0
Obrigado à todos
Jeffjames
Posts
13/03/2003
Carnette
Coloque esta função dentro do seu projeto e faça as adaptações necessárias;
Função Replace Str
function ReplaceStr (Text,oldstring,newstring:string):string;
var atual, strtofind, originalstr:pchar;
NewText:string;
lenoldstring,lennewstring,m,index:integer;
begin //ReplaceStr
NewText:=Text;
originalstr:=pchar(Text);
strtofind:=pchar(oldstring);
lenoldstring:=length(oldstring);
lennewstring:=length(newstring);
Atual:=StrPos(OriginalStr,StrtoFind);
index:=0;
while Atual<>nil do
begin //Atual<>nil
m:=Atual - OriginalStr - index + 1;
Delete(NewText,m,lenoldstring);
Insert(newstring,NewText,m);
inc(index,lenoldstring-lennewstring);
Atual:=StrPos(Atual+lenoldstring,StrtoFind);
end; //Atual<>nil
Result:=NewText;
end; //ReplaceStr
13/03/2003
Marcelo Saviski
var num:integer; begin query1.active := false; query11.SQL.clear; query1.SQL.add(´select * from tabela.dbf´); query11.SQL.ADD(´´); query1.active := true; tabelacorreta.first; while not tabelacorreta.EOF do begin query1.active := false; query11.SQL[1] := ´where endereco like "¬´ + tabelacorreta.fieldbyname(´prefix´).asstring + ´¬"´ query1.active := true; query1.first; while not query1.EOF do begin num := pos(tabelacorreta.fieldbyname(´prefix´).asstring,query1.fieldbyname(´endereco´).asstring ) query1.fieldbyname(´endereco´).asstring := copy(query1.fieldbyname(´endereco´).asstring , 0 , num) + tabelacorreta.fieldbyname(´nome´).asstring + copy(query1.fieldbyname(´endereco´).asstring ,num + length(tabelacorreta.fieldbyname(´prefix´).asstring),1000); query1.next; end; tabelacorreta.next; end; end;
Espero que funcione!
[img:2a7a104543]http://www.apriori.com.br/cgi/forum/images/smiles/icon_eek.gif[/img:2a7a104543][img:2a7a104543]http://www.apriori.com.br/cgi/forum/images/smiles/icon_cool.gif[/img:2a7a104543][img:2a7a104543]http://www.apriori.com.br/cgi/forum/images/smiles/icon_rolleyes.gif[/img:2a7a104543]
13/03/2003
Anonymous
Jeff
Clique aqui para fazer login e interagir na Comunidade :)