Link to home
Start Free TrialLog in
Avatar of pr_wainwright
pr_wainwright

asked on

StringReplace

I have compiled a Delphi package which references the function StringReplace.
I get a compile time error of 'undeclared  identifier'. I know that StringReplace is a standard Delphi function but i cannot seem to find it, nor does the Delphi help have any reference to it. Could anyone tell me which unit StringReplace is in ?. I am using Delphi 3.02 Professional.

P.S I have a copy of C++ Builder 4 which has the 'StringReplace' function in the SysUtils file. Is it possible to call this from a Delphi application?.

     Thanks Paul.
Avatar of aubs
aubs

According to help it resides in SysUtils.
Yes... Actually it resides in all versions in SysUtils.pas
here ya go, from the help files:
---------------------------------------

Returns a string with occurrences of one substring replaced by another substring.

Unit

Sysutils

Category

string handling routines

type
  TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;

Description

StringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string, specified by S, may contain Multibyte characters.

If the Flags parameter does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, all instances of OldPattern are replaced by NewPattern.

If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.
ASKER CERTIFIED SOLUTION
Avatar of umulig
umulig

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pr_wainwright

ASKER

Edited text of question.
Adjusted points from 50 to 100
Hi pr_wainwright,

Seems easy solve your problem.
If you're using CBuilder then open then source file header,
example : Unit1.cpp-->Unit1.hpp and put the follow line
<#include SysUtils.hpp>

Now any reference to StringReplace at Unit1 is fixed.

Now if you're Using Delphi 3.02 locate the "uses" clause of each unit that make reference ot StringReplace and add
SysUtils at the end of the line. like this
uses
 ..., Windows, ...., SysUtils;

T++, Radler.
Hi pr_wainwright,

Seems easy solve your problem.
If you're using CBuilder then open then source file header,
example : Unit1.cpp-->Unit1.hpp and put the follow line
<#include SysUtils.hpp>

Now any reference to StringReplace at Unit1 is fixed.

Now if you're Using Delphi 3.02 locate the "uses" clause of each unit that make reference ot StringReplace and add
SysUtils at the end of the line. like this
uses
 ..., Windows, ...., SysUtils;

T++, Radler.
Thanks, Delphi 3.02 does not have the ReplaceString function in it's SysUtils.pas file. This alternative worked fine.

   Paul.