Skip to content
Closed
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]. If parts has fewer than 3 elements, this will raise an IndexError. Add a length check: if len(parts) >= 3 and parts[0].startswith(\"CONFIG\") and parts[2].startswith(\"value\"):

Suggested change
if parts[0].startswith("CONFIG") and parts[2].startswith("value"):
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.

The C path construction only includes the first three parts (CONFIG0__VARNAME.value), but doesn't append any remaining parts from the original path. For paths like CONFIG0.VARNAME.value.table[0].field, this would incorrectly produce CONFIG0__VARNAME.value instead of CONFIG0__VARNAME.value.table[0].field. The fix should concatenate 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