From f1b8d784c543fc1df2b617d50c7cc7321e1a7ef0 Mon Sep 17 00:00:00 2001 From: OH1KH Date: Tue, 25 Jan 2022 12:58:30 +0200 Subject: [PATCH] -Added LocalDbg value -2 to adifimport and import progress -Modified CVersion string compose -importprogress combined source code of lotw and eqsl process to "commonImport" procedure -fixed NewQSO remote adif to be sure that mode tag does not override submode if they are in order where submode comes first in record -moved lotw erro file to user home dir (as eqsl error is) It is easier to find from there than from hidden folder .config/cqrlog -changed errors found prompts to open error file from both lotw qnd eqsl imports. ERROR FILE OPENING DOES NOT WORK! Check next! --- src/cqrlog.lpi | 4 +- src/cqrlog.lpr | 1 + src/fAdifImport.pas | 53 +++-- src/fImportProgress.pas | 460 ++++++++++------------------------------ src/fNewQSO.pas | 14 +- src/uVersion.pas | 13 +- 6 files changed, 167 insertions(+), 378 deletions(-) diff --git a/src/cqrlog.lpi b/src/cqrlog.lpi index bcfbf1b..dd2c387 100644 --- a/src/cqrlog.lpi +++ b/src/cqrlog.lpi @@ -39,7 +39,7 @@ - + @@ -52,7 +52,7 @@ - + diff --git a/src/cqrlog.lpr b/src/cqrlog.lpr index daf3b98..29d3dff 100644 --- a/src/cqrlog.lpr +++ b/src/cqrlog.lpr @@ -55,6 +55,7 @@ begin Writeln(' 1 All debug messages'); Writeln(' 2 All debug messages + some additional RBNmonitor & DXCluster debugs'); Writeln('Negative values can be combined (binary bitwise OR)'); + Writeln(' -2 AdifImport & ImportProgress debug messages'); Writeln(' -4 Wsjtx remote & Worked grids debug messages'); Writeln(' -8 CW keying & TRXControl debug messages'); Writeln(' -16 Grayline map RBN debug messages'); diff --git a/src/fAdifImport.pas b/src/fAdifImport.pas index ea23f04..a3f3dd6 100644 --- a/src/fAdifImport.pas +++ b/src/fAdifImport.pas @@ -141,6 +141,7 @@ type procedure mnuImportClick(Sender: TObject); private LockSubMode : boolean; //if we replace mode with submode we set lock in case that submode and mode are in opposite order in qso record. + LocalDbg : Boolean; AbortImport : boolean; ERR_FILE : String; Do_Err_Import : Boolean; @@ -164,6 +165,7 @@ type { private declarations } public function getNextAdifTag(var vstup,prik,data:string):boolean; + procedure OpenInTextEditor(OpenName:String); { public declarations } end; @@ -224,7 +226,7 @@ var z,x:longint; DataLen := 0 else DataLen := StrToInt(slen); - //if dmData.DebugLevel >=1 then Write('Got length:',DataLen); + //if LocalDbg then Write('Got length:',DataLen); if z<>0 then prik:=trim(copy(aaa,1,z-1)) @@ -235,14 +237,14 @@ var z,x:longint; z:=pos('<',aaa); i:= pos('_INTL',upcase(prik)); - //if dmData.DebugLevel >=1 then Write(' pos INTL:',i); + //if LocalDbg then Write(' pos INTL:',i); if z=0 then begin if i>0 then //tags with '_intl' have UTF8 charactes Begin prik:= copy(prik,1,i-1); //remove '_INTL' data:=UTF8copy(aaa,1,DataLen); - //if dmData.DebugLevel >=1 then Write(' as UTF8'); + //if LocalDbg then Write(' as UTF8'); end else data:=copy(aaa,1,DataLen); @@ -253,14 +255,14 @@ var z,x:longint; Begin prik:= copy(prik,1,i-1); //remove '_INTL' data:=UTF8copy(aaa,1,DataLen); - //if dmData.DebugLevel >=1 then Write(' as UTF8'); + //if LocalDbg then Write(' as UTF8'); end else data:=copy(aaa,1,DataLen); vstup:=copy(aaa,z,length(aaa)) end; data :=trim(data); - //if dmData.DebugLevel >=1 then Writeln(' for tag:',prik,' with data:',data); + //if LocalDbg then Writeln(' for tag:',prik,' with data:',data); getNextAdifTag:=true end; @@ -507,19 +509,19 @@ begin Q4.SQL.Text := 'SELECT nr FROM profiles WHERE locator='+QuotedStr(pLoc) + ' and qth='+QuotedStr(pQTH)+' and rig='+QuotedStr(pEq) + ' and remarks='+QuotedStr(pNote); - if dmData.DebugLevel >=1 then Writeln(Q4.SQL.Text); + if LocalDbg then Writeln(Q4.SQL.Text); Q4.Open; if Q4.Fields[0].AsInteger = 0 then begin Q4.Close(); Q4.SQL.Text := 'select nr from profiles where nr = '+pProf; - if dmData.DebugLevel >=1 then Writeln(Q4.SQL.Text); + if LocalDbg then Writeln(Q4.SQL.Text); Q4.Open(); if (Q4.Fields[0].AsInteger > 0) then //if profile with this number doesnt exists, begin //we can save the number Q4.Close(); Q4.SQL.Text := 'select max(nr) from profiles'; - if dmData.DebugLevel >=1 then Writeln(Q4.SQL.Text); + if LocalDbg then Writeln(Q4.SQL.Text); Q4.Open(); pProf := IntToStr(Q4.Fields[0].AsInteger+1) end; @@ -539,7 +541,7 @@ begin pProf+','+QuotedStr(pLoc)+','+QuotedStr(pQTH)+','+QuotedStr(pEq)+','+ QuotedStr(pNote)+',1)'; } - if dmData.DebugLevel >=1 then Writeln(Q4.SQL.Text); + if LocalDbg then Writeln(Q4.SQL.Text); Q4.ExecSQL; Q4.Close(); end @@ -559,7 +561,7 @@ begin ' AND time_on = ' + QuotedStr(d.TIME_ON) + ' AND callsign = '+QuotedStr(d.CALL)+ ' AND band = ' + QuotedStr(d.BAND) + ' AND mode = '+QuotedStr(d.MODE); - if dmData.DebugLevel >=1 then Writeln(dmData.Q.SQL.Text); + if LocalDbg then Writeln(dmData.Q.SQL.Text); if dmData.trQ.Active then dmData.trQ.Rollback; dmData.trQ.StartTransaction; @@ -627,7 +629,7 @@ begin ':lotw_qslr,:qsls_date,:qslr_date,:eqsl_qslsdate,:eqsl_qsl_sent,:eqsl_qslrdate,'+ ':eqsl_qsl_rcvd, :prop_mode, :satellite, :rxfreq, :stx, :srx, :stx_string, :srx_string,'+ ':contestname,:dok,:operator)'; - if dmData.DebugLevel >=1 then Writeln(Q1.SQL.Text); + if LocalDbg then Writeln(Q1.SQL.Text); Q1.Prepare; Q1.Params[0].AsString := d.QSO_DATE; Q1.Params[1].AsString := d.TIME_ON; @@ -756,7 +758,7 @@ begin else Q1.Params[47].Clear; - if dmData.DebugLevel >=1 then Writeln(Q1.SQL.Text); + if LocalDbg then Writeln(Q1.SQL.Text); Q1.ExecSQL; inc(RecNR); if (RecNR mod 100 = 0) then @@ -792,7 +794,7 @@ begin // If that failed use default configured locator if not dmUtils.IsLocOK(FMyLoc) then FMyLoc := cqrini.ReadString('Station', 'LOC', ''); - if dmData.DebugLevel >=1 then WriteLn('Using '+FMyLoc+' as locator for imports'); + if LocalDbg then WriteLn('Using '+FMyLoc+' as locator for imports'); RecNR := 0; WrongRecNr := 0; FFilteredOutRecNr := 0; @@ -852,7 +854,7 @@ begin tr.Commit; dt := dt - now; DecodeTime(dt,hh,m,s,ms); - if dmData.DebugLevel >=1 then WriteLn('It takes about ',m,' minutes and ',s,' seconds ',ms,' milliseconds'); + if LocalDbg then WriteLn('It takes about ',m,' minutes and ',s,' seconds ',ms,' milliseconds'); lblCount.Caption := IntToStr(RecNR); lblFilteredOut.Visible := FFilterByDate; lblFilteredOutCount.Visible := FFilterByDate; @@ -874,23 +876,27 @@ procedure TfrmAdifImport.lblErrorLogClick(Sender: TObject); Begin popErrFile.Popup; end; - -procedure TfrmAdifImport.mnueditClick(Sender: TObject); - //open in text editor +procedure TfrmAdifImport.OpenInTextEditor(OpenName:String); +//open in text editor var prg: string; begin - popErrFile.Close; try prg := cqrini.ReadString('ExtView', 'txt', ''); if prg<>'' then - dmUtils.RunOnBackground(prg + ' ' + lblErrorLog.Caption) + dmUtils.RunOnBackground(prg + ' ' + name) else ShowMessage('No external text viewer defined!'+#10+'See: prefrences/External viewers'); finally //done end; end; +procedure TfrmAdifImport.mnueditClick(Sender: TObject); +begin + popErrFile.Close; + OpenInTextEditor(lblErrorLog.Caption); +end; + procedure TfrmAdifImport.mnuImportClick(Sender: TObject); var tmp:Char; @@ -976,7 +982,12 @@ begin finally FormatSettings.TimeSeparator := tmp end; - lblErrorLog.Visible:=false + lblErrorLog.Visible:=false; + //set debug rules for this form + // bit 1, %1, ---> -2 for routines in this form + LocalDbg := dmData.DebugLevel >= 1 ; + if dmData.DebugLevel < 0 then + LocalDbg := LocalDbg or ((abs(dmData.DebugLevel) and 2) = 2 ); end; procedure TfrmAdifImport.chkFilterDateRangeChange(Sender: TObject); @@ -1018,7 +1029,7 @@ var i : Integer; begin for i:= 0 to Length(lines)-1 do - if dmData.DebugLevel >=1 then WriteLn(lines[i]); + if LocalDbg then WriteLn(lines[i]); if FileExists(dmData.UsrHomeDir + ERR_FILE) then begin diff --git a/src/fImportProgress.pas b/src/fImportProgress.pas index a88af86..a5a8162 100644 --- a/src/fImportProgress.pas +++ b/src/fImportProgress.pas @@ -41,12 +41,15 @@ type procedure FormShow(Sender: TObject); procedure tmrImportTimer(Sender: TObject); private - running : Boolean; + running, + LocalDbg : Boolean; FileSize : Int64; procedure ImportDXCCTables; procedure RegenerateDXCCStat; procedure DownloadDXCCData; procedure DownloadDOKData; + procedure CommonImport(var PosEOR:word;var f:TextFile;var call,band,mode,submode,qsodate,time_on,qslr, + qslrdate,cqz,ituz,iota,grid,state,county:String); procedure ImportLoTWAdif; procedure ImportQSLMgrs; procedure DownloadQSLData; @@ -77,7 +80,7 @@ implementation {$R *.lfm} { TfrmImportProgress } -uses dData, dUtils, fImportTest, dDXCC, uMyini, dLogUpload, dMembership, dSatellite; +uses dData, dUtils, fImportTest, dDXCC, uMyini, dLogUpload, dMembership, dSatellite, fAdifImport; procedure TfrmImportProgress.FormActivate(Sender: TObject); begin @@ -108,7 +111,12 @@ begin LoTWQSOList := TStringList.Create; LoTWQSOList.Clear; eQSLQSOList := TStringList.Create; - eQSLQSOList.Clear + eQSLQSOList.Clear; + //set debug rules for this form + // bit 1, %1, ---> -2 for routines in this form + LocalDbg := dmData.DebugLevel >= 1 ; + if dmData.DebugLevel < 0 then + LocalDbg := LocalDbg or ((abs(dmData.DebugLevel) and 2) = 2 ); end; procedure TfrmImportProgress.FormDestroy(Sender: TObject); @@ -176,7 +184,7 @@ begin QuotedStr(Result[4])+','+QuotedStr(Result[5])+','+ QuotedStr(Result[6])+','+QuotedStr(Result[7])+','+ IntToStr(ADIF)+',0)'; - if dmData.DebugLevel >=1 then Writeln(dmDXCC.qDXCCRef.SQL.Text); + if LocalDbg then Writeln(dmDXCC.qDXCCRef.SQL.Text); dmDXCC.qDXCCRef.ExecSQL; end; end; @@ -202,7 +210,7 @@ begin QuotedStr(Result[4])+','+QuotedStr(Result[5])+','+ QuotedStr(Result[6])+','+QuotedStr(Result[7])+','+ IntToStr(ADIF)+','+'1'+')'; - if dmData.DebugLevel >=1 then + if LocalDbg then Writeln(dmDXCC.qDXCCRef.SQL.Text); dmDXCC.qDXCCRef.ExecSQL; end; @@ -319,7 +327,7 @@ begin QuotedStr(Result[1]) + ',' + QuotedStr(Result[2]) + ',' + QuotedStr(tmp) + ')'; end; - if dmData.DebugLevel>=1 then + if LocalDbg then Writeln(dmData.qIOTAList.SQL.Text); if length(Result[1]) > 250 then ShowMessage(Result[0]); @@ -540,7 +548,56 @@ begin Application.ProcessMessages; end; end; +procedure TfrmImportProgress.CommonImport(var PosEOR:word;var f:TextFile;var call,band,mode,submode,qsodate,time_on,qslr, + qslrdate,cqz,ituz,iota,grid,state,county:String); +var + a, + prik, + data, + Buf :string; +Begin + Buf:=''; + while not ((PosEOR > 0) or eof(f)) do //combine one record. LoTW adif has one tag per line + Begin + Readln(f, a); + a := Trim(a); + PosEOR := Pos('',UpperCase(a)); + Buf := Buf+a; + end; + Buf:=buf+''; //in case we have broken record in broken file (hit eof before it is time) + if LocalDbg then Writeln('one record read: ',Buf); + mode := ''; //be sure there is no mode at this point + repeat + begin + if frmAdifImport.getNextAdifTag(Buf,prik,data) then + if LocalDbg then + Begin + write(prik,'->'); + writeln(data); + end; + case uppercase(prik) of + 'CALL' : call := uppercase(data); + 'GRIDSQUARE' : if dmUtils.IsLocOK(data) then + grid := dmUtils.StdFormatLocator(data); + //if not mode set by submode then set mode + 'MODE' : if mode='' then mode := uppercase(data); + //submode overrides MODE, if exist + 'SUBMODE' : mode := uppercase(data); + 'BAND' : band := uppercase(data); + 'QSO_DATE' : qsodate := data; + 'TIME_ON' : time_on := data; + 'IOTA' : iota := data; + 'STATE' : state := data; + 'CQZ' : cqz := data; + 'ITUZ' : ituz := data; + 'CNTY' : county := data; + 'QSL_RCVD' : qslr :=uppercase(data); + 'QSLRDATE' : qslrdate:= data; + end; //case + end; //repeat + until pos('',uppercase(Buf))=1; +end; procedure TfrmImportProgress.ImportLoTWAdif; var @@ -556,6 +613,8 @@ var call : String; band : String; mode : String; + //submode not needed with lotw + submode : String; qsodate : String; time_on : String; qslr : String; @@ -566,19 +625,6 @@ var grid : String; state : String; county : String; - PosCall : Word; - PosBand : Word; - PosMode : Word; - PosQsoDate : Word; - PosTime_on : Word; - PosQslr : Word; - PosQslrDate : Word; - PosCqz : Word; - PosItuz : Word; - PosIota : Word; - PosGrid : Word; - PosState : Word; - PosCounty : Word; qso_in_log : Boolean = False; ErrorCount : Word = 0; @@ -621,6 +667,7 @@ begin call := ''; band := ''; mode := ''; + submode := ''; qsodate := ''; time_on := ''; qslr := ''; @@ -632,205 +679,18 @@ begin state := ''; county := ''; PosEOR := 0; - while not ((PosEOR > 0) or eof(f)) do + while not ((PosEOR > 0) or eof(f)) do //read all records begin qso_in_log := False; - Readln(f, a); - a := Trim(a); - orig := a; - a := UpperCase(a); - - PosCall := Pos('',a); - - if PosCall > 0 then - begin - sSize := ''; - PosCall := PosCall + 6; - while not (a[PosCall] = '>') do - begin - sSize := sSize + a[PosCall]; - inc(PosCall) - end; - Size := StrToInt(sSize); - call := copy(orig,PosCall+1,Size) - end; - - if PosBand > 0 then - begin - sSize := ''; - PosBand := PosBand + 6; - while not (a[PosBand] = '>') do - begin - sSize := sSize + a[PosBand]; - inc(PosBand) - end; - Size := StrToInt(sSize); - band := copy(orig,PosBand+1,Size) - end; - - if PosMode > 0 then - begin - sSize := ''; - PosMode := PosMode + 6; - while not (a[PosMode] = '>') do - begin - sSize := sSize + a[PosMode]; - inc(PosMode) - end; - Size := StrToInt(sSize); - mode := copy(orig,PosMode+1,Size) - end; - - if PosQsoDate > 0 then - begin - sSize := ''; - PosQsoDate := PosQsoDate + 10; - while not (a[PosQsoDate] = '>') do - begin - sSize := sSize + a[PosQsoDate]; - inc(PosQsoDate) - end; - Size := StrToInt(sSize); - qsodate := copy(orig,PosQsoDate+1,Size) - end; - - if PosTime_on > 0 then - begin - sSize := ''; - PosTime_on := PosTime_on + 9; - while not (a[PosTime_on] = '>') do - begin - sSize := sSize + a[PosTime_on]; - inc(PosTime_on) - end; - Size := StrToInt(sSize); - time_on := copy(orig,PosTime_on+1,Size) - end; - - - if PosQslr > 0 then - begin - sSize := ''; - PosQslr := PosQslr + 10; - while not (a[PosQslr] = '>') do - begin - sSize := sSize + a[PosQslr]; - inc(PosQslr) - end; - Size := StrToInt(sSize); - qslr := copy(orig,PosQslr+1,Size) - end; - - if PosQslrDate > 0 then - begin - sSize := ''; - PosQslrDate := PosQslrDate + 10; - while not (a[PosQslrDate] = '>') do - begin - sSize := sSize + a[PosQslrDate]; - inc(PosQslrDate) - end; - Size := StrToInt(sSize); - qslrdate := copy(orig,PosQslrDate+1,Size) - end; - - if PosCqz > 0 then - begin - sSize := ''; - PosCqz := PosCqz + 5; - while not (a[PosCqz] = '>') do - begin - sSize := sSize + a[PosCqz]; - inc(PosCqz) - end; - Size := StrToInt(sSize); - cqz := copy(orig,PosCqz+1,Size) - end; - - if PosItuz > 0 then - begin - sSize := ''; - PosItuz := PosItuz + 6; - while not (a[PosItuz] = '>') do - begin - sSize := sSize + a[PosItuz]; - inc(PosItuz) - end; - Size := StrToInt(sSize); - ituz := copy(orig,PosItuz+1,Size) - end; - - if PosIota > 0 then - begin - sSize := ''; - PosIota := PosIota + 6; - while not (a[PosIota] = '>') do - begin - sSize := sSize + a[PosIota]; - inc(PosIota) - end; - Size := StrToInt(sSize); - iota := copy(orig,PosIota+1,Size) - end; - - if PosGrid > 0 then - begin - sSize := ''; - PosGrid := PosGrid + 12; - while not (a[PosGrid] = '>') do - begin - sSize := sSize + a[PosGrid]; - inc(PosGrid) - end; - Size := StrToInt(sSize); - grid := copy(orig,PosGrid+1,Size) - end; - - if PosState > 0 then - begin - sSize := ''; - PosState := PosState + 7; - while not (a[PosState] = '>') do - begin - sSize := sSize + a[PosState]; - inc(PosState) - end; - Size := StrToInt(sSize); - state := copy(orig,PosState+1,Size) - end; - - if PosCounty > 0 then - begin - sSize := ''; - PosCounty := PosCounty + 6; - while not (a[PosCounty] = '>') do - begin - sSize := sSize + a[PosCounty]; - inc(PosCounty) - end; - Size := StrToInt(sSize); - county := copy(orig,PosCounty+1,Size) - end; + CommonImport(PosEOR,f,call,band,mode,submode,qsodate,time_on,qslr, + qslrdate,cqz,ituz,iota,grid,state,county); if PosEOR > 0 then begin - //inc(qsln); - if dmData.DebugLevel >= 1 then + if LocalDbg then begin - // Writeln('Number: ',IntToStr(qsln)); + Writeln('------------------------------------------------'); + Writeln('Record Number: ',IntToStr(qsln)); Writeln('Call: ',call); Writeln('Band: ',band); Writeln('Mode: ',mode); @@ -860,7 +720,7 @@ begin 'and (band = ' + QuotedStr(band) + ')'+ // 'and (mode = ' + QuotedStr(mode) + ') and (band = ' + QuotedStr(band) + ')'+ 'and (callsign = ' + QuotedStr(call) + ')'; - if dmData.DebugLevel >=1 then Writeln(dmData.Q.SQL.Text); + if LocalDbg then Writeln(dmData.Q.SQL.Text); //if dmData.trQ.Active then dmData.trQ.Rollback; //dmData.trQ.StartTransaction; dmData.Q.Open(); @@ -887,7 +747,7 @@ begin else //as day is set at sql query and we can not go forward to tomorrow t_lotw_max := t_lotw+5/1440; - if dmData.DebugLevel >=1 then Writeln(call,'|',TimeToStr(t_log),' | ',TimeToStr(t_lotw_min),'|',TimeToStr(t_lotw_max)); + if LocalDbg then Writeln(call,'|',TimeToStr(t_log),' | ',TimeToStr(t_lotw_min),'|',TimeToStr(t_lotw_max)); if (t_log >=t_lotw_min) and (t_log<=t_lotw_max) then begin @@ -916,7 +776,7 @@ begin end; dmData.Q1.SQL.Add(' where id_cqrlog_main = ' + dmData.Q.Fields[8].AsString); inc(qsln); - if dmData.DebugLevel>=1 then Writeln(dmData.Q1.SQL.Text+ ' qsl number:'+ IntToStr(qsln)); + if LocalDbg then Writeln(dmData.Q1.SQL.Text+ ' qsl number:'+ IntToStr(qsln)); dmData.Q1.ExecSQL end; qso_in_log := True; @@ -954,18 +814,17 @@ begin dmData.trQ1.Commit; if ErrorCount > 0 then begin - l.SaveToFile(dmData.HomeDir + 'lotw_error.txt'); - if Application.MessageBox(PChar(IntToStr(ErrorCount)+' QSO(s) were not found in your log. '#13' QSO(s) are stored to '+dmData.HomeDir + 'lotw_error.txt'+ + l.SaveToFile(dmData.UsrHomeDir + 'lotw_error.txt'); + if Application.MessageBox(PChar(IntToStr(ErrorCount)+' QSO(s) were not found in your log. '#13' QSO(s) are stored to '+dmData.UsrHomeDir + 'lotw_error.txt'+ LineEnding+LineEnding+'Do you want to show the file?'),'Question ....',mb_YesNo+mb_IconQuestion)=idYes then - dmUtils.OpenInApp(dmData.HomeDir + 'lotw_error.txt') - //ShowMessage(IntToStr(ErrorCount)+' QSO(s) were not found in your log. '#13' QSO(s) are stored to '+dmData.HomeDir + 'lotw_error.txt') + frmAdifImport.OpenInTextEditor(dmData.UsrHomeDir + 'lotw_error.txt') end end else begin if Application.MessageBox('Something is wrong because LoTW server returned invalid adif file header.'+LineEnding+ 'Your LoTW username/password could be wrong or LoTW server is down.'+LineEnding+LineEnding+'Do you want to show the file?', 'Error ...',mb_YesNo+mb_IconQuestion) = idYes then - dmUtils.OpenInApp(FileName) + frmAdifImport.OpenInTextEditor(FileName) end finally dmData.Q.Close(); @@ -1071,7 +930,7 @@ begin dmData.trQ.StartTransaction; dmData.Q.SQL.Text := 'update cqrlog_main set qsl_via = ' + QuotedStr(qsl_via) + ' where id_cqrlog_main = '+ IntToStr(dmData.qCQRLOG.FieldByName('id_cqrlog_main').AsInteger); - if dmData.DebugLevel>=1 then Writeln(dmData.Q.SQL.Text); + if LocalDbg then Writeln(dmData.Q.SQL.Text); dmData.Q.ExecSQL; dmData.trQ.Commit end; @@ -1104,6 +963,15 @@ var qsodate : String; time_on : String; qslr : String; + qslrdate : String; + cqz : String; + ituz : String; + iota : String; + grid : String; + state : String; + county : String; + Buf : String; + PosCall : Word; PosBand : Word; PosMode : Word; @@ -1155,127 +1023,29 @@ begin qsodate := ''; time_on := ''; qslr := ''; + //these are not needed with eQSL + qslrdate := ''; + cqz := ''; + ituz := ''; + iota := ''; + grid := ''; + state := ''; + county := ''; + PosEOR := 0; + + while not ((PosEOR > 0) or eof(f)) do begin qso_in_log := False; - Readln(f, a); - a := Trim(a); - orig := a; - a := UpperCase(a); - - PosCall := Pos('',a); - - if PosCall > 0 then - begin - sSize := ''; - PosCall := PosCall + 6; - while not (a[PosCall] = '>') do - begin - sSize := sSize + a[PosCall]; - inc(PosCall) - end; - Size := StrToInt(sSize); - call := copy(orig,PosCall+1,Size) - end; - - if PosBand > 0 then - begin - sSize := ''; - PosBand := PosBand + 6; - while not (a[PosBand] = '>') do - begin - sSize := sSize + a[PosBand]; - inc(PosBand) - end; - Size := StrToInt(sSize); - band := copy(orig,PosBand+1,Size) - end; - - if PosMode > 0 then - begin - sSize := ''; - PosMode := PosMode + 6; - while not (a[PosMode] = '>') do - begin - sSize := sSize + a[PosMode]; - inc(PosMode) - end; - Size := StrToInt(sSize); - mode := copy(orig,PosMode+1,Size) - end; - - if PosSubmode > 0 then - begin - sSize := ''; - PosSubmode := PosSubmode + 9; - while not (a[PosSubmode] = '>') do - begin - sSize := sSize + a[PosSubmode]; - inc(PosSubmode) - end; - Size := StrToInt(sSize); - submode := copy(orig,PosSubmode+1,Size) - end; - - if PosQsoDate > 0 then - begin - qsodate :=copy(orig,PosQsoDate+14,8); - { - sSize := ''; - PosQsoDate := PosQsoDate + 13; - while not (a[PosQsoDate] = '>') do - begin - sSize := sSize + a[PosQsoDate]; - inc(PosQsoDate) - end; - Size := StrToInt(sSize); - qsodate := copy(orig,PosQsoDate+1,Size) - } - end; - - if PosTime_on > 0 then - begin - sSize := ''; - PosTime_on := PosTime_on + 9; - while not (a[PosTime_on] = '>') do - begin - sSize := sSize + a[PosTime_on]; - inc(PosTime_on) - end; - Size := StrToInt(sSize); - time_on := copy(orig,PosTime_on+1,Size) - end; - - if PosQslr > 0 then - begin - sSize := ''; - PosQslr := PosQslr + 10; - while not (a[PosQslr] = '>') do - begin - sSize := sSize + a[PosQslr]; - inc(PosQslr) - end; - Size := StrToInt(sSize); - qslr := copy(orig,PosQslr+1,Size) - end; + CommonImport(PosEOR,f,call,band,mode,submode,qsodate,time_on,qslr, + qslrdate,cqz,ituz,iota,grid,state,county); if PosEOR > 0 then begin - band := UpperCase(band); - mode := UpperCase(mode); - submode := UpperCase(submode); - qslr := UpperCase(qslr); - call := UpperCase(call); - if dmData.DebugLevel >= 1 then + if LocalDbg then begin + Writeln('------------------------------------------------'); Writeln('Call: ',call); Writeln('Band: ',band); Writeln('Mode: ',mode); @@ -1283,11 +1053,9 @@ begin Writeln('QSO_date: ',qsodate); Writeln('Time_on: ',time_on); Writeln('QSLR: ',qslr); - Writeln('------------------------------------------------') + Writeln('------------------------------------------------'); end; qsodate := dmUtils.ADIFDateToDate(qsodate); - mode := UpperCase(mode); - dmData.Q.Close; @@ -1307,7 +1075,7 @@ begin 'and (band = ' + QuotedStr(band) + ') '+ 'and (callsign = ' + QuotedStr(call) + ')' end; - if dmData.DebugLevel >=1 then Writeln(dmData.Q.SQL.Text); + if LocalDbg then Writeln(dmData.Q.SQL.Text); //if dmData.trQ.Active then dmData.trQ.Rollback; //dmData.trQ.StartTransaction; dmData.Q.Open(); @@ -1334,7 +1102,7 @@ begin else //as day is set at sql query and we can not go forward to tomorrow t_eQSL_max := t_eQSL+60/1440; - if dmData.DebugLevel >=1 then Writeln(call,'|',TimeToStr(t_log),' | ',TimeToStr(t_eQSL_min),'|',TimeToStr(t_eQSL_max)); + if LocalDbg then Writeln(call,'|',TimeToStr(t_log),' | ',TimeToStr(t_eQSL_min),'|',TimeToStr(t_eQSL_max)); if (t_log >=t_eQSL_min) and (t_log<=t_eQSL_max) then begin @@ -1347,7 +1115,7 @@ begin dmData.Q1.SQL.Add('update cqrlog_main set eqsl_qsl_rcvd = ' + QuotedStr('E')); dmData.Q1.SQL.Add(',eqsl_qslrdate = ' + QuotedStr(dmUtils.DateInRightFormat(now))); dmData.Q1.SQL.Add(' where id_cqrlog_main = ' + dmData.Q.Fields[0].AsString); - if dmData.DebugLevel>=1 then Writeln(dmData.Q1.SQL.Text); + if LocalDbg then Writeln(dmData.Q1.SQL.Text); dmData.Q1.ExecSQL end; qso_in_log := True; @@ -1380,7 +1148,9 @@ begin if ErrorCount > 0 then begin l.SaveToFile(dmData.UsrHomeDir + 'eQSL_error.txt'); - ShowMessage('Some QSO(s) were not found in your log. '#13' QSO(s) are stored to '+dmData.UsrHomeDir + 'eQSL_error.txt') + if Application.MessageBox(PChar(IntToStr(ErrorCount)+' QSO(s) were not found in your log. '#13' QSO(s) are stored to '+dmData.UsrHomeDir + 'eQSL_error.txt'+ + LineEnding+LineEnding+'Do you want to show the file?'),'Question ....',mb_YesNo+mb_IconQuestion)=idYes then + frmAdifImport.OpenInTextEditor(dmData.UsrHomeDir + 'eQSL_error.txt') end finally l.Free; @@ -1400,7 +1170,7 @@ begin try try dmData.trQ.StartTransaction; dmData.Q.SQL.Text := 'create table tempdupes like cqrlog_main'; - if dmData.DebugLevel>=1 then Writeln(dmData.Q.SQL.Text); + if LocalDbg then Writeln(dmData.Q.SQL.Text); dmData.Q.ExecSQL; dmData.trQ.Commit; @@ -1411,15 +1181,15 @@ begin dmData.trQ.StartTransaction; dmData.Q.SQL.Text := 'insert into tempdupes ' + ' select * from cqrlog_main group by qsodate,time_on,callsign,mode,band'; - if dmData.DebugLevel>=1 then Writeln(dmData.Q.SQL.Text); + if LocalDbg then Writeln(dmData.Q.SQL.Text); dmData.Q.ExecSQL; dmData.Q.SQL.Text := 'delete from cqrlog_main'; - if dmData.DebugLevel>=1 then Writeln(dmData.Q.SQL.Text); + if LocalDbg then Writeln(dmData.Q.SQL.Text); dmData.Q.ExecSQL; dmData.Q.SQL.Text := 'insert into cqrlog_main select * from tempdupes'; - if dmData.DebugLevel>=1 then Writeln(dmData.Q.SQL.Text); + if LocalDbg then Writeln(dmData.Q.SQL.Text); dmData.Q.ExecSQL except on E : Exception do diff --git a/src/fNewQSO.pas b/src/fNewQSO.pas index df3fa6c..910ea3e 100644 --- a/src/fNewQSO.pas +++ b/src/fNewQSO.pas @@ -2179,7 +2179,8 @@ var buf2, prik, data :string; - chkDuplicates :boolean; + chkDuplicates, + submodeExist :boolean; i :longint; a,b,l :integer; fixed :Boolean; @@ -2256,7 +2257,7 @@ begin //this is fake as call info(qslmgr) needs date. We use current date if call tag comes before qso_date tag //qso_date will then replace this edtDate.Text := FormatDateTime('YYYY-MM-DD',now()); - + submodeExist:=false; repeat begin if frmAdifImport.getNextAdifTag(Buf,prik,data) then @@ -2278,9 +2279,14 @@ begin if pos(data,edtGrid.Text)=0 then //if qso loc does not fit to QRZ loc , or qrz loc is empty edtGrid.Text := data; //replace qrz loc, otherwise keep it end; - 'MODE' : cmbMode.Text := uppercase(data); + 'MODE' : if not submodeExist then + cmbMode.Text := uppercase(data); //now this overrides MODE, if exists - 'SUBMODE' : cmbMode.Text := uppercase(data); + 'SUBMODE' : Begin + //we need lock in case submode found before mode tag + submodeExist:=true; + cmbMode.Text := uppercase(data); + end; 'FREQ' : cmbFreq.Text := data; 'FREQ_RX' : edtRXFreq.Text := data; 'RST_SENT' : edtHisRST.Text := data; diff --git a/src/uVersion.pas b/src/uVersion.pas index d65ed7d..dad9273 100644 --- a/src/uVersion.pas +++ b/src/uVersion.pas @@ -4,13 +4,14 @@ unit uVersion; interface const - {$IFDEF LCLGtk2} - cVERSION = '2.5.2 (001) Gtk2'; - {$ENDIF} - {$IFDEF LCLQt5} - cVERSION = '2.5.2 (001) QT5'; - {$ENDIF} + cVersionBase = '2.5.2 (001)'; + {$IFDEF LCLGtk2} + cVERSION = cVersionBase+' Gtk2'; + {$ENDIF} + {$IFDEF LCLQt5} + cVERSION = cVersionBase+' QT5'; + {$ENDIF} cMAJOR = 2; cMINOR = 5;