-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUWWMultiForm.pas
More file actions
758 lines (681 loc) · 18.4 KB
/
UWWMultiForm.pas
File metadata and controls
758 lines (681 loc) · 18.4 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
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
unit UWWMultiForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
UBasicMultiForm, StdCtrls, Grids, Cologrid, ExtCtrls, JLLabel,zLogGlobal;
const testCQWW = $03;
MAXCQZONE = 40;
testIARU = $09;
testDXCCWWZone = $05;
type
TCountry = class
Country : string[40]; {JA, KH6 etc}
CountryName : string[40]; {Japan, Hawaii, etc}
Zone : integer;
Continent : string[3];
Worked : array[b19..HiBand] of boolean;
GridIndex : integer; // where it is listed in the Grid (row)
constructor Create;
function Summary : string;
function Summary2 : string;
function JustInfo : string; // returns cty name, px and continent
end;
TCountryList = class
List : TList;
constructor Create;
destructor Destroy; override;
end;
TPrefix = class
Prefix : string[12];
Index : integer;
Length : integer;
OvrZone : integer; // override zone
OvrContinent : string[3]; // override continent
constructor Create;
end;
TPrefixList = class
List : TList;
constructor Create;
destructor Destroy; override;
end;
type
TWWMultiForm = class(TBasicMultiForm)
Panel: TPanel;
RotateLabel1: TRotateLabel;
RotateLabel2: TRotateLabel;
RotateLabel3: TRotateLabel;
RotateLabel4: TRotateLabel;
RotateLabel5: TRotateLabel;
RotateLabel6: TRotateLabel;
SortBy: TRadioGroup;
Grid: TMgrid;
Panel1: TPanel;
Button1: TButton;
GoButton: TButton;
Edit1: TEdit;
cbStayOnTop: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure SortByClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure GoButtonClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure cbStayOnTopClick(Sender: TObject);
procedure GridSetting(ARow, Acol: Integer; var Fcolor: Integer;
var Bold, Italic, underline: Boolean);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
GridReverse : array[0..500] of integer; {pointer from grid row to countrylist index}
CountryList : TCountryList;
PrefixList : TPrefixList;
Zone : array[b19..HiBand, 1..MAXCQZONE] of boolean;
procedure ResetBand(B : TBand); override;
procedure Reset; override;
procedure Add(aQSO : TQSO); override;
procedure SortDefault;
procedure SortZone;
//procedure RecalcBand(B : TBand); override;
procedure RecalcAll; override;
{ Public declarations }
end;
procedure LoadCTY_DAT(TEST : byte; var L : TCountryList; var PL : TPrefixList);
procedure LoadCountryDataFromFile(filename : string; var L : TCountryList; var PL : TPrefixList);
var
WWMultiForm: TWWMultiForm;
implementation
uses UWWZone, UServerForm;
{$R *.DFM}
procedure LoadCTY_DAT(TEST : byte; var L : TCountryList; var PL : TPrefixList);
var f : textfile;
str, temp, temp2 : string;
C : TCountry;
P : TPrefix;
i, mii, j, k, m : integer;
begin
System.assign(f, 'CTY.DAT');
try
System.reset(f);
except
on EFOpenError do
begin
exit;
end;
end;
//readln(f, str);
C := TCountry.Create;
C.CountryName := 'Unknown';
L.List.Add(C);
while not(eof(f)) do
begin
readln(f, str);
if (Pos('*', str) > 0) and (TEST <> testCQWW) then //Cty only for CQWW
begin
repeat
readln(f, str);
until (eof(f)) or (pos(':',str) > 0);
if eof(f) then
exit;
end;
C := TCountry.Create;
i := Pos(':',str);
if i > 0 then
begin
C.CountryName := copy(str,1,i-1);
Delete(str, 1, i);
str := TrimLeft(str);
end;
i := Pos(':',str);
if i > 0 then
begin
temp := copy(str,1,i-1);
try
j := StrToInt(temp);
except
on EConvertError do
j := 0;
end;
if (TEST in [testCQWW, testDXCCWWZone]) then
C.Zone := j;
Delete(str, 1, i);
str := TrimLeft(str);
end;
i := Pos(':',str);
if i > 0 then
begin
temp := copy(str,1,i-1);
try
j := StrToInt(temp);
except
on EConvertError do
j := 0;
end;
if (TEST = testIARU) then
C.Zone := j;
Delete(str, 1, i);
str := TrimLeft(str);
end;
i := Pos(':',str);
if i > 0 then
begin
temp := copy(str,1,i-1);
if Pos(temp+';', 'AS;AF;EU;NA;SA;OC;') > 0 then
C.Continent := temp;
Delete(str, 1, i);
str := TrimLeft(str);
end;
i := Pos(':',str); // latitude
if i > 0 then
begin
Delete(str, 1, i);
str := TrimLeft(str);
end;
i := Pos(':',str); // longitude
if i > 0 then
begin
Delete(str, 1, i);
str := TrimLeft(str);
end;
i := Pos(':',str); // utc offset
if i > 0 then
begin
Delete(str, 1, i);
str := TrimLeft(str);
end;
i := Pos(':',str);
if i > 0 then
begin
temp := copy(str, 1, i-1);
if temp[1] = '*' then
Delete(temp,1,1);
C.Country := temp;
//Delete(str, 1, i);
//str := TrimLeft(str);
end;
L.List.Add(C);
i := L.List.Count -1;
C.GridIndex := i;
repeat
mii:=1;
readln(f,str);
str := TrimLeft(str);
repeat
temp:='';
repeat
temp:=temp+str[mii];
inc(mii)
until (str[mii]=',') or (str[mii]=';') or (mii>length(str));
P := TPrefix.Create;
if (pos('(', temp) > 0) then
begin
j := pos('(',temp);
k := pos(')',temp);
if k > j+1 then
begin
temp2 := copy(temp, j+1, k-j-1);
try
m := StrToInt(temp2);
except
on EConvertError do
m := 0;
end;
if (m > 0) and (TEST in [testCQWW, testDXCCWWZone]) then
P.OvrZone := m;
end;
Delete(temp,j,k-j+1);
end;
if (pos('[', temp) > 0) then
begin
j := pos('[',temp);
k := pos(']',temp);
if k > j+1 then
begin
temp2 := copy(temp, j+1, k-j-1);
try
m := StrToInt(temp2);
except
on EConvertError do
m := 0;
end;
if (m > 0) and (TEST=testIARU) then
P.OvrZone := m;
end;
Delete(temp,j,k-j+1);
end;
if (pos('{', temp) > 0) then
begin
j := pos('{',temp);
k := pos('}',temp);
if k > j+1 then
begin
temp2 := copy(temp, j+1, k-j-1);
if Pos(temp2+';', 'AS;AF;EU;NA;SA;OC;') > 0 then
P.OvrContinent := temp2;
end;
Delete(temp,j,k-j+1);
end;
if (pos('<', temp) > 0) then // lat, long override. ignore
begin
j := pos('<',temp);
k := pos('>',temp);
Delete(temp,j,k-j+1);
end;
P.Prefix := temp;
P.Index := i;
P.Length := length(temp);
j := 0;
if PL.List.Count > 0 then
for j := 0 to PL.List.Count-1 do
begin
if TPrefix(PL.List[j]).Length <= P.Length then
break;
end;
PL.List.Insert(j, P);
inc(mii);
until (mii >= Length(str)+1);
until str[mii-1]=';';
end;
end;
procedure LoadCountryDataFromFile(filename : string; var L : TCountryList; var PL : TPrefixList);
var f : textfile;
str, temp : string;
C : TCountry;
P : TPrefix;
i, mii, j : integer;
begin
System.assign(f, filename);
try
System.reset(f);
except
on EFOpenError do
begin
exit;
end;
end;
readln(f, str);
C := TCountry.Create;
C.CountryName := 'Unknown';
L.List.Add(C);
while not(eof(f)) do
begin
readln(f, str);
if Pos('end of file', LowerCase(str))>0 then break;
C := TCountry.Create;
C.CountryName := TrimRight(copy(str,1,26));
temp := TrimLeft(TrimRight(copy(str,27,2)));
try
i := StrToInt(temp)
except
on EConvertError do
i := 0;
end;
if (i < 0) or (i > 90{maxzone}) then
i := 0;
C.Zone := i;
C.Country := TrimRight(copy(str,32,7));
case C.Zone of
1..8 : C.Continent := 'NA';
9..13 : C.Continent := 'SA';
14..16,40 : C.Continent := 'EU';
17..26 : C.Continent := 'AS';
27..32 : C.Continent := 'OC';
33..39 : C.Continent := 'AF';
end;
if str[39] in ['A','O','E'] then
begin
temp:=str[39]+str[40];
if temp='AS' then C.Continent := 'AS';
if temp='AN' then C.Continent := 'AN';
if temp='AF' then C.Continent := 'AF';
if temp='EU' then C.Continent := 'EU';
if temp='OC' then C.Continent := 'OC';
if temp='NA' then C.Continent := 'NA';
if temp='SA' then C.Continent := 'SA';
end;
L.List.Add(C);
i := L.List.Count -1;
C.GridIndex := i;
repeat
mii:=3;
readln(f,str);
repeat
temp:='';
repeat
temp:=temp+str[mii];
inc(mii)
until (str[mii]=',') or (str[mii]=';');
P := TPrefix.Create;
P.Prefix := temp;
P.Index := i;
P.Length := length(temp);
j := 0;
if PL.List.Count > 0 then
for j := 0 to PL.List.Count-1 do
begin
if TPrefix(PL.List[j]).Length <= P.Length then
break;
end;
PL.List.Insert(j, P);
inc(mii);
until mii=Length(str)+1;
until str[mii-1]=';';
end;
end;
constructor TCountryList.Create;
begin
List := TList.Create;
end;
destructor TCountryList.Destroy;
var i : integer;
begin
List.Pack;
for i := 0 to List.Count-1 do
TCountry(List[i]).Free;
List.Free;
end;
function TCountry.Summary : string;
var temp : string;
B : TBand;
begin
if CountryName = 'Unknown' then
begin
Result := 'Unknown';
exit;
end;
temp := '';
temp := FillRight(Country,7)+FillRight(CountryName,28)+
FillRight(IntToStr(Zone),2)+' '+ //ver 0.23
Continent+ ' ';
for B := b19 to b28 do
if NotWARC(B) then
if Worked[B] then
temp := temp + '* '
else
temp := temp + '. ';
Result := temp;
end;
function TCountry.Summary2 : string;
var temp : string;
B : TBand;
i : integer;
begin
if CountryName = 'Unknown' then
begin
Result := 'Unknown';
exit;
end;
temp := '';
temp := FillRight(Country,7)+FillRight(CountryName,28)+ Continent+ ' ';
temp := temp + 'worked on : ';
for B := b19 to b28 do
if NotWARC(B) then
if Worked[B] then
temp := temp + MHzString[B] + ' '
else
for i := 1 to length(MHzString[B]) do
temp := temp + ' ';
Result := temp;
end;
function TCountry.JustInfo : string;
var temp : string;
begin
if CountryName = 'Unknown' then
begin
Result := 'Unknown';
exit;
end;
temp := '';
temp := FillRight(Country,7)+FillRight(CountryName,28)+ Continent+ ' ';
Result := temp;
end;
constructor TCountry.Create;
var B : TBand;
begin
for B := b19 to HiBand do
Worked[B] := False;
Country := '';
CountryName := '';
Zone := 0;
Continent := '';
end;
constructor TPrefix.Create;
begin
Prefix := '';
Index := 0;
Length := 0;
OvrZone := 0;
OvrContinent := '';
end;
constructor TPrefixList.Create;
begin
List := TList.Create;
end;
destructor TPrefixList.Destroy;
var i : integer;
begin
List.Pack;
for i := 0 to List.Count-1 do
TPrefix(List[i]).Free;
List.Free;
end;
procedure TWWMultiForm.FormCreate(Sender: TObject);
begin
inherited;
CountryList := TCountryList.Create;
PrefixList := TPrefixList.Create;
if FileExists('CTY.DAT') then
begin
LoadCTY_DAT(testCQWW, CountryList, PrefixList);
//MainForm.StatusLine.SimpleText := 'Loaded CTY.DAT';
end
else
LoadCountryDataFromFile('CQWW.DAT', CountryList, PrefixList);
Reset; // WWZone.Reset is also called from Reset
end;
procedure TWWMultiForm.ResetBand(B : TBand);
var i : integer;
begin
for i := 0 to CountryList.List.Count - 1 do
begin
TCountry(CountryList.List[i]).Worked[B] := False;
end;
for i := 1 to MAXCQZONE do
Zone[B, i] := False;
WWZone.ResetBand(B);
case SortBy.ItemIndex of
0 : SortDefault;
1 : SortZone;
end;
end;
procedure TWWMultiForm.Reset;
var B : TBand;
i : integer;
begin
WWZone.Reset;
for B := b19 to HiBand do
for i := 1 to MAXCQZONE do
Zone[B, i] := false;
if CountryList.List.Count = 0 then exit;
for i := 0 to CountryList.List.Count-1 do
begin
for B := b19 to HiBand do
TCountry(CountryList.List[i]).Worked[B] := false;
end;
case SortBy.ItemIndex of
0 : SortDefault;
1 : SortZone;
end;
end;
procedure TWWMultiForm.SortDefault;
var i, j : integer;
begin
if CountryList.List.Count = 0 then exit;
j := Grid.TopRow;
Grid.RowCount := 0;
Grid.RowCount := CountryList.List.Count;
for i := 0 to CountryList.List.Count-1 do
begin
Grid.Cells[0,i] := TCountry(CountryList.List[i]).Summary;
TCountry(CountryList.List[i]).GridIndex := i;
GridReverse[i] := i;
end;
Grid.TopRow := j;
end;
procedure TWWMultiForm.SortZone;
var i, j, x, _top: integer;
begin
if CountryList.List.Count = 0 then exit;
_top := Grid.TopRow;
Grid.RowCount := 0;
Grid.RowCount := CountryList.List.Count;
Grid.Cells[0,0] := TCountry(CountryList.List[0]).Summary; // unknown
x := 1;
for i := 1 to 40 do
begin
for j := 1 to CountryList.List.Count - 1 do
begin
if TCountry(CountryList.List[j]).Zone = i then
begin
Grid.Cells[0,x] := TCountry(CountryList.List[j]).Summary;
TCountry(CountryList.List[j]).GridIndex := x;
GridReverse[x] := j;
inc(x);
end;
end;
end;
Grid.TopRow := _top;
end;
procedure TWWMultiForm.Add(aQSO : TQSO);
var i : integer;
C : TCountry;
begin
if aQSO.QSO.Dupe then
exit;
if aQSO.QSO.NewMulti1 then
begin
try
i := StrToInt(aQSO.QSO.Multi1);
except
on EConvertError do
i := 0;
end;
if i in [1..40] then
WWZone.Mark(aQSO.QSO.Band, i);
end;
if aQSO.QSO.NewMulti2 then
begin
for i := 0 to CountryList.List.Count - 1 do
if TCountry(CountryList.List[i]).Country = aQSO.QSO.Multi2 then
begin
C := TCountry(CountryList.List[i]);
C.Worked[aQSO.QSO.Band] := True;
Grid.Cells[0,C.GridIndex] := C.Summary;
exit;
end;
end;
end;
{procedure TWWMultiForm.RecalcBand(B : TBand);
var Log : TQSOList;
i : integer;
aQSO : TQSO;
begin
if NotWARC(B) and (B in [b19..b28]) = False then
exit;
Log := ServerForm.Stats.Logs[B];
ResetBand(B);
aQSO := TQSO.Create;
for i := 1 to Log.TotalQSO do
begin
aQSO.QSO := TQSO(Log.List[i]).QSO;
Add(aQSO);
TQSO(Log.List[i]).QSO := aQSO.QSO;
end;
aQSO.Free;
end;}
procedure TWWMultiForm.RecalcAll;
var i : integer;
aQSO : TQSO;
begin
Reset;
for i := 1 to ServerForm.Stats.MasterLog.TotalQSO do
begin
aQSO := TQSO(ServerForm.Stats.MasterLog.List[i]);
Add(aQSO);
end;
{ aQSO := TQSO.Create;
for B := b19 to HiBand do
begin
if NotWARC(B) then
begin
Log := ServerForm.Stats.Logs[B];
for i := 1 to Log.TotalQSO do
begin
aQSO.QSO := TQSO(Log.List[i]).QSO;
Add(aQSO);
TQSO(Log.List[i]).QSO := aQSO.QSO;
end;
end;
end;
aQSO.Free; }
end;
procedure TWWMultiForm.SortByClick(Sender: TObject);
begin
case SortBy.ItemIndex of
0 : SortDefault;
1 : SortZone;
end;
end;
procedure TWWMultiForm.FormShow(Sender: TObject);
begin
inherited;
WWZone.Show;
WWMultiForm.SetFocus;
end;
procedure TWWMultiForm.GoButtonClick(Sender: TObject);
var temp : string;
i : integer;
begin
temp := Edit1.Text;
for i := 0 to CountryList.List.Count-1 do
begin
if pos(temp,TCountry(CountryList.List[i]).Country) = 1 then
begin
Grid.TopRow := TCountry(CountryList.List[i]).GridIndex;
break;
end;
end;
end;
procedure TWWMultiForm.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TWWMultiForm.cbStayOnTopClick(Sender: TObject);
begin
inherited;
if cbStayOnTop.Checked then
FormStyle := fsStayOnTop
else
FormStyle := fsNormal;
end;
procedure TWWMultiForm.GridSetting(ARow, Acol: Integer;
var Fcolor: Integer; var Bold, Italic, underline: Boolean);
begin
inherited;
{
B := Main.CurrentQSO.QSO.Band;
if TCountry(CountryList.List[GridReverse[ARow]]).Worked[B] then
FColor := clRed
else
FColor := clBlack;}
FColor := clBlack;
end;
procedure TWWMultiForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if Key = Chr($0D) then
begin
GoButtonClick(Self);
Key := #0;
end;
end;
end.