Repository navigation
Expand file tree
/
Copy pathProcedure
More file actions
79 lines (79 loc) · 1.82 KB
/
Copy pathProcedure
File metadata and controls
79 lines (79 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
procedure TFprincipal.dataMask(Sender: TObject; var Key: Char);
var
texto1:String;
letra:Char;
I: Integer;
data:TDate;
begin
if Key in ['0'..'9'] then
begin
if not (Length(TEdit(Sender).Text) >= 11) then
begin
letra:= Key;
Key:=#0;
texto1:= TEdit(Sender).Text;
for I := 1 to Length(texto1) do
begin
if texto1[I] = ' ' then
begin
texto1[I]:= letra;
Break;
end;
if I = 9 then
begin
try
data:= StrToDate(texto1);
except
case MessageDlg('Data inválida', mtError, [mbOk], 0) of
mrOk:
begin
texto1:= ' / / ';
Break;
end;
end;
end;
end;
end;
end;
TEdit(Sender).Text:= texto1;
end
else if Key in [#8] then
begin
Key:= #0;
texto1:= TEdit(Sender).Text;
if texto1.IsEmpty then
begin
texto1:= ' / / ';
end;
for I := 1 to Length(texto1) do
begin
if texto1[I] = ' ' then
begin
if I > 1 then
begin
if not ((I-1) = 3) AND not ((I-1) = 6) then
begin
texto1[I-1]:= ' ';
end
else
begin
texto1[I-2]:= ' ';
end;
end
else
begin
texto1:= ' / / ';
end;
end
else if I = Length(texto1) then
begin
texto1[I]:= ' ';
end
end;
TEdit(Sender).Text:= texto1;
end
else
begin
Key:=#0;
end;
end;