This topic covers the implementation details of TSaras.
Scope: cpSaras.pas; class derived from TBtnEditProperty. Prepared from the curated implementation supplied for this review on 2 October 2026.
SaraSetInfo/SaraSet.Id is imported as the SARA set database ID. The supplied writer does not export the set’s program/rules. A comment states that the name is resolved in TSaras.SetDataValue; that setter is missing.
The shown ReadFromXML declares aPropValue but does not visibly seed the whole record before assigning its SaraSetInfo.Id. Its setter and actual compiled behavior should be checked before documenting permissive partial updates.
Notation and shared helper rules: Reading this reference.
No literal rec_type value is emitted directly by the selected routines. A property envelope, an inherited writer or a delegated record can supply its identifying attributes.
Inherited implementation: TBtnEditProperty. Follow it when the ordered behavior invokes inherited methods; inherited fields are not repeated as locally owned fields.
The paths below start at this record or property node. A slash identifies a child element; @ identifies an attribute. Curly braces mark a variable index or expression, not literal XML text. Initial values describe initialization; they do not establish what an omitted individual element does. The Implementation toggle below contains the supplied routines for exact branch order and conversions.
XML representation: The text of the SaraSet.Id element.
Initial value: PropValue (TSaras.Create).
Reading: Converts the stored text to a number and assigns it to aPropValue.SaraSetInfo.Id when the record node exists.
Writing: Stores the text representation of DataValue.SaraSetInfo.Id whenever the writer reaches this field.
Setting or temporary variable
|
Initial value
|
When it is assigned
|
PropName
|
“SARAs”
|
Always
|
Required
|
2
|
Always
|
PropValue
|
Default (TSL_PropValue)
|
Always
|
PropValue.SaraSetInfo.ID
|
- 1
|
Always
|
PropValue.SaraSetInfo.Name
|
an empty string
|
Always
|
DataValue
|
PropValue
|
Always
|
This routine also calls inherited Create; self.FillDisplayValue. See Implementation for their order and any conditional calls.
These are in-memory member and property types, not a list of mandatory XML children. They retain array bounds, fixed buffers and selector types. The field reference above defines what is actually serialized.
The Implementation toggle contains only TSaras methods. Initializers and helpers belonging to other types are identified separately below. Shared XML-helper limitations are explained in Reading this reference.
Implementation
// cpSaras.pas — TSaras.Create
constructor TSaras.Create;
var
PropValue : TSL_PropValue;
begin
inherited Create;
PropName := 'SARAs';
self.Required := 2;
PropValue := Default(TSL_PropValue);
with PropValue.SaraSetInfo do
begin
ID := -1;
Name := '';
end;
self.DataValue := PropValue;
self.FillDisplayValue;
end;
// cpSaras.pas — TSaras.ReadFromXML
procedure TSaras.ReadFromXML(const propertyNode: TXmlNode);
var
node : TXmlNode;
aPropValue: TSL_PropValue;
needsSaving : boolean;
aRec : TSaraSetInfo;
begin
// do not call inherited to avoid $message Hint 'PARTIALLY_IMPLEMENTED: missing ReadFromXML()'
needsSaving := false;
node := propertyNode.Find('SaraSetInfo');
if node <> nil then
begin
aRec := Default(TSaraSetInfo);
node := node.Find('SaraSet.Id');
if node <> nil then
begin
aPropValue.SaraSetInfo.Id := StrToInt(node.Text);
// test
needsSaving := true;
end;
end;
if needsSaving then
begin
// at the end assign the full structure
self.DataValue := aPropValue;
end;
end;
// cpSaras.pas — TSaras.SaveToXML
procedure TSaras.SaveToXML(scriptLineNode: TXmlNode; var propertyNode:
TXmlNode);
var
node, node2 : TXmlNode;
begin
propertyNode := scriptLineNode.AddChild('property');
inherited;
node := propertyNode.AddChild('SaraSetInfo');
node2 := node.AddChild('SaraSet.Id');
node2.text := self.DataValue.SaraSetInfo.Id.toString;
// SaraSetInfo.Name is saved for human convenience in looking at the XML
// will not be read from XML, but rather be looked-up in TSaras.SetDataValue
end;
initialization
lstColorNotInTemplate := TStringList.Create;
lstColorNotInTemplate.Sorted := true;
lstColorNotInTemplate.Duplicates := dupIgnore;
lstStrokeStyleNotInTemplate := TStringList.Create;
lstStrokeStyleNotInTemplate.Sorted := true;
lstStrokeStyleNotInTemplate.Duplicates := dupIgnore;
lstTextStrokeFillings := TStringList.Create;
lstTextStrokeFillings.Sorted := true;
lstTextStrokeFillings.Duplicates := dupIgnore;
lstOverprints := TStringList.Create;
lstOverprints.Sorted := true;
lstOverprints.Duplicates := dupIgnore;
lstOpacities := TStringList.Create;
lstOpacities.Sorted := true;
lstOpacities.Duplicates := dupIgnore;
lstLeadings := TStringList.Create;
lstLeadings.Sorted := true;
lstLeadings.Duplicates := dupIgnore;
lstColorNotInScript := TStringList.Create;
lstColorNotInScript.Sorted := true;
lstColorNotInScript.Duplicates := dupIgnore;
lstMissingFonts := TStringList.Create;
lstMissingFonts.Sorted := true;
lstMissingFonts.Duplicates := dupIgnore;
lstMissingImages := TStringList.Create;
lstMissingImages.Sorted := true;
lstMissingImages.Duplicates := dupIgnore;
lstBoundingBoxErrors := TStringList.Create;
lstBoundingBoxErrors.Sorted := true;
lstBoundingBoxErrors.Duplicates := dupIgnore;
finalization
FreeAndNil(lstBoundingBoxErrors);
FreeAndNil(lstMissingImages);
FreeAndNil(lstMissingFonts);
FreeAndNil(lstColorNotInScript);
FreeAndNil(lstStrokeStyleNotInTemplate);
FreeAndNil(lstOpacities);
FreeAndNil(lstLeadings);
FreeAndNil(lstOverprints);
FreeAndNil(lstTextStrokeFillings);
FreeAndNil(lstColorNotInTemplate);
end.
|