hexagon logo

Script to modify a series of .PRG files

I have a need to automate the following process:

Loop through a set of .PRG files that are in a common directory. For each file do the following:
1) Open the file
2) Locate a specific command in the program
3) Delete all commands in the program after the command located in step 2
4) Add a set of dimension commands after the command identified in step 2
5) Launch the PCD2EXCEL wizard to output a .CSV file containing the data from the commands added in step 4
6) Close the file

Has anyone had to do something similar? Is anyone willing to share their code for any or all of these actions?

Thanks for any help.
Parents
  • Hi Ninja,
    Thanks for the help. Yes, I do have excel 2016. I am currently using PCDMIS 2016 but could install any version for this application. Can also have any other common package that might be needed. No limits there really. Visual Studio, Python, whatever...

    The command in #2 could either be a comment or could be an alignment. I would guess alignment is a bit easier to target since it has a specific name. Also might be able to target using UUID. My only concern with that is that some of these programs are really old and not sure if UUID changes when other commands are added after the fact. If not then UUID will probably work,

    Unfortunately I can’t post any of the actual code here. I will be able to modify anything that you can give me to work on my specific application. For the sake of demonstration just have it insert two location dimensions with XYZ fields.

    I am quite comfortable with scripting so if you are able to provide even provide a framework with chunks of code here and there that need to be integrated I can very likely get it working from there. Any help you can provide is much appreciated. Just too overloaded right now to put the needed attention to this to develop from scratch.

    I’ll post my final working version, minus any application specific data, here when I’m done.
Reply
  • Hi Ninja,
    Thanks for the help. Yes, I do have excel 2016. I am currently using PCDMIS 2016 but could install any version for this application. Can also have any other common package that might be needed. No limits there really. Visual Studio, Python, whatever...

    The command in #2 could either be a comment or could be an alignment. I would guess alignment is a bit easier to target since it has a specific name. Also might be able to target using UUID. My only concern with that is that some of these programs are really old and not sure if UUID changes when other commands are added after the fact. If not then UUID will probably work,

    Unfortunately I can’t post any of the actual code here. I will be able to modify anything that you can give me to work on my specific application. For the sake of demonstration just have it insert two location dimensions with XYZ fields.

    I am quite comfortable with scripting so if you are able to provide even provide a framework with chunks of code here and there that need to be integrated I can very likely get it working from there. Any help you can provide is much appreciated. Just too overloaded right now to put the needed attention to this to develop from scratch.

    I’ll post my final working version, minus any application specific data, here when I’m done.
Children
No Data