Fredxxx Posted December 15, 2010 Report Share Posted December 15, 2010 Hello everybody, my aim is to rename all different objects, nodes, constant, in a huge program, which have a specific prefixx ( f.e.. XX_ ) as Value or as label. Normally i would use the find-dialogbox, search for the string "XX_" and replace it with the new rrefix (f.e. New_). But i have to do this with scripting programatically. Does anybody know a function or a routine, which can do this? Thanks a lot! Greetz Fred Quote Link to comment
jgcode Posted December 15, 2010 Report Share Posted December 15, 2010 Hi Fred Here is a sample snippet to get you started that you can use to change the Label Text of a Front Panel Control. Cheers -JG Quote Link to comment
jcarmody Posted December 15, 2010 Report Share Posted December 15, 2010 (edited) Does anybody know a function or a routine, which can do this? Here's the best way I know to find stuff anywhere in a VI; it's called TRef Traverse for References.vi. Feed it a VI reference and it will find every instance of the specified Class, no matter how deeply nested they are in various structures, which you can operate on as JG suggested. I've attached an example (in two VIs) that you can try. Download them to the same directory and run shooter.vi; it'll find (by name beginning with "XX_") and rename the Boolean constant that is buried in a Diagram Disable Structure in an Event Structure in a While Loop. <EDIT> Added shooter/target example <\EDIT> target.vi shooter.vi Edited December 15, 2010 by jcarmody Quote Link to comment
jcarmody Posted December 15, 2010 Report Share Posted December 15, 2010 With Undo, because experimenting is easier if you don't have to manually rename stuff back. Quote Link to comment
Fredxxx Posted December 21, 2010 Author Report Share Posted December 21, 2010 Hey friends, thanks a lot for your help. Especially the advice with UNDO is very useful!!! Greetz Fred Quote Link to comment
jcarmody Posted December 21, 2010 Report Share Posted December 21, 2010 I played around a bit further hoping to make it more general by searching for GObjects instead of each specific type. I came up with this, but it requires adding cases for every type of object you want to address. Perhaps it's not the worst solution... Quote Link to comment
ShaunR Posted December 21, 2010 Report Share Posted December 21, 2010 I played around a bit further hoping to make it more general by searching for GObjects instead of each specific type. I came up with this, but it requires adding cases for every type of object you want to address. Perhaps it's not the worst solution... If you search for "Constant" on the class name you won't need a case for each type as they all have labels. Quote Link to comment
jcarmody Posted December 21, 2010 Report Share Posted December 21, 2010 If you search for "Constant" on the class name you won't need a case for each type as they all have labels. I used the Constant Refnum for Constant instead of BooleanConstant but didn't add all types of constants to the Case Selector. I could search for "Constant" in the Class Name, but I'd just be moving the Case Structure. The other cases include Control, Node, Wire, Control Terminal and While Loop. I'd like to make it generic without specifying every possible type. I'm stuck... Quote Link to comment
ShaunR Posted December 21, 2010 Report Share Posted December 21, 2010 I used the Constant Refnum for Constant instead of BooleanConstant but didn't add all types of constants to the Case Selector. I could search for "Constant" in the Class Name, but I'd just be moving the Case Structure. The other cases include Control, Node, Wire, Control Terminal and While Loop. I'd like to make it generic without specifying every possible type. I'm stuck... Ahhh. IC. Don't bother with PassaMak then 'cos it's mainly UI focused. You have to find the parent that has the attribute you want to cover as many types as possible. Unfortunately, you still have to cast, but you can reduce the cases required. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.