IncludeLeadingChar function
String / Filename routines |
![]() ![]() ![]() |
acUtils
|
function IncludeLeadingChar(St: String; Ch: Char): String;
|
The IncludeLeadingChar function puts specified character at the beginning of a string if it's not already there. For example result of IncludeTrailingChar('Software\Microsoft\CurrentVersion', '\') will be "\Software\Microsoft\CurrentVersion". It's a typical function that gets rewritten by every programmer.
|
function IncludeLeadingChar(const St: String; Ch: Char): String;
|
begin
|
if (St = '') or (St[1] <> Ch) then
|
Result := Ch + St
|
else
|
Result := St;
|
end;
|