• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

A file question.

I have a text file (ie a sql script)
in which I like to lowercase  every string inside [ ] if the text is not [PRIMARY] (if it's [PRIMARY]
i like to keeep it upper-case.

how can I do that?

for example, every apperence of [TABLE_NAME] should be converted to  [table_name]


0
hulken
Asked:
hulken
  • 2
  • 2
1 Solution
 
ITugayCommented:
Hi hulken,


var
  S: String;
  C: String;
  I: Integer;
  J: Integer;
  L: TStrings;
begin

  L := TStringList.Create;
  L.LoadFromFile('D:\000.TXT');
  S := L.Text;

  I := 1;
  while (I <= Length(S)) do
  begin
    while (I <= Length(S)) and (S[I] <> '[') do inc(I);
    inc(I);
    J := I;
    while (I <= Length(S)) and (S[I] <> ']') do inc(I);
    C := Copy(S, J, I - J);
    if C <> 'PRIMARY' then
    begin
      C := LowerCase(C);
      Delete(S, J, I - J);
      Insert(C, S, J);
    end;
  end;

  L.Text := S;
  L.SaveToFile('D:\000.TXT');
  L.Free;

end;
0
 
kretzschmarCommented:
hu, bytewise, igor?
0
 
kretzschmarCommented:
what else :-)

hi igor ;-)
0
 
ITugayCommented:
hi meikl,
just have few free time to write something :-)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now