* patch to implement MaskDoFormatText by Paul Ishenin

git-svn-id: trunk@12458 -
This commit is contained in:
florian 2008-12-30 10:03:29 +00:00
parent 4e2676ca13
commit 2083396fbc

View File

@ -48,6 +48,7 @@ Classes
function FormatMaskText(const EditMask: string; const Value: string): string; function FormatMaskText(const EditMask: string; const Value: string): string;
function FormatMaskInput(const EditMask: 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 type
TMaskUtils = class(TObject) TMaskUtils = class(TObject)
private private
FValue: string; FValue: string;
SourcePosition,Position : Integer; SourcePosition,Position : Integer;
FEditMask,FMask : string; FEditMask,FMask : string;
SourceVal,ExitVal : string; SourceVal,ExitVal : string;
Matched : Boolean; FMatched : Boolean;
MissChar : Char; FMissChar : Char;
State : TParseState; State : TParseState;
procedure EvaluateExit; procedure EvaluateExit;
procedure EvaluateMissing; procedure EvaluateMissing;
@ -96,12 +97,14 @@ type
function GetInputMask: string; function GetInputMask: string;
procedure SetMask(const AValue: string); procedure SetMask(const AValue: string);
procedure SetValue(const AValue: string); procedure SetValue(const AValue: string);
protected protected
procedure RaiseError; procedure RaiseError;
procedure ExtractMask; procedure ExtractMask;
function MaskPtr : Char; function MaskPtr : Char;
function SourcePtr : Char; function SourcePtr : Char;
public property Matched: Boolean read FMatched write FMatched;
property MissChar: Char read FMissChar write FMissChar;
public
function ValidateInput : string; function ValidateInput : string;
property Mask : string read FEditMask write SetMask; property Mask : string read FEditMask write SetMask;
property Value : string read FValue write SetValue; property Value : string read FValue write SetValue;
@ -571,6 +574,26 @@ begin
end; end;
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. end.