Empty rig model will erase whole TRXnr section

This commit is contained in:
OH1KH 2022-08-25 13:11:13 +03:00
parent a1662e2484
commit 1814733715
2 changed files with 31 additions and 0 deletions

View File

@ -3335,7 +3335,13 @@ Procedure TfrmPreferences.SaveTRX(RigNr:integer);
var
nr :string;
Begin
nr:=IntToStr(RigNr);
if cmbModelRig.Text='' then //empty model will erase whole TRX section
Begin
cqrini.SectionErase('TRX'+nr);
exit;
end;
cqrini.WriteString('TRX'+nr, 'device', edtRDevice.Text);
cqrini.WriteString('TRX'+nr, 'model', dmUtils.GetRigIdFromComboBoxItem(cmbModelRig.Text));

View File

@ -26,6 +26,7 @@ type
function ReadBool(const Section, Ident: string; Default: Boolean;ToLocal : Boolean=FALSE): Boolean;
function ReadFloat(const Section, Ident: string; Default: Double): Double;
function SectionExists(Section : String) : Boolean;
function SectionErase(Section : String) : Boolean;
function LocalOnly(Section : String) : Boolean;
procedure WriteString(const Section, Ident, Value: String;ToLocal : Boolean=FALSE);
@ -222,6 +223,30 @@ begin
LeaveCriticalsection(crit)
end
end;
function TMyIni.SectionErase(Section : String) : Boolean;
begin
EnterCriticalsection(crit);
try
if SectionExists(Section) then
begin
if LocalOnly(Section) then
Begin
Result := true;
lini.EraseSection(Section)
end
else
begin
Result := true;
ini.EraseSection(Section)
end;
end
else
Result:=false;
finally
LeaveCriticalsection(crit)
end
end;
function TMyIni.LocalOnly(Section : String) : Boolean;
begin