Solved

A file question.

Posted on 2001-08-24
4
140 Views
Last Modified: 2010-04-06
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
Comment
Question by:hulken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
ITugay earned 100 total points
ID: 6421538
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6421554
hu, bytewise, igor?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6421557
what else :-)

hi igor ;-)
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6421568
hi meikl,
just have few free time to write something :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
URL for downloading Google Chrome for Win XP 2 273
JAudiorecorder record freezing the app 29 91
Graphics32 under Delphi 10.1 Berlin 2 172
RESTRequest Parameter 4 78
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question