LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to have diagram text/comments tied to typedef?

Solved!
Go to solution

Greetings,

      Does anybody have an idea of to have diagram-text updateable via a typedef  - so that updating the typedef changes the text seen by programmers?.

 

I've tried using a string with a default-text value, but it doesn't work well for me.  With string-typedef, at best, constant-text initially appears in the diagram-constant but text doesn't update with changes to typedef.  At worst, no text appears in constant on the diagram.

 

LV 2009

 

Thanks/Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 1 of 7
(3,263 Views)
There's an article on the Eyes on VIs blog entitled There Are No Strict Type Definition Constants which might help you understand why that won't work. It boils down to the fact that you're not modifying the type of the constant.  You'd need a strict type definition to capture cosmetics but, as the article explains, there's no such thing.
Message Edited by jcarmody on 04-12-2010 03:26 PM
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 7
(3,241 Views)
Solution
Accepted by topic author tbd
You can do it with scripting.  This snippet can be run from the Tools menu and it will update the first String constant it finds with the default value of its Type Def.  It can easily be modified to update all String constant Type Defs.


Scripting.png
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 7
(3,229 Views)

Hi Jim,

      Thanks for the utility!  I like the simplicity of running it from the tools menu - though it implies any LV installation needs this tool to do the maintenance(?)

 

May be the best solution anyway.

 

Thanks/Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 4 of 7
(3,215 Views)
If you're familiar with the scripting API you can modify it to suit your purposes.  Lemme know if you need help; I have a few ideas.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 7
(3,196 Views)

Just scratching the surface re: scripting.  Built a utility to create FP cluster typedefs from a database, still fine-tuning the results/cosmetics.

 

Hey, on the OP subject, I got close to the optimal/simple solution by embedding text in an enumerated type.  Though each enumeration is limited to about 256 chars, that's plenty enough for a line of text.  So my 12 lines of comments became 12 enumerations, and the typedef is an array of this enum.  Editing the typedef causes diagram array-constants to return to displaying a default of one value, but that's OK.  The important thing is to have accurate information available locally (on the diagram) and the constant can be expanded and saved by anyone editing a diagram after a typedef change.

 

Thanks/Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 6 of 7
(3,188 Views)

The enum array is one way you can do this. Another is a modification of Jim's example - you can open a reference to the typedef VIs, get its callers property (which will return all VIs which call it), then open a reference to each of those VIs and use the traverse VI from vi.lib\utility to traverse the diagram for string constants, and for each constant check its typedef property to see if its your typedef. If it is, you can modify it.

 

This will handle all VIs currently in memory, but it takes time and won't handle VIs not in memory, so I wouldn't recommend it.


___________________
Try to take over the world!
0 Kudos
Message 7 of 7
(3,174 Views)