How can I easily convert on-board i/o to modbus i/o in my program

I have an old program that is about 15 miles long. Unfortunately, when the program was made, i/o was not linked to variables or anything, so all the i/o is called out directly in the program.

The installation has changed and the program must be updated to use modbus i/o now instead of on-board digital i/o.
How can i convert the thousands of i/o points in my program? Is there some kind of find/replace function i’m not seeing, can i modify the program files in some way to do this?

Oof. Short answer as far as I’m aware is no, you aren’t missing any find and replace easy option. If it were me, I might try opening the .script file in notepad++ or some similar text editor and then do some data manipulation. Delete everything that comes from the Installation node, since that will be generated again anyway. Delete all the lines that start with the $ since those are just labels. Then find and replace all your IO. Then in Polyscope your program is just a single Script node set to run that entire program. You’d sort of be locked into making any edits that way, would be unable to easily touchup waypoints, etc. It would definitely not be ideal, but I have no idea what your setup looks like. Maybe someone else knows of some .script to .urp conversion platform or something.

1 Like

Hey thanks, Eric. This is exactly what I spent all day yesterday doing.
Fortunately, I was able to break up the code into “Evaluation sections” (where almost all my digital inputs references and conditionals were) from the movement sections (very few I/O points in the movement sections).

Each evaluation section was turned into a script where I could easily find/replace the I/O, then dropped into the existing program. This way I had very few I/O points to change in Polyscope, but retained the ability to touch up points easily.

Side note I had to delete around 5000 line labels (lines starting with a $) in the scripts. For anyone who needs an easy way, if you have a code editor that can take a regex statement in the find/replace (I used VSCode). Use the following 2 regex statements to find and completely remove all those line labels:

  1. \s*\$\s\d*\s".+"       (This selects all those $ lines. Then just replace with nothing)
    
  2.  ^\s*$\n               (This Selects all the blank lines that the previous operation leaves. Then replace with nothing to remove the blank lines.)
    
2 Likes