LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find and replace

Solved!
Go to solution

Hi all,

 

One of my co-worker is working on a program with over 100 instances of the same enum (non-type def in constant, control, and property node form).  He needs to update the enum (surprise), so he needs to make modification on all the 100+ enum.  I showed him how to make a type-def, and he can replace the 100+ enum with the new type def.  This is a lot of work manually, so I tried use find and replace, but it will not let me select the new type-def enum that we would like to replace the 100+ enum with.  If I do find and replace, can I exclude the property node?  If I do, would the proerty node get linke to the new enum?

 

What's the best way to accomplish this task?   

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 13
(1,868 Views)

In the search results window when you clicked on the "Replace with" box a functions palette dialog should have appeared. You should then go to "Select a VI" and navigate to the actual type def VI.

Message 2 of 13
(1,859 Views)

The replace with box is either greyed out or blank.  Palette dialog doesn't come up.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 13
(1,854 Views)

What did you search for, and what were your search results? Can you post a screenshot? Is this being done with a project open? What is your LabVIEW version?

Message 4 of 13
(1,852 Views)

It is on my co-worker's computer, but I will try to get a screen shot.  For the serach criteria, I entered the label of the enum constant, and I got a bunch of results, which are expected.  Project was not opened.  LabVIEW version is 8.6.

 

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 13
(1,844 Views)

(Saverio shakes his head) If you entered the label then you are searcing for text, not objects. You have to search for an enum object. Were you expecting to be able to replace text with an enum?

Message 6 of 13
(1,826 Views)

Haha.  Good call.  I am not very familiar with this function.  Now I know how to change the label with find and replace :).  I guess for what I want, I need to do find object, instead of finding text.  I tried to find object, but I ran into a few problem.  See attached what the example that I was playing with.

 

1. I was able to find all the enum constants and replaced them with something else.  Is it true that I can only replace with similar data type?  For example, I can't replace an enum constant with an add function.  I tried to change enum to ring, ring to numeric, and numeric to enum.  They worked, but sometime, there is a glitch, where I have to do find and replace twice to get it to work.  Have you seen this before?

 

2. I was able to find enum constants easily, but for enum controls, I needed to go under others -> front panel terminal.  I found the controls, but there is a backward slash sign next to it.  I assumed that it meant cannot be operated upon.  I tried to replace the enum control with some else, and I can't.  How do you do find and replace on a enum control (not constant).  

 

Thanks!

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
Download All
0 Kudos
Message 7 of 13
(1,819 Views)
Solution
Accepted by topic author jyang72211

@jyang72211 wrote:

1. I was able to find all the enum constants and replaced them with something else.  Is it true that I can only replace with similar data type?  For example, I can't replace an enum constant with an add function.  I tried to change enum to ring, ring to numeric, and numeric to enum.  They worked, but sometime, there is a glitch, where I have to do find and replace twice to get it to work.  Have you seen this before?


Yes, there are some replacements which won't work since they simply don't make any sense.

 


2. I was able to find enum constants easily, but for enum controls, I needed to go under others -> front panel terminal.  I found the controls, but there is a backward slash sign next to it.  I assumed that it meant cannot be operated upon.  I tried to replace the enum control with some else, and I can't.  How do you do find and replace on a enum control (not constant).  

The Search and Replace does have some limitations, and you've encountered one. You can do what you want to do by scripting. See attached example, which replaces controls that have a label that starts with "cc" with the typedef. The criteria for which controls to replace is up to you. I simply chose that based on the example VI that you provided. Modify as needed.

Message 8 of 13
(1,815 Views)

Thanks for the script.  I have one more related question.  If I do a find and replace on a enum constant, can I have multiple criteria?  Right now, when I do find, the only criteria is enum constant object.  I want to find enum constant with the label "enum123". 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 9 of 13
(1,803 Views)

I tried your script, and I am getting an error, 1154 Invoke Node in replace enum control.vi<APPEND>Method Name: <b>Replace</b>.

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 10 of 13
(1,786 Views)