Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ProjectController.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ def GetIECProgramsAndVariables(self):
parts = [config_FB] + parts[2:]
attrs["C_path"] = ".".join(parts)
else:
attrs["C_path"] = "__".join(parts[1:])
# Check if this is a global array/struct variable at CONFIG level
# Pattern: CONFIG0.VARNAME.value.table[x] or CONFIG0.VARNAME.value.fieldname
# These should become: CONFIG0__VARNAME.value.table[x] or CONFIG0__VARNAME.value.fieldname
if parts[0].startswith("CONFIG") and parts[2].startswith("value"):
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition assumes parts has at least 3 elements, but there's no length check before accessing parts[2]. This will raise an IndexError if the path has fewer than 3 parts. Add a length check: if len(parts) >= 3 and parts[0].startswith('CONFIG') and parts[2].startswith('value'):

Copilot uses AI. Check for mistakes.
# Global array or struct access - keep CONFIG prefix
attrs["C_path"] = parts[0] + "__" + parts[1] + "." + parts[2]
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation only handles paths with exactly 3 parts (CONFIG0.VARNAME.value), but the PR description mentions supporting patterns like CONFIG0.GLOBALVAR.value.table[0] which would have 4 or more parts. The remaining parts (beyond parts[2]) are discarded. Consider joining all parts from index 2 onwards: attrs['C_path'] = parts[0] + '__' + parts[1] + '.' + '.'.join(parts[2:])

Copilot uses AI. Check for mistakes.
else:
# For resource-level variables (RES0.INSTANCE.xxx)
attrs["C_path"] = "__".join(parts[1:])
else:
attrs["C_path"] = "__".join(parts)
if attrs["vartype"] == "FB":
Expand Down
Loading