LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

QD Shortcut - Chage To/From Array

There is an interesting idea on the Idea Exchange to allow you to convert scalars to arrays (and perhaps back again).  In case you want to try it before you buy it, I am posting a QD shortcut to allow you to do just that. 

 

Add the QD shortcut:  Unzip the attached files, copy to the shortcut folder:  [LabVIEW 2009]\resource\dialog\QuickDrop\plugins

 

Select some terminals on the BD or controls on the FP and do Ctrl-Space Ctrl-a to convert to arrays of the same type.  Ctrl-Space Ctrl-A (that is Shift-a) converts arrays back to their respective scalar types.

 

'a' is one of those shortcuts likely to be stomped in LV2010, so you can choose a different letter (rename a.vi), or be prepared.

 

Having tried it, I think I like the idea.

Message 1 of 24
(5,883 Views)
Kudos! I've often been frustrated by the effort this task requires, and this shortcut will save me a lot of clicks Smiley Happy
0 Kudos
Message 2 of 24
(5,826 Views)

 Thanks Darin!


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 24
(5,617 Views)

Sorry Jeff, testing this slipped my mind.  This version will respect the existing wiring connections (at least most of the time).  Replace the two subVIs with the ones in this zip file.  Nice suggestion, I almost always used this when creating controls or constants, but now it is even more flexible.

 

 

Message 4 of 24
(5,456 Views)
Any chance of making this into a Right-Click-Framework plugin?
0 Kudos
Message 5 of 24
(5,444 Views)

 


GregS wrote:
Any chance of making this into a Right-Click-Framework plugin?

Two new files.  The first a.zip is the latest QD shortcut, I think my source code control (ie. me) screwed up the last one.  The second is my first-ever RCF plug-in.  Seemed like a smooth transition, although I have only done this for BD objects so far.  I don't have the ability to make packages so this is a manual install, just put the plug-in and ini file into the JKI RCF plugin folder and restart the framework.

 

 

Download All
Message 6 of 24
(5,401 Views)
Very nice, thanks!
0 Kudos
Message 7 of 24
(5,395 Views)

GObject has a "Replace" method.  Don't know if this is new since you wrote the plugin, but using replace cleans up the code a bit and maintains connector pane linkage when swapping out the control (and maybe keeps track of a few other things behind the scenes, not sure).  Here's a version that does it that way.

0 Kudos
Message 8 of 24
(4,119 Views)

Good Job, CantankerousBullMoose. I always had my HOMERian "D'oh"-moment whenever I used the shortcut on elements within a structure which would completely break all the connections and delete the SubVI terminal.

 

I have updated your version with two functionalities, now having renamed the VI, put the SubVIs into an appropriate subfolder and changed the default shortcut letter to Z, as A is already taken in my environment for "Align with connector pane". The two functionalities are

1. now works with controlVIs (Custom Controls, TypeDefs etc.)

2. now works on BD constants in the Array->Constant branch

 

This 2nd modification gave me some headaches, one of which still remains. I hope to receive some feedback because I'm not really happy with what I came up with.

Let me explain:

The Replace method requires a Style ID which I couldn't find for a reference of a constant. Therefore I cumbersomely change the constant into a control, get the element's StyleID, replace the Array with the ArrayElement using this StyleID and change the control back into a constant. All in all this works quite well, however RubeGoldberg-like this seems to me.

 

Furthermore, and this is the headache I still have about this, the Replace method changes the numeric representation into the standard for the numeric data type (DBL). For strings, paths etc. this might be irrelevant. But for numeric constants/controls I didn't find a way to tell the resulting element to inherit the original representation. This holds true for controls and indicators as well. I spent quite some time to look (NI commuity, forums etc.) for a way to programmatically change this numeric representation but no joy. So I'll appreciate any hints how to do this in VI Scripting.

 

0 Kudos
Message 9 of 24
(3,930 Views)

There's a Representation property for numeric controls and constants that you can use, it requires that scripting be enabled in Tools > Options:

 

rep.png

Message 10 of 24
(3,908 Views)