Fixed some config parameters reading.

cqrini.ReadInteger and  cqrini.ReadString both can be used for same numeric value reading.
  	Works same way as database ReadAsString or ReadAsInteger; Source is same but resulting read is
  	either String or Integer how programmer wants.
  	cqrini.Write does not make difference in config file if variable is saved as String or Integer
  	both results look same in .cfg file.
This commit is contained in:
OH1KH 2022-12-09 14:05:52 +02:00
parent 03e196a032
commit 22b86742b3
4 changed files with 35 additions and 14 deletions

View File

@ -1,5 +1,5 @@
object frmPreferences: TfrmPreferences
Left = -194
Left = 0
Height = 652
Top = 165
Width = 1103
@ -17,7 +17,7 @@ object frmPreferences: TfrmPreferences
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
LCLVersion = '2.2.2.0'
LCLVersion = '2.2.4.0'
object pgPreferences: TPageControl
Left = 160
Height = 703
@ -2315,6 +2315,7 @@ object frmPreferences: TfrmPreferences
Height = 34
Top = 76
Width = 80
NumbersOnly = True
OnChange = TRXParamsChange
OnExit = edtPollExit
TabOrder = 5
@ -2387,6 +2388,7 @@ object frmPreferences: TfrmPreferences
Height = 34
Top = 76
Width = 80
NumbersOnly = True
OnChange = TRXParamsChange
TabOrder = 6
end
@ -3026,6 +3028,7 @@ object frmPreferences: TfrmPreferences
Top = 35
Width = 80
BorderSpacing.Left = 12
NumbersOnly = True
OnChange = RotorParamsChange
TabOrder = 1
end
@ -3085,6 +3088,7 @@ object frmPreferences: TfrmPreferences
Top = 35
Width = 80
BorderSpacing.Left = 12
NumbersOnly = True
OnChange = RotorParamsChange
TabOrder = 4
end
@ -3483,6 +3487,7 @@ object frmPreferences: TfrmPreferences
Top = 35
Width = 80
BorderSpacing.Left = 12
NumbersOnly = True
OnChange = RotorParamsChange
TabOrder = 1
end
@ -3542,6 +3547,7 @@ object frmPreferences: TfrmPreferences
Top = 35
Width = 80
BorderSpacing.Left = 12
NumbersOnly = True
OnChange = RotorParamsChange
TabOrder = 4
end

View File

@ -376,11 +376,19 @@ begin
//broken configuration caused crash because RotCtldPort was empty
//probably late to change it to Integer, I have no idea if the current
//setting would be converted automatically or user has to do it again :(
if not TryStrToInt(cqrini.ReadString('ROT'+n,'RotCtldPort','4533'),port) then
port := 4533;
if not TryStrToInt(cqrini.ReadString('ROT'+n,'poll','500'),poll) then
poll := 500;
//OH1KH 2022-12-09: cqrini.ReadInteger and cqrini.ReadString both can be used!
//Works same way as database ReadAsString or ReadAsInteger; Source is same but resulting read is
//either String or Integer how programmer wants.
//cqrini.Write does not make difference in config file if variable is saved as String or Integer
//both results look same in .cfg file.
port:= cqrini.ReadInteger('ROT'+n, 'RotCtldPort', 4533);
if ((port>65534) or (port<1024)) then port := 4533; //limit values
poll:=cqrini.ReadInteger('ROT'+n, 'poll', 500);
if ((poll>60000) or (poll<10)) then poll := 500; //limit values
rotor.RotCtldPath := cqrini.ReadString('ROT','RotCtldPath','/usr/bin/rotctld');
rotor.RotCtldArgs := dmUtils.GetRotorRotCtldCommandLine(StrToInt(n));

View File

@ -426,7 +426,7 @@ begin
dmUtils.LoadWindowPos(frmTRXControl);
cmbRigGetItems(nil);
//These two are needed here othewise rig selector has "None" even if rig is initialized at startup
cmbRig.ItemIndex:=StrToInt(cqrini.ReadString('TRX', 'RigInUse', '1'));
cmbRig.ItemIndex:=cqrini.ReadInteger('TRX', 'RigInUse', 1);
cmbRigCloseUp(nil); //defaults rig 1 in case of undefined
old_mode := '';
MemRelated := cqrini.ReadBool('TRX', 'MemModeRelated', False);
@ -725,7 +725,7 @@ end;
procedure TfrmTRXControl.FormClose(Sender : TObject; var CloseAction : TCloseAction);
begin
cqrini.WriteString('TRX', 'RigInUse', IntToStr(cmbRig.ItemIndex));
cqrini.WriteInteger('TRX', 'RigInUse', cmbRig.ItemIndex);
dmUtils.SaveWindowPos(frmTRXControl);
end;
@ -1018,7 +1018,7 @@ begin
Radio := nil;
AutoMode := True;
//these are needed here otherwise rig init at startup, if TRXControl window stays closed, fails
cmbRig.ItemIndex:=StrToInt(cqrini.ReadString('TRX', 'RigInUse', '1'));
cmbRig.ItemIndex:=cqrini.ReadInteger('TRX', 'RigInUse', 1);
cmbRigCloseUp(nil); //defaults rig 1 in case of undefined
end;
@ -1085,11 +1085,18 @@ begin
//broken configuration caused crash because RigCtldPort was empty
//probably late to change it to Integer, I have no idea if the current
//setting would be converted automatically or user has to do it again :(
if not TryStrToInt(cqrini.ReadString('TRX' + RigInUse, 'RigCtldPort', '4532'), port) then
port := 4532;
if not TryStrToInt(cqrini.ReadString('TRX' + RigInUse, 'poll', '500'), poll) then
poll := 500;
//OH1KH 2022-12-09: cqrini.ReadInteger and cqrini.ReadString both can be used!
//Works same way as database ReadAsString or ReadAsInteger; Source is same but resulting read is
//either String or Integer how programmer wants.
//cqrini.Write does not make difference in config file if variable is saved as String or Integer
//both results look same in .cfg file.
port:= cqrini.ReadInteger('TRX' + RigInUse, 'RigCtldPort', 4532);
if ((port>65534) or (port<1024)) then port := 4532; //limit values
poll:=cqrini.ReadInteger('TRX' + RigInUse, 'poll', 500);
if ((poll>60000) or (poll<10)) then poll := 500; //limit values
radio.RigCtldPath := cqrini.ReadString('TRX', 'RigCtldPath', '/usr/bin/rigctld');
radio.RigCtldArgs := dmUtils.GetRadioRigCtldCommandLine(StrToInt(RigInUse));

View File

@ -21,7 +21,7 @@ const
cRELEAS = 0;
cBUILD = 1;
cBUILD_DATE = '2022-12-07';
cBUILD_DATE = '2022-12-09';
implementation