[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to 'right' this 'wrong' function???

Posted on 2004-04-02
5
Medium Priority
?
166 Views
Last Modified: 2010-04-05
Hi all!! I'm trying to compile this package which should be no problem in D7, at least that is what I was told. Compiling however halts at an early stage and I can't circumvent this. I know, cause I tried...;(

This function causes the problem with its StrReplace > something I could not find in delphi help (D7) and also something I couldn't 'fix'.
Anyone dare to try??
The error message states that either 'a file' already is in use or that it is readonly (which it is NOT) or it refers to my harddisk being damaged. Out of these three I would go for the first > so I went and went but I couldn't find a file used, that was already in use. (this function is part of the actor creator kit which helps you create a custom .aad and afterwards .aal file to respresent an office assistant like creature.....)

 function CreateProject(LibName, ResName: String): String;
  var
    I: Integer;
    F: TextFile;
    ResFileNameOnly: String;
    LibNameOnly, LibExtOnly: String;
  begin
    ResFileNameOnly := ExtractFileName(ResName);
    LibNameOnly := ChangeFileExt(ExtractFileName(LibName), '');
    LibExtOnly := ReplaceStr(ExtractFileExt(LibName), '.', '');
    Result := ChangeFileExt(LibName, '.dpr');
    AssignFile(F, Result);
    Rewrite(F);
    try
      for I := 0 to LibSource.Strings.Count-1 do
        if Pos('%f', LibSource.Strings[I]) <> 0 then
          WriteLn(F, ReplaceStr(LibSource.Strings[I], '%f', LibNameOnly))
        else if Pos('%r', LibSource.Strings[I]) <> 0 then
          WriteLn(F, ReplaceStr(LibSource.Strings[I], '%r', ResFileNameOnly))
        else if Pos('%e', LibSource.Strings[I]) <> 0 then
          WriteLn(F, ReplaceStr(LibSource.Strings[I], '%e', LibExtOnly))
        else
          WriteLn(F, LibSource.Strings[I]);
    finally
      CloseFile(F);
    end;
  end;

My regards to all-o-ya!! Keep up da good work!!

Peter

(ps correcting the problem and providing a functional replacement equals the points ofcourse;)
0
Comment
Question by:PeterdeB
[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
  • 3
5 Comments
 

Author Comment

by:PeterdeB
ID: 10744982
Ooeps > ReplaceStr that is instead of StrReplace;)
0
 
LVL 17

Expert Comment

by:mokule
ID: 10745043
StringReplace ?
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 1000 total points
ID: 10745062
Have you tried replacing this with the StringReplace function in Delphi?

StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;

eg:

WriteLn(F,StringReplace(LibSource.Strings[I], '%f', LibNameOnly, [rfReplaceAll]));

Just a thought,
Russell

0
 

Author Comment

by:PeterdeB
ID: 10746804
Hi Mokule and rllibby! Yes I tried but couldn't get this thing working anyway > I will now try again (using your response Russell)

Thanks in advance for the replies!!

I will get back to this,

Peter
0
 

Author Comment

by:PeterdeB
ID: 10751399
Hi all,

Thanks to both of you for assisting me > Russell you get the points cause I consider your answer to be complete even though Mokule responded before you did (just to explain why ....). I had already thought about the StringReplace but failed to implement it accordingly even though it does seem logics now, ofcourse this was after Russell provided the solution.

My regards and appreciation, Peter

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

656 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