mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-17 04:21:00 +01:00
MG: started lclproc.pas
git-svn-id: trunk@2350 -
This commit is contained in:
parent
1341f5ea7e
commit
e6c9b594e5
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -609,6 +609,7 @@ lcl/languages/lcl.po svneol=native#text/plain
|
||||
lcl/lazqueue.pp svneol=native#text/pascal
|
||||
lcl/lcllinux.pp svneol=native#text/pascal
|
||||
lcl/lclmemmanager.pas svneol=native#text/pascal
|
||||
lcl/lclproc.pas svneol=native#text/pascal
|
||||
lcl/lclstrconsts.pas svneol=native#text/pascal
|
||||
lcl/lcltype.pp svneol=native#text/pascal
|
||||
lcl/lmessages.pp svneol=native#text/pascal
|
||||
|
||||
69
lcl/lclproc.pas
Normal file
69
lcl/lclproc.pas
Normal file
@ -0,0 +1,69 @@
|
||||
{
|
||||
/***************************************************************************
|
||||
lclproc.pas
|
||||
-----------
|
||||
Component Library Code
|
||||
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
*****************************************************************************
|
||||
* *
|
||||
* This file is part of the Lazarus Component Library (LCL) *
|
||||
* *
|
||||
* See the file COPYING.LCL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
Useful helper functions.
|
||||
}
|
||||
unit LCLProc;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLType;
|
||||
|
||||
Function DeleteAmpersands(var Str : String) : Longint;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
Function DeleteAmpersands(var Str : String) : Longint;
|
||||
// Replace all &x with x
|
||||
// and return the position of the first ampersand letter in the resulting Str.
|
||||
// double ampersands && are converted to a single & and are ignored.
|
||||
var
|
||||
SrcPos, DestPos, SrcLen: Integer;
|
||||
begin
|
||||
Result:=-1;
|
||||
SrcLen:=length(Str);
|
||||
SrcPos:=1;
|
||||
DestPos:=1;
|
||||
while SrcPos<=SrcLen do begin
|
||||
if (Str[SrcPos]='&') and (SrcPos<SrcLen) then begin
|
||||
// & found
|
||||
inc(SrcPos); // skip &
|
||||
if (Str[SrcPos]<>'&') and (Result<1) then
|
||||
Result:=DestPos;
|
||||
end;
|
||||
if DestPos<SrcPos then
|
||||
Str[DestPos]:=Str[SrcPos];
|
||||
inc(SrcPos);
|
||||
inc(DestPos);
|
||||
end;
|
||||
if DestPos<SrcPos then
|
||||
SetLength(Str,DestPos-1);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user