Applies to:
PcVue all versions supporting ascii format for mimics |
||
|
||
Summary:
This article explains how to use regular expressions to modify a set of text files and thus save a lot of time when modifying a project. |
||
|
||
Details:
Regular expressions can be used in modern text editors such as Ultra Edit, PSPad, Notepad++… In a project, we have 4 windows that use the same window template, but not with the same properties inherited from the template. So the graphical rendering is different for the 4 windows, it is not homogeneous: If you want to apply the same properties inherited from the template for all 4 windows, you can do it easily with Notepad++ by doing a search / replace with regular expressions. This will be all the more convenient if you manipulate a lot of files. Imagine if we had to homogenize 100 windows… Caution: before modifying your project with external tools, please take care of saving carefully last version of your project.
Then we have to make sure that the mimics are saved in ASCII format so that we can modify them with a text editor. The easiest way is to use the library converter from the Display menu. The library converter will close all open mimics before appearing. Then select the concerned library, check the option Mimics and convert to ASCII format: In our example we want all 4 windows to use the same inherited properties as the first one: We open this mimic with Notepad++ to find the line that starts with TEMPLATE near the top of the file. This line defines not only the window template used by the View1 window, but also all the properties inherited from the template: Now you have to replace the TEMPLATE line of the other 3 files using this : To do this, launch the file search tool by clicking on the menu Search –> Find in Files… Here we use the regular expression “.” (dot) which means any character in the Find what field. Here is the configuration that is appropriate in our case : Another simpler regular expression could be used in that case: Press the Replace in Files button and confirm. Caution: files are automatically saved, so it is not possible to undo the modifications. The 4 files in the W directory are then modified and homogeneous. Here is the result after closing and opening the 4 new windows : Another example. A search and replace in the COMM.dat file with the following regular expression allows to change IP address of all PLCs to redirect them on a local simulator: Search: ,\d{1,3}#\d{1,3}#\d{1,3}#\d{1,3}#\d{1,3}#0#0#10#0#0#0#0#0 |
||
Another example. Since PcVue version 16, protoc.dat file in Bin directory has been replaced by CimWayProtocols.xml file. A search and replace in that xml file allows you to redirect all the protocols so that they use the simulation protocol: Search: filename=”cwp.*.dll” |
||
|
Created on: 03 Apr 2020 Last update: 04 Sep 2024