diff options
| author | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2008-12-30 10:03:29 +0000 |
|---|---|---|
| committer | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2008-12-30 10:03:29 +0000 |
| commit | 7c2b9006daa04337f36c4fa1984846dc3397ffe5 (patch) | |
| tree | 5ea5c92694a5b9c78a11e7b271ea0416275cd35a /packages/fcl-base | |
| parent | 62fbf76f4c3d06927dbbc104f5443fb833c52857 (diff) | |
| download | fpc-7c2b9006daa04337f36c4fa1984846dc3397ffe5.tar.gz | |
* patch to implement MaskDoFormatText by Paul Ishenin
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@12458 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-base')
| -rw-r--r-- | packages/fcl-base/src/maskutils.pp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/packages/fcl-base/src/maskutils.pp b/packages/fcl-base/src/maskutils.pp index 207949631a..613913bcf7 100644 --- a/packages/fcl-base/src/maskutils.pp +++ b/packages/fcl-base/src/maskutils.pp @@ -48,6 +48,7 @@ Classes function FormatMaskText(const EditMask: string; const Value: string): string; function FormatMaskInput(const EditMask: string): string; +function MaskDoFormatText(const EditMask: string; const Value: string; Blank: Char): string; @@ -69,13 +70,13 @@ type type TMaskUtils = class(TObject) - private + private FValue: string; SourcePosition,Position : Integer; FEditMask,FMask : string; SourceVal,ExitVal : string; - Matched : Boolean; - MissChar : Char; + FMatched : Boolean; + FMissChar : Char; State : TParseState; procedure EvaluateExit; procedure EvaluateMissing; @@ -96,12 +97,14 @@ type function GetInputMask: string; procedure SetMask(const AValue: string); procedure SetValue(const AValue: string); - protected + protected procedure RaiseError; procedure ExtractMask; function MaskPtr : Char; function SourcePtr : Char; - public + property Matched: Boolean read FMatched write FMatched; + property MissChar: Char read FMissChar write FMissChar; + public function ValidateInput : string; property Mask : string read FEditMask write SetMask; property Value : string read FValue write SetValue; @@ -571,6 +574,26 @@ begin end; end; +{ + Format Value string using EditMask, dont use 2d and 3d fields of EditMask, + set own Blank char and Matched = False +} +function MaskDoFormatText(const EditMask: string; const Value: string; Blank: Char): string; +var + msk : TMaskUtils; +begin + Result := ''; + msk := TMaskUtils.Create; + try + msk.Mask := EditMask; + msk.Value := Value; + msk.Matched := False; + msk.MissChar := Blank; + Result := msk.ValidateInput; + finally + msk.Free; + end; +end; end. |
