I'm struggling to make a search and replace code that read what to change by global table lookup, so a made a few notes about the command replacedata_s() that I'm using in my logic and I think could help others.
I'm working with equipment TAG, the global table ("ChangeTAG") contains 2 columns with the old and new tags (PX_09, PX_10 and PX_1040XX_09, PX_1040XX_10 for example), that must be changed in other global tables, object names... i.e. other nodes, and for that using replacedata_s() and replacename(). However I would like that the replacedata_s() do not change the strings in my "ChangeTAG" table, so instead of just provide the obj startnode as parameter, an option to give a obj stopnode or an exception to not access a node.
Another point, as you can see, by searching the PX_10 tag, the command replacedata_s() will replace not just the PX_10 tag but also PX_1040XX_09 and PX_1040XX_10, and as "ChangeTAG" is read by a for code (you can see the code bellow) the replacedata_s() will chage the table and depending on the sequence, the new PX_09 TAG change to PX_1040XX_1040XX_09 because the command replace substrings also, a parameter to choose between exact and approximate match would be very helpful.
Table v_gt_Change_Tags = Table("ChangeTAG"); for (int iTAG = 1; iTAG <= v_gt_Change_Tags.numRows; iTAG++){ string v_str_Before = v_gt_Change_Tags[iTAG][1]; string v_str_After = v_gt_Change_Tags[iTAG][2]; replacedata_s(maintree(), v_str_Before, v_str_After); replacename(maintree(), v_str_Before, v_str_After); }
For now I'm segregating the replace commands and the "ChangeTAG" reading into 2 for (to save the TAGs into an array before start to replace them), with the replace's for going thru every bottom node so I can make an if condition to not enter into "ChangeTAG" table. Accepting any ideas to reduce the code.