1 | unit rMisc;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses SysUtils, Windows, Classes, Forms, Controls, ComCtrls, Grids, ORFn, ORNet,
|
---|
6 | Menus, Contnrs, StrUtils;
|
---|
7 |
|
---|
8 | const
|
---|
9 | MAX_TOOLITEMS = 30;
|
---|
10 |
|
---|
11 | type
|
---|
12 | TToolMenuItem = class
|
---|
13 | public
|
---|
14 | Caption: string;
|
---|
15 | Caption2: string;
|
---|
16 | Action: string;
|
---|
17 | MenuID: string;
|
---|
18 | SubMenuID: string;
|
---|
19 | MenuItem: TMenuItem;
|
---|
20 | end;
|
---|
21 |
|
---|
22 | var
|
---|
23 | uToolMenuItems: TObjectList = nil;
|
---|
24 |
|
---|
25 | type
|
---|
26 | {An Object of this Class is Created to Hold the Sizes of Controls(Forms)
|
---|
27 | while the app is running, thus reducing calls to RPCs SAVESIZ and LOADSIZ}
|
---|
28 | TSizeHolder = class(TObject)
|
---|
29 | private
|
---|
30 | FSizeList,FNameList: TStringList;
|
---|
31 | public
|
---|
32 | constructor Create;
|
---|
33 | destructor Destroy; override;
|
---|
34 | function GetSize(AName: String): String;
|
---|
35 | procedure SetSize(AName,ASize: String);
|
---|
36 | procedure AddSizesToStrList(theList: TStringList);
|
---|
37 | end;
|
---|
38 |
|
---|
39 | function DetailPrimaryCare(const DFN: string): TStrings; //*DFN*
|
---|
40 | procedure GetToolMenu;
|
---|
41 | procedure ListSymbolTable(Dest: TStrings);
|
---|
42 | function MScalar(const x: string): string;
|
---|
43 | procedure SetShareNode(const DFN: string; AHandle: HWND); //*DFN*
|
---|
44 | function ServerHasPatch(const x: string): Boolean;
|
---|
45 | function ServerVersion(const Option, VerClient: string): string;
|
---|
46 | function PackageVersion(const Namespace: string): string;
|
---|
47 |
|
---|
48 | procedure SaveUserBounds(AControl: TControl);
|
---|
49 | procedure SaveUserSizes(SizingList: TStringList);
|
---|
50 | procedure SetFormPosition(AForm: TForm);
|
---|
51 | procedure SetUserBounds(var AControl: TControl);
|
---|
52 | procedure SetUserBounds2(AName: string; var v1, v2, v3, v4: integer);
|
---|
53 | procedure SetUserWidths(var AControl: TControl);
|
---|
54 | procedure SetUserColumns(var AControl: TControl);
|
---|
55 | procedure SetUserString(StrName: string; var Str: string);
|
---|
56 | function StrUserBounds(AControl: TControl): string;
|
---|
57 | function StrUserBounds2(AName: string; v1, v2, v3, v4: integer): string;
|
---|
58 | function StrUserWidth(AControl: TControl): string;
|
---|
59 | function StrUserColumns(AControl: TControl): string;
|
---|
60 | function StrUserString(StrName: string; Str: string): string;
|
---|
61 | function UserFontSize: integer;
|
---|
62 | procedure SaveUserFontSize( FontSize: integer);
|
---|
63 |
|
---|
64 | var
|
---|
65 | SizeHolder : TSizeHolder;
|
---|
66 |
|
---|
67 | implementation
|
---|
68 |
|
---|
69 | uses TRPCB, fOrders, math;
|
---|
70 |
|
---|
71 | var
|
---|
72 | uBounds, uWidths, uColumns: TStringList;
|
---|
73 |
|
---|
74 | function DetailPrimaryCare(const DFN: string): TStrings; //*DFN*
|
---|
75 | begin
|
---|
76 | CallV('ORWPT1 PCDETAIL', [DFN]);
|
---|
77 | Result := RPCBrokerV.Results;
|
---|
78 | end;
|
---|
79 |
|
---|
80 | const
|
---|
81 | SUBMENU_KEY = 'SUBMENU';
|
---|
82 | SUBMENU_KEY_LEN = length(SUBMENU_KEY);
|
---|
83 | SUB_LEFT = '[';
|
---|
84 | SUB_RIGHT = ']';
|
---|
85 | MORE_ID = 'MORE^';
|
---|
86 | MORE_NAME = 'More...';
|
---|
87 |
|
---|
88 | procedure GetToolMenu;
|
---|
89 | var
|
---|
90 | i, p, LastIdx, count, MenuCount: Integer;
|
---|
91 | id, x: string;
|
---|
92 | LastItem, item: TToolMenuItem;
|
---|
93 | caption, action: string;
|
---|
94 | CurrentMenuID: string;
|
---|
95 | MenuIDs: TStringList;
|
---|
96 | begin
|
---|
97 | if not assigned(uToolMenuItems) then
|
---|
98 | uToolMenuItems := TObjectList.Create
|
---|
99 | else
|
---|
100 | uToolMenuItems.Clear;
|
---|
101 | CallV('ORWU TOOLMENU', [nil]);
|
---|
102 | MenuIDs := TStringList.Create;
|
---|
103 | try
|
---|
104 | for i := 0 to RPCBrokerV.Results.Count - 1 do
|
---|
105 | begin
|
---|
106 | x := Piece(RPCBrokerV.Results[i], U, 1);
|
---|
107 | item := TToolMenuItem.Create;
|
---|
108 | Caption := Piece(x, '=', 1);
|
---|
109 | Action := Copy(x, Pos('=', x) + 1, Length(x));
|
---|
110 | item.Caption2 := Caption;
|
---|
111 | if UpperCase(copy(Action,1,SUBMENU_KEY_LEN)) = SUBMENU_KEY then
|
---|
112 | begin
|
---|
113 | id := UpperCase(Trim(Copy(Action, SUBMENU_KEY_LEN+1, MaxInt)));
|
---|
114 | if (LeftStr(id,1) = SUB_LEFT) and (RightStr(id,1) = SUB_RIGHT) then
|
---|
115 | id := copy(id, 2, length(id)-2);
|
---|
116 | item.MenuID := id;
|
---|
117 | Action := '';
|
---|
118 | if MenuIDs.IndexOf(item.MenuID) < 0 then
|
---|
119 | MenuIDs.Add(item.MenuID)
|
---|
120 | else
|
---|
121 | begin
|
---|
122 | item.SubMenuID := item.MenuID;
|
---|
123 | item.MenuID := '';
|
---|
124 | end;
|
---|
125 | end;
|
---|
126 | if RightStr(Caption, 1) = SUB_RIGHT then
|
---|
127 | begin
|
---|
128 | p := length(Caption) - 2;
|
---|
129 | while (p > 0) and (Caption[p] <> SUB_LEFT) do
|
---|
130 | dec(p);
|
---|
131 | if (p > 0) and (Caption[p] = SUB_LEFT) then
|
---|
132 | begin
|
---|
133 | item.SubMenuID := UpperCase(Trim(copy(Caption,p+1, length(Caption)-1-p)));
|
---|
134 | Caption := copy(Caption,1,p-1);
|
---|
135 | end;
|
---|
136 | end;
|
---|
137 | item.Caption := Caption;
|
---|
138 | item.Action := Action;
|
---|
139 | uToolMenuItems.add(item);
|
---|
140 | end;
|
---|
141 | // see if all child menu items have parents
|
---|
142 | for I := 0 to uToolMenuItems.Count - 1 do
|
---|
143 | begin
|
---|
144 | item := TToolMenuItem(uToolMenuItems[i]);
|
---|
145 | if MenuIDs.IndexOf(item.SubMenuID) < 0 then
|
---|
146 | begin
|
---|
147 | item.SubMenuID := '';
|
---|
148 | item.Caption := item.Caption2;
|
---|
149 | end;
|
---|
150 | end;
|
---|
151 |
|
---|
152 | // see if there are more than MAX_TOOLITEMS in the root menu
|
---|
153 | // if there are, add automatic sub menus
|
---|
154 | LastIdx := (MAX_TOOLITEMS - 1);
|
---|
155 | count := 0;
|
---|
156 | CurrentMenuID := '';
|
---|
157 | i := 0;
|
---|
158 | LastItem := nil;
|
---|
159 | MenuCount := 0;
|
---|
160 | repeat
|
---|
161 | item := TToolMenuItem(uToolMenuItems[i]);
|
---|
162 | if item.SubMenuID = '' then
|
---|
163 | begin
|
---|
164 | item.SubMenuID := CurrentMenuID;
|
---|
165 | inc(count);
|
---|
166 | if Count > MAX_TOOLITEMS then
|
---|
167 | begin
|
---|
168 | item.SubMenuID := '';
|
---|
169 | inc(MenuCount);
|
---|
170 | item := TToolMenuItem.Create;
|
---|
171 | item.Caption := MORE_NAME;
|
---|
172 | item.MenuID := MORE_ID + IntToStr(MenuCount);
|
---|
173 | item.SubMenuID := CurrentMenuID;
|
---|
174 | CurrentMenuID := item.MenuID;
|
---|
175 | LastItem.SubMenuID := CurrentMenuID;
|
---|
176 | uToolMenuItems.Insert(LastIdx, item);
|
---|
177 | inc(LastIdx,MAX_TOOLITEMS);
|
---|
178 | Count := 1;
|
---|
179 | end;
|
---|
180 | LastItem := item;
|
---|
181 | end;
|
---|
182 | inc(i);
|
---|
183 | until i >= uToolMenuItems.Count;
|
---|
184 |
|
---|
185 | finally
|
---|
186 | MenuIDs.Free;
|
---|
187 | end;
|
---|
188 | end;
|
---|
189 |
|
---|
190 | procedure ListSymbolTable(Dest: TStrings);
|
---|
191 | var
|
---|
192 | i: Integer;
|
---|
193 | x: string;
|
---|
194 | begin
|
---|
195 | Dest.Clear;
|
---|
196 | CallV('ORWUX SYMTAB', [nil]);
|
---|
197 | i := 0;
|
---|
198 | with RPCBrokerV.Results do while i < Count do
|
---|
199 | begin
|
---|
200 | x := Strings[i] + '=';
|
---|
201 | Inc(i);
|
---|
202 | if i < Count then x := x + Strings[i];
|
---|
203 | Dest.Add(x);
|
---|
204 | Inc(i);
|
---|
205 | end;
|
---|
206 | end;
|
---|
207 |
|
---|
208 | function MScalar(const x: string): string;
|
---|
209 | begin
|
---|
210 | with RPCBrokerV do
|
---|
211 | begin
|
---|
212 | ClearParameters := True;
|
---|
213 | RemoteProcedure := 'XWB GET VARIABLE VALUE';
|
---|
214 | Param[0].Value := x;
|
---|
215 | Param[0].PType := reference;
|
---|
216 | CallBroker;
|
---|
217 | Result := Results[0];
|
---|
218 | end;
|
---|
219 | end;
|
---|
220 |
|
---|
221 | function ServerHasPatch(const x: string): Boolean;
|
---|
222 | begin
|
---|
223 | Result := sCallV('ORWU PATCH', [x]) = '1';
|
---|
224 | end;
|
---|
225 |
|
---|
226 | function ServerVersion(const Option, VerClient: string): string;
|
---|
227 | begin
|
---|
228 | Result := sCallV('ORWU VERSRV', [Option, VerClient]);
|
---|
229 | end;
|
---|
230 |
|
---|
231 | function PackageVersion(const Namespace: string): string;
|
---|
232 | begin
|
---|
233 | Result := sCallV('ORWU VERSION', [Namespace]);
|
---|
234 | end;
|
---|
235 |
|
---|
236 | function UserFontSize: integer;
|
---|
237 | begin
|
---|
238 | Result := StrToIntDef(sCallV('ORWCH LDFONT', [nil]),8);
|
---|
239 | If Result = 24 then Result := 18; // CQ #12322 removed 24 pt font
|
---|
240 | end;
|
---|
241 |
|
---|
242 | procedure LoadSizes;
|
---|
243 | var
|
---|
244 | i, p: Integer;
|
---|
245 | begin
|
---|
246 | uBounds := TStringList.Create;
|
---|
247 | uWidths := TStringList.Create;
|
---|
248 | uColumns := TStringList.Create;
|
---|
249 | CallV('ORWCH LOADALL', [nil]);
|
---|
250 | with RPCBrokerV do
|
---|
251 | begin
|
---|
252 | for i := 0 to Results.Count - 1 do // change '^' to '='
|
---|
253 | begin
|
---|
254 | p := Pos(U, Results[i]);
|
---|
255 | if p > 0 then Results[i] := Copy(Results[i], 1, p - 1) + '=' +
|
---|
256 | Copy(Results[i], p + 1, Length(Results[i]));
|
---|
257 | end;
|
---|
258 | ExtractItems(uBounds, RPCBrokerV.Results, 'Bounds');
|
---|
259 | ExtractItems(uWidths, RPCBrokerV.Results, 'Widths');
|
---|
260 | ExtractItems(uColumns, RPCBrokerV.Results, 'Columns');
|
---|
261 | end;
|
---|
262 | end;
|
---|
263 |
|
---|
264 | procedure SetShareNode(const DFN: string; AHandle: HWND); //*DFN*
|
---|
265 | begin
|
---|
266 | // sets node that allows other apps to see which patient is currently selected
|
---|
267 | sCallV('ORWPT SHARE', [DottedIPStr, IntToHex(AHandle, 8), DFN]);
|
---|
268 | end;
|
---|
269 |
|
---|
270 | procedure SetUserBounds(var AControl: TControl);
|
---|
271 | var
|
---|
272 | x: string;
|
---|
273 | begin
|
---|
274 | if uBounds = nil then LoadSizes;
|
---|
275 | x := AControl.Name;
|
---|
276 | if not (AControl is TForm) and (Assigned(AControl.Owner)) then x := AControl.Owner.Name + '.' + x;
|
---|
277 | x := uBounds.Values[x];
|
---|
278 | if (x = '0,0,0,0') and (AControl is TForm)
|
---|
279 | then TForm(AControl).WindowState := wsMaximized
|
---|
280 | else
|
---|
281 | begin
|
---|
282 | AControl.Left := HigherOf(StrToIntDef(Piece(x, ',', 1), AControl.Left), 0);
|
---|
283 | AControl.Top := HigherOf(StrToIntDef(Piece(x, ',', 2), AControl.Top), 0);
|
---|
284 | if Assigned( AControl.Parent ) then
|
---|
285 | begin
|
---|
286 | AControl.Width := LowerOf(StrToIntDef(Piece(x, ',', 3), AControl.Width), AControl.Parent.Width - AControl.Left);
|
---|
287 | AControl.Height := LowerOf(StrToIntDef(Piece(x, ',', 4), AControl.Height), AControl.Parent.Height - AControl.Top);
|
---|
288 | end
|
---|
289 | else
|
---|
290 | begin
|
---|
291 | AControl.Width := StrToIntDef(Piece(x, ',', 3), AControl.Width);
|
---|
292 | AControl.Height := StrToIntDef(Piece(x, ',', 4), AControl.Height);
|
---|
293 | end;
|
---|
294 | end;
|
---|
295 | //if (x = '0,0,' + IntToStr(Screen.Width) + ',' + IntToStr(Screen.Height)) and
|
---|
296 | // (AControl is TForm) then TForm(AControl).WindowState := wsMaximized;
|
---|
297 | end;
|
---|
298 |
|
---|
299 | procedure SetUserBounds2(AName: string; var v1, v2, v3, v4: integer);
|
---|
300 | var
|
---|
301 | x: string;
|
---|
302 | begin
|
---|
303 | if uBounds = nil then LoadSizes;
|
---|
304 | x := uBounds.Values[AName];
|
---|
305 | v1 := StrToIntDef(Piece(x, ',', 1), 0);
|
---|
306 | v2 := StrToIntDef(Piece(x, ',', 2), 0);
|
---|
307 | v3 := StrToIntDef(Piece(x, ',', 3), 0);
|
---|
308 | v4 := StrToIntDef(Piece(x, ',', 4), 0);
|
---|
309 | end;
|
---|
310 |
|
---|
311 |
|
---|
312 | procedure SetUserWidths(var AControl: TControl);
|
---|
313 | var
|
---|
314 | x: string;
|
---|
315 | begin
|
---|
316 | if uWidths = nil then LoadSizes;
|
---|
317 | x := AControl.Name;
|
---|
318 | if not (AControl is TForm) and (Assigned(AControl.Owner)) then x := AControl.Owner.Name + '.' + x;
|
---|
319 | x := uWidths.Values[x];
|
---|
320 | if Assigned (AControl.Parent) then
|
---|
321 | AControl.Width := LowerOf(StrToIntDef(x, AControl.Width), AControl.Parent.Width - AControl.Left)
|
---|
322 | else
|
---|
323 | AControl.Width := StrToIntDef(x, AControl.Width);
|
---|
324 | end;
|
---|
325 |
|
---|
326 | procedure SetUserColumns(var AControl: TControl);
|
---|
327 | var
|
---|
328 | x: string;
|
---|
329 | i, AWidth: Integer;
|
---|
330 | couldSet: boolean;
|
---|
331 | begin
|
---|
332 | couldSet := False;
|
---|
333 | if uColumns = nil then LoadSizes;
|
---|
334 | x := AControl.Name;
|
---|
335 | if not (AControl is TForm) and (Assigned(AControl.Owner)) then x := AControl.Owner.Name + '.' + x;
|
---|
336 | if AnsiCompareText(x,'frmOrders.hdrOrders')=0 then
|
---|
337 | couldSet := True;
|
---|
338 | x := uColumns.Values[x];
|
---|
339 | if AControl is THeaderControl then with THeaderControl(AControl) do
|
---|
340 | for i := 0 to Sections.Count - 1 do
|
---|
341 | begin
|
---|
342 | //Make sure all of the colmumns fit, even if it means scrunching the last ones.
|
---|
343 | AWidth := LowerOf(StrToIntDef(Piece(x, ',', i + 1), 0), HigherOf(ClientWidth - (Sections.Count - i)*5 - Sections.Items[i].Left, 5));
|
---|
344 | if AWidth > 0 then Sections.Items[i].Width := AWidth;
|
---|
345 | if couldSet and (i=0) and (AWidth>0) then
|
---|
346 | frmOrders.EvtColWidth := AWidth;
|
---|
347 | end;
|
---|
348 | if AControl is TCustomGrid then {nothing for now};
|
---|
349 | end;
|
---|
350 |
|
---|
351 | procedure SetUserString(StrName: string; var Str: string);
|
---|
352 | begin
|
---|
353 | Str := uColumns.Values[StrName];
|
---|
354 | end;
|
---|
355 |
|
---|
356 | procedure SaveUserBounds(AControl: TControl);
|
---|
357 | var
|
---|
358 | x: string;
|
---|
359 | NewHeight: integer;
|
---|
360 | begin
|
---|
361 | if (AControl is TForm) and (TForm(AControl).WindowState = wsMaximized) then
|
---|
362 | x := '0,0,0,0'
|
---|
363 | else
|
---|
364 | with AControl do
|
---|
365 | begin
|
---|
366 | //Done to remove the adjustment for Window XP style before saving the form size
|
---|
367 | NewHeight := Height - (GetSystemMetrics(SM_CYCAPTION) - 19);
|
---|
368 | x := IntToStr(Left) + ',' + IntToStr(Top) + ',' +
|
---|
369 | IntToStr(Width) + ',' + IntToStr(NewHeight);
|
---|
370 | end;
|
---|
371 | // CallV('ORWCH SAVESIZ', [AControl.Name, x]);
|
---|
372 | SizeHolder.SetSize(AControl.Name, x);
|
---|
373 | end;
|
---|
374 |
|
---|
375 | procedure SaveUserSizes(SizingList: TStringList);
|
---|
376 | begin
|
---|
377 | CallV('ORWCH SAVEALL', [SizingList]);
|
---|
378 | end;
|
---|
379 |
|
---|
380 | procedure SaveUserFontSize( FontSize: integer);
|
---|
381 | begin
|
---|
382 | CallV('ORWCH SAVFONT', [IntToStr(FontSize)]);
|
---|
383 | end;
|
---|
384 |
|
---|
385 | procedure SetFormPosition(AForm: TForm);
|
---|
386 | var
|
---|
387 | x: string;
|
---|
388 | Rect: TRect;
|
---|
389 | begin
|
---|
390 | // x := sCallV('ORWCH LOADSIZ', [AForm.Name]);
|
---|
391 | x := SizeHolder.GetSize(AForm.Name);
|
---|
392 | if x = '' then Exit; // allow default bounds to be passed in, else screen center?
|
---|
393 | if (x = '0,0,0,0') then
|
---|
394 | AForm.WindowState := wsMaximized
|
---|
395 | else
|
---|
396 | begin
|
---|
397 | AForm.SetBounds(StrToIntDef(Piece(x, ',', 1), AForm.Left),
|
---|
398 | StrToIntDef(Piece(x, ',', 2), AForm.Top),
|
---|
399 | StrToIntDef(Piece(x, ',', 3), AForm.Width),
|
---|
400 | StrToIntDef(Piece(x, ',', 4), AForm.Height));
|
---|
401 | Rect := AForm.BoundsRect;
|
---|
402 | ForceInsideWorkArea(Rect);
|
---|
403 | AForm.BoundsRect := Rect;
|
---|
404 | end;
|
---|
405 | end;
|
---|
406 |
|
---|
407 | function StrUserBounds(AControl: TControl): string;
|
---|
408 | var
|
---|
409 | x: string;
|
---|
410 | begin
|
---|
411 | x := AControl.Name;
|
---|
412 | if not (AControl is TForm) and (Assigned(AControl.Owner)) then x := AControl.Owner.Name + '.' + x;
|
---|
413 | with AControl do Result := 'B' + U + x + U + IntToStr(Left) + ',' + IntToStr(Top) + ',' +
|
---|
414 | IntToStr(Width) + ',' + IntToStr(Height);
|
---|
415 | if (AControl is TForm) and (TForm(AControl).WindowState = wsMaximized)
|
---|
416 | then Result := 'B' + U + x + U + '0,0,0,0';
|
---|
417 | end;
|
---|
418 |
|
---|
419 | function StrUserBounds2(AName: string; v1, v2, v3, v4: integer): string;
|
---|
420 | begin
|
---|
421 | Result := 'B' + U + AName + U + IntToStr(v1) + ',' + IntToStr(v2) + ',' +
|
---|
422 | IntToStr(v3) + ',' + IntToStr(v4);
|
---|
423 | end;
|
---|
424 |
|
---|
425 | function StrUserWidth(AControl: TControl): string;
|
---|
426 | var
|
---|
427 | x: string;
|
---|
428 | begin
|
---|
429 | x := AControl.Name;
|
---|
430 | if not (AControl is TForm) and (Assigned(AControl.Owner)) then x := AControl.Owner.Name + '.' + x;
|
---|
431 | with AControl do Result := 'W' + U + x + U + IntToStr(Width);
|
---|
432 | end;
|
---|
433 |
|
---|
434 | function StrUserColumns(AControl: TControl): string;
|
---|
435 | var
|
---|
436 | x: string;
|
---|
437 | i: Integer;
|
---|
438 | shouldSave: boolean;
|
---|
439 | begin
|
---|
440 | shouldSave := False;
|
---|
441 | x := AControl.Name;
|
---|
442 | if not (AControl is TForm) and (Assigned(AControl.Owner)) then x := AControl.Owner.Name + '.' + x;
|
---|
443 | if AnsiCompareText(x,'frmOrders.hdrOrders') = 0 then
|
---|
444 | shouldSave := True;
|
---|
445 | Result := 'C' + U + x + U;
|
---|
446 | if AControl is THeaderControl then with THeaderControl(AControl) do
|
---|
447 | for i := 0 to Sections.Count - 1 do
|
---|
448 | begin
|
---|
449 | if shouldSave and (i = 0) then
|
---|
450 | Result := Result + IntToStr(frmOrders.EvtColWidth) + ','
|
---|
451 | else
|
---|
452 | Result := Result + IntToStr(Sections.Items[i].Width) + ',';
|
---|
453 | end;
|
---|
454 | if AControl is TCustomGrid then {nothing for now};
|
---|
455 | if CharAt(Result, Length(Result)) = ',' then Result := Copy(Result, 1, Length(Result) - 1);
|
---|
456 | end;
|
---|
457 |
|
---|
458 | function StrUserString(StrName: string; Str: string): string;
|
---|
459 | begin
|
---|
460 | Result := 'C' + U + StrName + U + Str;
|
---|
461 | end;
|
---|
462 |
|
---|
463 | { TSizeHolder }
|
---|
464 |
|
---|
465 | procedure TSizeHolder.AddSizesToStrList(theList: TStringList);
|
---|
466 | {Adds all the Sizes in the TSizeHolder Object to theList String list parameter}
|
---|
467 | var
|
---|
468 | i: integer;
|
---|
469 | begin
|
---|
470 | for i := 0 to FNameList.Count-1 do
|
---|
471 | theList.Add('B' + U + FNameList[i] + U + FSizeList[i]);
|
---|
472 | end;
|
---|
473 |
|
---|
474 | constructor TSizeHolder.Create;
|
---|
475 | begin
|
---|
476 | inherited;
|
---|
477 | FNameList := TStringList.Create;
|
---|
478 | FSizeList := TStringList.Create;
|
---|
479 | end;
|
---|
480 |
|
---|
481 |
|
---|
482 | destructor TSizeHolder.Destroy;
|
---|
483 | begin
|
---|
484 | FNameList.Free;
|
---|
485 | FSizeList.Free;
|
---|
486 | inherited;
|
---|
487 | end;
|
---|
488 |
|
---|
489 | function TSizeHolder.GetSize(AName: String): String;
|
---|
490 | {Fuctions returns a String of the Size(s) Of the Name parameter passed,
|
---|
491 | if the Size(s) are already loaded into the object it will return those,
|
---|
492 | otherwise it will make the apropriate RPC call to LOADSIZ}
|
---|
493 | var
|
---|
494 | rSizeVal: String; //return Size value
|
---|
495 | nameIndex: integer;
|
---|
496 | begin
|
---|
497 | rSizeVal := '';
|
---|
498 | nameIndex := FNameList.IndexOf(AName);
|
---|
499 | if nameIndex = -1 then //Currently Not in the NameList
|
---|
500 | begin
|
---|
501 | rSizeVal := sCallV('ORWCH LOADSIZ', [AName]);
|
---|
502 | if rSizeVal <> '' then
|
---|
503 | begin
|
---|
504 | FNameList.Add(AName);
|
---|
505 | FSizeList.Add(rSizeVal);
|
---|
506 | end;
|
---|
507 | end
|
---|
508 | else //Currently is in the NameList
|
---|
509 | rSizeVal := FSizeList[nameIndex];
|
---|
510 | result := rSizeVal;
|
---|
511 | end;
|
---|
512 |
|
---|
513 | procedure TSizeHolder.SetSize(AName, ASize: String);
|
---|
514 | {Store the Size(s) Of the ASize parameter passed, Associate it with the AName
|
---|
515 | Parameter. This only stores the sizes in the objects member variables.
|
---|
516 | to Store on the MUMPS Database call SendSizesToDB()}
|
---|
517 | var
|
---|
518 | nameIndex: integer;
|
---|
519 | begin
|
---|
520 | nameIndex := FNameList.IndexOf(AName);
|
---|
521 | if nameIndex = -1 then //Currently Not in the NameList
|
---|
522 | begin
|
---|
523 | FNameList.Add(AName);
|
---|
524 | FSizeList.Add(ASize);
|
---|
525 | end
|
---|
526 | else //Currently is in the NameList
|
---|
527 | FSizeList[nameIndex] := ASize;
|
---|
528 | end;
|
---|
529 |
|
---|
530 | initialization
|
---|
531 | // nothing for now
|
---|
532 |
|
---|
533 | finalization
|
---|
534 | if uBounds <> nil then uBounds.Free;
|
---|
535 | if uWidths <> nil then uWidths.Free;
|
---|
536 | if uColumns <> nil then uColumns.Free;
|
---|
537 | if assigned(uToolMenuItems) then
|
---|
538 | FreeAndNil(uToolMenuItems);
|
---|
539 |
|
---|
540 | end.
|
---|