Форум: "Основная";
Текущий архив: 2002.03.21;
Скачать: [xml.tar.bz2];
ВнизМожно ли перевести *.DFM (D6) в *.DFM (D5) ???? Найти похожие ветки
← →
Alx2 (2002-03-06 12:43) [6]Если интересно, вот код:
Procedure TForm1.Button1Click(Sender: TObject);
Function isChanges(Const S: String; Var Res: String): Boolean;
Var len: Integer;
Function LexemSharp(Var K: Integer): Boolean;
Begin
Result := (K < len) And (S[K] = "#");
If Result Then
Begin
inc(K);
While (K <= len) And (S[K] In ["0".."9"]) Do inc(K);
End;
End;
Function LexemAp(Var K: Integer): Boolean;
Begin
Result := (K < len) And (S[K] = """");
If Result Then
Begin
inc(K);
While (K <= len) And (S[K] <> """") Do inc(K);
If K <= len
Then
inc(K);
End;
End;
Function Lexem(Var K: Integer; Var Str: String): Boolean;
Var
Start: Integer;
ValS : String;
Begin
Result := False;
Start := K;
If LexemSharp(K) Then
Begin
ValS := Copy(S, Start+1, K - Start-1);
Str := WideChar(StrToInt(ValS));
Result := True;
End
Else
If LexemAp(K) Then
Begin
Str := Copy(S, Start + 1, K - Start - 2);
Result := True;
End;
End;
Function Prepare(Var K: Integer): String;
Var Str: String;
Begin
Result := "";
While Lexem(K, Str) Do
Result := Result + Str;
If Result <> "" Then
Result := """" + Result + """" + Copy(S, K, Length(S))
Else Result := S;
End;
function min(a,b : integer):integer ;
begin
if a=0 then Result := b
else
if b=0 then Result := a
else
if a>b then result := b
else result := a;
end;
Var
StartIdx: Integer;
Begin
Result := False;
StartIdx := min(Pos("#", S),pos("""",S));
If StartIdx > 0 Then
Begin
len := Length(S);
While (StartIdx <= len) And (Not (S[StartIdx] In ["#", """"])) Do inc(StartIdx);
If StartIdx < len Then
Begin
Res := Copy(S, 1, StartIdx - 1) + Prepare(StartIdx);
Result := True;
End;
End;
End;
Var
SList: TStringList;
K : Integer;
Res : String;
Begin
If OpenDialog1.Execute Then
Begin
SList := TStringList.Create;
Try
SList.LOADFROMFILE(OpenDialog1.Filename);
For K := 0 To SList.Count - 1 Do
If isChanges(SList[K], Res) Then
SList[K] := Res;
Finally
SList.SaveToFile(OpenDialog1.FileName); // Храним в тот же файл.
SList.Free;
End;
End;
End;
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2002.03.21;
Скачать: [xml.tar.bz2];
Память: 0.44 MB
Время: 0.006 c