How to make many SQL tags

This message is mainly aimed at Colby. A short while back while doing a meeting you showed how to do a cut and paste kind of thing using Jython script. I do not recall exactly how you done it but thought this would make a nice posting. So if it does not take up to much time could you write up the proceedure you went thru to accomplish this. Many thanks.

Have a great day.

Hi-

Yeah, I was just showing a little trick I use every once in a while to save some time… really nothing more then a little python scripting, but using the PMI designer as the scripting host, because it’s convenient.

In this case, we needed to make 100 tags, each one identical execept for 1 number, 0-99 (in the name and opc address).

First, I created 1 tag, and exported to CSV. I opened the csv, and did a search and replace to escape quotes, so… from " to " , and then copied that line to the clipboard.

In the PMI designed, I created a temporary window, with a temporary button. In the ActionPerformed event of the button, I wrote a script to run a loop, and print out that line, but with the running number. Something like:

i=0 while i<100: print "myescapedline... item%d, address%d" % (i, i) i=i+1

The point is that the PRINT command prints to the console, from which you can copy and paste. So, I opened the console from Tools->Advanced->Console, and clicked the Clear button.

Finally, I put the designer in preview mode, hit the button, and watched the console. I now had a csv of all the tags I wanted, so I copied from the console, pasted into the file, saved and imported it.

Nothing too special, just a quick way to get it printed out somewhere where you can copy the result. I could do it with any scripting environment, but PMI just happened to be the most convenient since it was already installed :slight_smile:

Hope this helps,

Heh, thats a new one. Not a bad idea. Of course, Excel will do that for you, but as always, the most efficient course of action always depends on tool you’re most familiar with…