We are still working on migrating to the new Bosch Connected Industry Online Portal. Stay tuned! Click here for the latest updates.
10-25-2021 08:37 AM
Hello, dear Nexeed Developer Team,
today I encountered a small nuissance that can be easily fixed.
Problem: In my source code control, I have trouble seeing what changed in an enum.
Reason: The length of the longest item changed. This lead to a change of the comma position at the end of each line, making the code file comparison tool think that each line was changed. So the actual semantic change I made (added or removed items) are not obvious at all.
Solution: Don't align all commas, simply put them at the end of the text (this is also how a normal human would write an enum by hand). To make this happen, the standard export templates of enum types needs to be changed in OES.
I went ahead and modify the otd file accordingly:
<% // --- ENUMERATION %>
<* Enumeration name="<%=@this.Name%>" path="<%=@this.Path%>" Overwrite="True" Comment="<%=@this.Comment%>" Pragma="attribute 'qualified_only'" EnumType="<%= @this.TypeName %>"*>
TYPE <%=@this.Name%> :
(
<% for (int counter = 0; counter < @this.EnumItems.Count; counter++){%>
<% if (!string.IsNullOrEmpty(@this.EnumItems[counter].Comment)){%>
/// <%=@this.EnumItems[counter].Comment%>
<% }%>
<% if (!string.IsNullOrEmpty(@this.EnumItems[counter].ValueString)){%>
<%=@this.EnumItems[counter].Name%><% *luIndex* %> := <%=@this.EnumItems[counter].ValueString%><%= counter < @this.EnumItems.Count-1 ? "," : string.Empty %>
<% } else { %>
<%=@this.EnumItems[counter].Name%><%= counter < @this.EnumItems.Count-1 ? "," : string.Empty %>
<% }%>
<% }%>
) <%= @this.TypeName %>;
END_TYPE
(I took liberty to also remove some useless spaces at the end of the comment lines).
Please consider using this as the new template for the next OES/CPS release.
Solved! Go to Solution.
10-25-2021 09:23 AM
Thanks for your input! This would even be an argument against aligning any code at all. We still prefer aligning assignments for readability reasons. But you are right, aligning the commas does not make much sense. We will change this in Control plus Studio 5.3, but not in any compatible OES updates.
BTW: The blanks at the end of the comment have already been removed in OES 4.11 and CpStudio 5.0.