How to 'right' this 'wrong' function???
Posted on 2004-04-02
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;
LibNameOnly, LibExtOnly: String;
ResFileNameOnly := ExtractFileName(ResName);
LibNameOnly := ChangeFileExt(ExtractFileName(LibName), '');
LibExtOnly := ReplaceStr(ExtractFileExt(LibName), '.', '');
Result := ChangeFileExt(LibName, '.dpr');
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))
My regards to all-o-ya!! Keep up da good work!!
(ps correcting the problem and providing a functional replacement equals the points ofcourse;)