-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunrec.pas
763 lines (674 loc) · 23.1 KB
/
runrec.pas
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
// **
// * Census 2, a NONMEM project manager
// *
// * Copyright 2017, Justin J Wilkins.
// *
// * This is free software; you can redistribute it and/or modify it
// * under the terms of the GNU Lesser General Public License as
// * published by the Free Software Foundation; either version 2.1 of
// * the License, or (at your option) any later version.
// *
// * This software is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// * Lesser General Public License for more details.
// *
// * You should have received a copy of the GNU Lesser General Public
// * License along with this software; if not, write to the Free
// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
// */
unit runrec;
{$mode delphi}
interface
uses
Classes, SysUtils, FileUtil, Ipfilebroker, Forms, Controls, Graphics, math,
Dialogs, ExtCtrls, StdCtrls, DBGrids, ComCtrls, db, ZDataset, ZConnection;
type
{ TfrmRunRec }
TfrmRunRec = class(TForm)
btnCancel: TButton;
btnExport: TButton;
chkSigDig: TCheckBox;
chkMinimization: TCheckBox;
chkWarnings: TCheckBox;
chkCondNo: TCheckBox;
chk1: TCheckBox;
chk2: TCheckBox;
chk3: TCheckBox;
chk5: TCheckBox;
chk4: TCheckBox;
chkAll: TCheckBox;
dsRuns: TDatasource;
dlgSave: TSaveDialog;
grdRunRec: TDBGrid;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
img1: TImage;
img2: TImage;
img3: TImage;
img4: TImage;
img5: TImage;
ipProvider: TIpFileDataProvider;
Label1: TLabel;
pnlLatex: TPanel;
pnlRunRec: TPanel;
qryRuns: TZReadOnlyQuery;
qryRunsComment: TMemoField;
qryRunsComments: TMemoField;
qryRunsConditionNumber: TFloatField;
qryRunsdOFV: TFloatField;
qryRunsFnEvals: TLongintField;
qryRunsiRunNo: TLongintField;
qryRunsKeyRun: TLongintField;
qryRunsMinShort: TMemoField;
qryRunsOFV: TFloatField;
qryRunsParentNo: TMemoField;
qryRunsRunNo: TMemoField;
qryRunsSigDigits: TFloatField;
qryRunsWarnings: TMemoField;
rgOutput: TRadioGroup;
stBar: TStatusBar;
procedure FormCreate(Sender: TObject);
procedure rgOutputClick(Sender: TObject);
function Round2(const Number: extended; const Places: longint): extended;
procedure btnCancelClick(Sender: TObject);
procedure btnExportClick(Sender: TObject);
procedure chk1Change(Sender: TObject);
procedure chk2Change(Sender: TObject);
procedure chk3Change(Sender: TObject);
procedure chk4Change(Sender: TObject);
procedure chk5Change(Sender: TObject);
procedure chkAllChange(Sender: TObject);
procedure chkCondNoChange(Sender: TObject);
procedure chkMinimizationChange(Sender: TObject);
procedure chkSigDigChange(Sender: TObject);
procedure chkWarningsChange(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure qryRunsCommentGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsCommentsGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsConditionNumberGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsdOFVGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsFnEvalsGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsMinShortGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsOFVGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsParentNoGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsRunNoGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsSigDigitsGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure qryRunsWarningsGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
procedure UpdateRunRec;
private
{ private declarations }
public
{ public declarations }
end;
var
frmRunRec: TfrmRunRec;
const
{$ifdef windows}
strOS = 'Windows';
strDelim = '\'
{$endif}
{$ifdef unix}
strOS = 'Linux';
strDelim = '/'
{$endif};
implementation
uses main;
{$R *.lfm}
{ TfrmRunRec }
function TfrmRunRec.Round2(const Number: extended; const Places: longint): extended;
var
t: extended;
begin
t := power(10, places);
Round2 := round(Number*t)/t;
end;
procedure TfrmRunRec.rgOutputClick(Sender: TObject);
begin
if rgOutput.ItemIndex = 2 then
pnlLatex.Visible := True
else
pnlLatex.Visible := False;
end;
procedure TfrmRunRec.FormCreate(Sender: TObject);
begin
{$ifdef windows}
Label1.Font.Size := 0;
Label1.Height := 112;
pnlLatex.Height := 128;
{$endif}
{$ifdef darwin}
Label1.Font.Size := -11;
Label1.Height := 96;
pnlLatex.Height := 120;
{$endif}
end;
procedure TfrmRunRec.chk1Change(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.btnCancelClick(Sender: TObject);
begin
qryRuns.Active := False;
Close;
end;
procedure TfrmRunRec.btnExportClick(Sender: TObject);
var
strOut, txtUser: string;
lstOut: TStringList;
n, m, p: Integer;
begin
lstOut := TStringList.Create;
strOut := '';
if strOS = 'Linux' then
txtUser := GetEnvironmentVariable('USER');
if strOS = 'Windows' then
txtUser := GetEnvironmentVariable('USERNAME');
// CSV
if rgOutput.ItemIndex = 0 then
begin
dlgSave.Filter := 'Comma-separated values (*.csv)|*.csv';
dlgSave.Title := 'Export to CSV...';
dlgSave.DefaultExt := '.csv';
try
qryRuns.First;
if dlgSave.Execute then
begin
strOut := '"Run No"' + DefaultFormatSettings.ListSeparator +
'"Comment"' + DefaultFormatSettings.ListSeparator +
'"OFV"' + DefaultFormatSettings.ListSeparator +
'"dOFV"' + DefaultFormatSettings.ListSeparator +
'"Parent"';
if chkMinimization.Checked then
strOut := strOut + DefaultFormatSettings.ListSeparator + '"Minimization"';
if chkWarnings.Checked then
strOut := strOut + DefaultFormatSettings.ListSeparator + '"Warnings"';
if chkCondNo.Checked then
strOut := strOut + DefaultFormatSettings.ListSeparator + '"Condition No"';
if chkSigDig.Checked then
strOut := strOut + DefaultFormatSettings.ListSeparator + '"Sig Digits"';
lstOut.Add(strOut);
while not qryRuns.EOF do
begin
strOut := '"' + qryRuns.FieldByName('RunNo').asString + '"' + DefaultFormatSettings.ListSeparator + '"' +
qryRuns.FieldByName('Comment').AsString + '"' + DefaultFormatSettings.ListSeparator + '"' +
qryRuns.FieldByName('OFV').asString + '"' + DefaultFormatSettings.ListSeparator + '"' +
qryRuns.FieldByName('dOFV').asString + '"' + DefaultFormatSettings.ListSeparator + '"' +
qryRuns.FieldByName('ParentNo').asString + '"';
if chkMinimization.Checked then
strOut := strOut + DefaultFormatSettings.ListSeparator + '"' + qryRuns.FieldByName('MinShort').asString + '"';
if chkWarnings.Checked then
strOut := strOut + DefaultFormatSettings.ListSeparator + '"' + qryRuns.FieldByName('Warnings').asString + '"';
if chkCondNo.Checked then
strOut := strOut + DefaultFormatSettings.ListSeparator + '"' + qryRuns.FieldByName('ConditionNumber').asString + '"';
if chkSigDig.Checked then
strOut := strOut + DefaultFormatSettings.ListSeparator + '"' + qryRuns.FieldByName('SigDigits').asString + '"';
lstOut.Add(strOut);
qryRuns.Next;
end;
lstOut.SaveToFile(dlgSave.FileName);
end;
finally
qryRuns.First;
end;
end;
// HTML
if rgOutput.ItemIndex = 1 then
begin
dlgSave.Filter := 'HTML files (*.html)|*.html';
dlgSave.Title := 'Export to HTML...';
dlgSave.DefaultExt := '.html';
with lstOut do
begin
Add('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
Add('<HTML>');
Add('<HEAD>');
Add('<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">');
Add('<TITLE></TITLE>');
Add('<META NAME="GENERATOR" CONTENT="Census 2.0">');
Add('<META NAME="AUTHOR" CONTENT="' + txtUser + '">');
Add('<META NAME="CREATED" CONTENT="' + IntToStr(Trunc((Now - EncodeDate(1970, 1 ,1)) * 24 * 60 * 60)) + '">');
Add('<STYLE TYPE="text/css">');
Add(' <!--');
Add(' @page { margin: 0.79in }');
Add(' P { margin-bottom: 0.08in }');
Add(' TD P { margin-bottom: 0in }');
Add(' TH P { margin-bottom: 0in }');
Add(' --> ');
Add('</STYLE>');
Add('</HEAD>');
Add('<BODY LANG="en" DIR="LTR"> ');
Add('<TABLE WIDTH=100% BORDER=2 BORDERCOLOR="#000000" CELLPADDING=2 CELLSPACING=0 FRAME=HSIDES RULES=GROUPS>');
p := 5;
if chkMinimization.Checked then
p := p + 1;
if chkWarnings.Checked then
p := p + 1;
if chkSigDig.Checked then
p := p + 1;
if chkCondNo.Checked then
p := p + 1;
for n := 1 to p do
Add(' <COL />');
Add('<TBODY>');
Add(' <TR VALIGN=TOP>');
for n := 1 to 5 do
begin
Add(' <TH WIDTH=' + IntToStr(Round((1/ p) * 100)) + ' %>');
case n of
1: Add(' <P ALIGN=LEFT>Run No</P>');
2: Add(' <P ALIGN=LEFT>Comment</P>');
3: Add(' <P ALIGN=LEFT>OFV</P>');
4: Add(' <P ALIGN=LEFT>dOFV</P>');
5: Add(' <P ALIGN=LEFT>Parent</P>');
end;
Add(' </TH>');
end;
if chkMinimization.Checked then
begin
Add(' <TH WIDTH=' + IntToStr(Round((1/ p) * 100)) + ' %>');
Add(' <P ALIGN=LEFT>Minimization</P>');
Add(' </TH>');
end;
if chkWarnings.Checked then
begin
Add(' <TH WIDTH=' + IntToStr(Round((1/ p) * 100)) + ' %>');
Add(' <P ALIGN=LEFT>Warnings</P>');
Add(' </TH>');
end;
if chkSigDig.Checked then
begin
Add(' <TH WIDTH=' + IntToStr(Round((1/ p) * 100)) + ' %>');
Add(' <P ALIGN=LEFT>Sig Digits</P>');
Add(' </TH>');
end;
if chkCondNo.Checked then
begin
Add(' <TH WIDTH=' + IntToStr(Round((1/ p) * 100)) + ' %>');
Add(' <P ALIGN=LEFT>Cond No</P>');
Add(' </TH>');
end;
Add(' </TR>');
Add('</TBODY>');
Add('<TBODY>');
end;
try
qryRuns.First;
if dlgSave.Execute then
begin
for n := 0 to qryRuns.RecordCount - 1 do
begin
with lstOut do
begin
Add(' <TR VALIGN=TOP>');
for m := 1 to 5 do
begin
case m of
1: begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('RunNo').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + qryRuns.FieldByName('RunNo').AsString + '</P> ');
Add(' </TD>');
end;
2: begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('Comment').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + qryRuns.FieldByName('Comment').AsString + '</P> ');
Add(' </TD>');
end;
3: begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('OFV').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + FloatToStrF(qryRuns.FieldByName('OFV').AsFloat, ffGeneral, 8, 4) + '</P> ');
Add(' </TD>');
end;
4: begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('dOFV').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + qryRuns.FieldByName('dOFV').AsString + '</P> ');
Add(' </TD>');
end;
5: begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('ParentNo').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + qryRuns.FieldByName('ParentNo').AsString + '</P> ');
Add(' </TD>');
end;
end;
end;
if chkMinimization.Checked then
begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('MinShort').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + qryRuns.FieldByName('MinShort').AsString + '</P> ');
Add(' </TD>');
end;
if chkWarnings.Checked then
begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('Warnings').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + qryRuns.FieldByName('Warnings').AsString + '</P> ');
Add(' </TD>');
end;
if chkSigDig.Checked then
begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('SigDigits').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + qryRuns.FieldByName('SigDigits').AsString + '</P> ');
Add(' </TD>');
end;
if chkCondNo.Checked then
begin
Add(' <TD WIDTH=' + IntToStr(Round((1/p) * 100)) + '% SDVAL="' + qryRuns.FieldByName('ConditionNumber').AsString + '" SDNUM="9;">');
Add(' <P ALIGN=LEFT>' + FloatToStr(Round2(qryRuns.FieldByName('ConditionNumber').AsFloat, 2)) + '</P> ');
Add(' </TD>');
end;
Add(' </TR>');
qryRuns.Next;
end;
end;
lstOut.Add('</TBODY>');
lstOut.Add('</TABLE>');
lstOut.Add('<P STYLE="margin-bottom: 0in"><BR>');
lstOut.Add('</P>');
lstOut.Add('</BODY>');
lstOut.Add('</HTML>');
lstOut.SaveToFile(dlgSave.FileName);
end;
finally
qryRuns.First;
end;
end;
// LaTeX
if rgOutput.ItemIndex = 2 then
begin
dlgSave.Filter := 'LaTeX files (*.tex)|*.tex';
dlgSave.Title := 'Export to LaTeX...';
dlgSave.DefaultExt := '.tex';
with lstOut do
begin
Add('\documentclass[12pt]{article}');
Add('\usepackage{ctable}');
Add('\usepackage{relsize}');
Add('\begin{document}');
Add('');
Add('\ctable[');
Add(' pos=H,');
Add(' doinside=\smaller,');
Add(' label = tab:censusrunrecord,');
Add(' width=\textwidth,');
Add(' caption = Summary of key runs.');
end;
strOut := ']{l>{\raggedright}p{4cm}lll';
p := 5;
if chkMinimization.Checked then
begin
p := p + 1;
strOut := strOut + 'l';
end;
if chkWarnings.Checked then
begin
p := p + 1;
strOut := strOut + '>{\raggedright}p{4cm}'
end;
if chkSigDig.Checked then
begin
p := p + 1;
strOut := strOut + 'l';
end;
if chkCondNo.Checked then
begin
p := p + 1;
strOut := strOut + 'l';
end;
strOut := strOut + '}{';
//footnotes
strOut := strOut + '\tnote[a]{Objective function value}';
strOut := strOut + '\tnote[b]{Change in objective function value}';
strOut := strOut + '}{ ';
lstOut.Add(strOut);
lstOut.Add('\FL');
strOut := '';
for n := 1 to 5 do
begin
case n of
1: strOut := strOut + '\textbf{Run No}';
2: strOut := strOut + '\textbf{Comment}';
3: strOut := strOut + '\textbf{OFV}\tmark[a]';
4: strOut := strOut + '\textbf{$\Delta$OFV}\tmark[b]';
5: strOut := strOut + '\textbf{Parent}';
end;
if n < 5 then
strOut := strOut + ' & ';
end;
if chkMinimization.Checked then
strOut := strOut + ' & \textbf{Minimization}';
if chkWarnings.Checked then
strOut := strOut + ' & \textbf{Warnings}';
if chkSigDig.Checked then
strOut := strOut + ' & \textbf{Sig Digits}';
if chkCondNo.Checked then
strOut := strOut + ' & \textbf{Condition No}';
lstOut.Add(strOut);
lstOut.Add('\ML');
strOut := '';
if dlgSave.Execute then
begin
try
for n := 0 to qryRuns.RecordCount - 1 do
begin
for m := 1 to 5 do
begin
case m of
1: strOut := strOut + qryRuns.FieldByName('RunNo').AsString;
2: strOut := strOut + qryRuns.FieldByName('Comment').AsString;
3: strOut := strOut + FloatToStrF(qryRuns.FieldByName('OFV').AsFloat, ffGeneral, 8, 4);
4: strOut := strOut + qryRuns.FieldByName('dOFV').AsString;
5: strOut := strOut + qryRuns.FieldByName('ParentNo').AsString;
end;
if m < 5 then
strOut := strOut + ' & ';
end;
if chkMinimization.Checked then
strOut := strOut + ' & ' + qryRuns.FieldByName('MinShort').AsString;
if chkWarnings.Checked then
strOut := strOut + ' & ' + qryRuns.FieldByName('Warnings').AsString;
if chkSigDig.Checked then
strOut := strOut + ' & ' + qryRuns.FieldByName('SigDigits').AsString;
if chkCondNo.Checked then
strOut := strOut + ' & ' + FloatToStr(Round2(qryRuns.FieldByName('ConditionNumber').AsFloat, 2));
if n < qryRuns.RecordCount - 1 then
strOut := strOut + '\NN'
else
strOut := strOut + '\LL';
lstOut.Add(strOut);
strOut := '';
qryRuns.Next;
end;
finally
lstOut.Add('}');
lstOut.Add('\end{document}');
qryRuns.First;
lstOut.SaveToFile(dlgSave.FileName);
end;
end;
end;
lstOut.Free;
end;
procedure TfrmRunRec.chk2Change(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.chk3Change(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.chk4Change(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.chk5Change(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.chkAllChange(Sender: TObject);
begin
if chkAll.Checked then
begin
chk1.Enabled := False;
chk2.Enabled := False;
chk3.Enabled := False;
chk4.Enabled := False;
chk5.Enabled := False;
end
else
begin
chk1.Enabled := True;
chk2.Enabled := True;
chk3.Enabled := True;
chk4.Enabled := True;
chk5.Enabled := True;
end;
UpdateRunRec;
end;
procedure TfrmRunRec.chkCondNoChange(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.chkMinimizationChange(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.chkSigDigChange(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.chkWarningsChange(Sender: TObject);
begin
UpdateRunRec;
end;
procedure TfrmRunRec.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
CloseAction := caFree;
frmRunRec := nil;
end;
procedure TfrmRunRec.qryRunsCommentGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsComment.AsString, 1, 250);
end;
procedure TfrmRunRec.qryRunsCommentsGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsComments.AsString, 1, 250);
end;
procedure TfrmRunRec.qryRunsConditionNumberGetText(Sender: TField;
var aText: string; DisplayText: Boolean);
begin
aText := FloatToStrF(qryRunsOFV.Value, ffGeneral, 8, 4);
end;
procedure TfrmRunRec.qryRunsdOFVGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsdOFV.AsString, 1, 50);
end;
procedure TfrmRunRec.qryRunsFnEvalsGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsFnEvals.AsString, 1, 50);
end;
procedure TfrmRunRec.qryRunsMinShortGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsMinShort.AsString, 1, 250);
end;
procedure TfrmRunRec.qryRunsOFVGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := FloatToStrF(qryRunsOFV.Value, ffGeneral, 8, 4);
end;
procedure TfrmRunRec.qryRunsParentNoGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsParentNo.AsString, 1, 50);
end;
procedure TfrmRunRec.qryRunsRunNoGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsRunNo.AsString, 1, 50);
end;
procedure TfrmRunRec.qryRunsSigDigitsGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsSigDigits.AsString, 1, 50);
end;
procedure TfrmRunRec.qryRunsWarningsGetText(Sender: TField; var aText: string;
DisplayText: Boolean);
begin
aText := Copy(qryRunsWarnings.AsString, 1, 250);
end;
procedure TfrmRunRec.UpdateRunRec;
var
strIn: string;
begin
strIn := '';
if chk1.Checked then
strIn := strIn + '1,';
if chk2.Checked then
strIn := strIn + '2,';
if chk3.Checked then
strIn := strIn + '3,';
if chk4.Checked then
strIn := strIn + '4,';
if chk5.Checked then
strIn := strIn + '5,';
if Length(strIn) > 0 then
strIn := Copy(strIn, 1, Length(strIn)-1); // drop trailing comma
//ShowMessage(strIn);
// fields
if chkWarnings.Checked then
grdRunRec.Columns.Items[6].Width := 250
else
grdRunRec.Columns.Items[6].Width := 0;
if chkMinimization.Checked then
grdRunRec.Columns.Items[5].Width := 150
else
grdRunRec.Columns.Items[5].Width := 0;
if chkSigDig.Checked then
grdRunRec.Columns.Items[7].Width := 96
else
grdRunRec.Columns.Items[7].Width := 0;
if chkCondNo.Checked then
grdRunRec.Columns.Items[8].Width := 96
else
grdRunRec.Columns.Items[8].Width := 0;
grdRunRec.Repaint;
if (Length(strIn) > 0) or (chkAll.Checked) then
with qryRuns do
begin
Active := False;
SQL.Clear;
SQL.Add('SELECT RunNo, Comment, Comments, OFV, dOFV, ParentNo, Warnings, ConditionNumber, MinShort, FnEvals, SigDigits, iRunNo, KeyRun');
SQL.Add('FROM runs');
if (chkAll.Checked = False) and (Length(strIn) > 0) then
SQL.Add('WHERE KeyRun IN (' + strIn + ')');
SQL.Add('ORDER BY iRunNo;');
Active := True;
end
else
qryRuns.Active := False;
if qryRuns.Active then
begin
if qryRuns.RecordCount > 0 then
stBar.Panels[0].Text := IntToStr(qryRuns.RecordCount) + ' runs selected'
else
stBar.Panels[0].Text := 'No runs selected';
end
else
stBar.Panels[0].Text := 'No runs selected';
end;
end.