r/PLC • 800xA|Ac400/500/800|S+ • 4d ago

Engineering Question Formatter for Structured Text

I need to consult the hive-mind here.

Does anybody have a good formatter for Structured Text (dialect is secondary). I need it to be able to properly indent multiple commented lines as, unfortunately, the original creator of the programs (a lot) has decided to disable certain parts with the (# and #) comments and yet uses the (* and *) comments in between the outer comments.

I've inherited this program (which is quite huge) and need to sift through it. Can't just simply omit/delete the commented out code as it is absolutely possible that it will be used at any given time in the future.

The original creator didn't want to think about a mechanism to disable certain parts (each part reflects a particular "Control Unit").

I would be very grateful for any recommendation. My google-fu and my VSCode extension search didn't bring decent results.

Edit: I cannot use any AI as assistant because of the sensitivity of the data. This is also the reason I have to be so vague here in my descriptions. (The bane of working in system-critical infrastructure.)

7 Upvotes

41 comments sorted by

View all comments

Show parent comment

1

u/TheFern3 Software Engineer 4d ago

Then you gotta learn how to use grep awk or make a script to parse examples of what you have replace sensitive data then ask ai or just figure out how to do that by yourself like we did before ai lol

But what’s the issue you have with the project? If is just comments what are you really fixing here?

1

u/desrtfx 800xA|Ac400/500/800|S+ 4d ago

The comments are a symptom.

The whole thing is a complex calculation with roughly 1200 redundant input signals coming into the system via IEC 60870-104 (multiple sources and destinations) and the whole is application redundant across 2 DCS clusters with 2 DCS controllers each. (Which is a fairly small setup for my normal standards.)

The comments indicate "out of service control units" - these units might be temporarily out of service or permanently. Yet, the commenting out is scattered around all of the project.

We are now in the process of upgrading and improving said project and can't miss any of the commented out parts, which is often not that easy to find because of nested ifs (not good practice, I know), because of multiple levels (also not the best practice), and other factors.

As I've said before: I do know how to make such a script but was just asking to see if someone else had something readily available.

I know my trade well, don't worry.

0

u/TheFern3 Software Engineer 4d ago

I mean if you know “your” trade and can’t use ai I don’t understand why you would think someone would have a custom script for an oddly specific codebase… script would have been done faster than writing a reddit post 🤷‍♂️