-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJetCommon.pas
More file actions
128 lines (108 loc) · 2.57 KB
/
JetCommon.pas
File metadata and controls
128 lines (108 loc) · 2.57 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
unit JetCommon;
(*
Contains common procedures for printing/converting stuff
*)
interface
function VarIsNil(val: OleVariant): boolean;
function str(val: OleVariant): WideString;
function arr_str(val: OleVariant): WideString;
function int(val: OleVariant): integer;
function uint(val: OleVariant): int64;
function bool(val: OleVariant): boolean;
function includes(main, flag: cardinal): boolean;
(*
Previous section is closed automatically when a new one is declared.
If you need to close manually, call EndSection.
*)
procedure Section(SectionName: string);
procedure Subsection(SectionName: string);
procedure EndSection;
procedure EndSubsection;
implementation
uses Variants;
function VarIsNil(val: OleVariant): boolean;
begin
Result := VarIsClear(val) or VarIsNull(val);
end;
function str(val: OleVariant): WideString;
begin
if VarIsNil(val) then
Result := ''
else begin
Result := string(val);
end;
end;
//Òî æå, ÷òî str(), íî ôîðìàòèðóåò è ìàññèâû
function arr_str(val: OleVariant): WideString;
var i: integer;
begin
if not VarIsArray(val) then begin
Result := str(val);
exit;
end;
if Length(val) > 0 then
Result := arr_str(val[0])
else
Result := '';
for i := 1 to Length(val) - 1 do
Result := Result + ', ' + arr_str(val[i]);
Result := '(' + Result + ')';
end;
function int(val: OleVariant): integer;
begin
if VarIsNil(val) then
Result := 0
else Result := integer(val);
end;
function uint(val: OleVariant): int64;
begin
if VarIsNil(val) then
Result := 0
else Result := val;
end;
function bool(val: OleVariant): boolean;
begin
if VarIsNil(val) then
Result := false
else Result := boolean(val);
end;
function includes(main, flag: cardinal): boolean;
begin
Result := (main and flag) = flag;
end;
var
InSection: boolean = false;
InSubSection: boolean = false;
procedure Section(SectionName: string);
begin
if InSection then
EndSection;
writeln(SectionName);
writeln('=========================================');
InSection := true;
end;
procedure SubSection(SectionName: string);
begin
if InSubsection then
EndSubsection;
writeln('== ' + SectionName);
InSubsection := true;
end;
procedure EndSection;
begin
if InSection then begin
writeln('');
writeln('');
end else
if InSubsection then
EndSubsection;
InSubsection := false;
InSection := false;
end;
procedure EndSubsection;
begin
if InSubsection then
writeln('');
InSubsection := false;
end;
end.