Jump to content

How do I programmatically save a control?


crelf

Recommended Posts

HI Chris

You can use the scripting function Select object and the Copy it and then past in a new CTL file.

But the problem is that you are not allowed to copy an object from a running VI, so you have to first take that VI and do a file-copy/"save as" of it to a new name, open that VI and then you can Copy and Past in to a typedef CTL file.

//Mikael

Link to comment

QUOTE (Ton @ Jan 29 2009, 04:00 PM)

post-2399-1233262822.png?width=400

But doesn't that just create a new control with the value of the existing control? I want to save the control itself so I get to keep all the attributes (caption, colors, size, etc).

QUOTE (neBulus @ Jan 29 2009, 03:49 PM)

Is it possible to use that ref to drop a new control of a new VI and save it as a .ctl?

I don't understand that sentance - can you please give it another go?

Link to comment

QUOTE (crelf @ Jan 29 2009, 10:05 PM)

But doesn't that just create a new control with the value of the existing control? I want to save the control itself so I get to keep all the attributes (caption, colors, size, etc).

Yep, I get what you want.

I don't think this can be done in a truly fully generic way programmitically.

The routine 'Right Click->Advanced->Customize->{(Strict)TypeDef}->Save' is what you need.

I've got a feeling that this is not possible.

One could write xml/ini based solutions but they are tight to control types. Would make a wonderful class routine.

Ton

PS, learn how to ask questions on twitter in 160 characters...your initial question seemed so much simpler

Link to comment

QUOTE (crelf @ Jan 29 2009, 03:47 PM)

http://lavag.org/old_files/monthly_01_2009/post-10515-1233264886.png' target="_blank">post-10515-1233264886.png?width=400

EDIT: Now that I read your original post carefully... you have a reference to an existing control. I wonder if it's as easy an shown. I'll check quickly and come back.

EDIT 2: OK. I should have checked Ton's VIs. Mine looks like a very rudimentary version of his. I guess if it didn't do it, I'm off too.

Link to comment

Once again, all the folks on LAVA prove their worth (and thanks also to those who came to my rescue through twitter!) It was the unnamed method that I was looking for:

post-181-1233268997.png?width=400

QUOTE (Ton @ Jan 29 2009, 04:09 PM)

PS, learn how to ask questions on twitter in 160 characters...your initial question seemed so much simpler

Unfortunately I use twitter4skype and it doesn't limit the number of chars I can type, so I often get cropped - sorry about that :unsure:

Link to comment

QUOTE (crelf @ Jan 29 2009, 02:47 PM)

That's because a control is not an instrument.

A *control VI* is an instrument, and those you can save.

To highlight the difference, let me point out that you could open a VI reference to a control VI and then get a control reference to the single control on that VI's front panel. A control reference is always to a part of a VI, which is not a file in and of itself.

QUOTE (crelf @ Jan 29 2009, 04:44 PM)

Once again, all the folks on LAVA prove their worth (and thanks also to those who came to my rescue through twitter!) It was the unnamed method that I was looking for:

You could also use methods for Copy Selection / Paste Selection to copy the control from one VI to another blank VI and then save that blank VI.

Link to comment

QUOTE (Aristos Queue @ Jan 29 2009, 06:06 PM)

Right - that's what took my brain a few minutes to comprehend :)

QUOTE (Aristos Queue @ Jan 29 2009, 06:06 PM)

You could also use methods for Copy Selection / Paste Selection to copy the control from one VI to another blank VI and then save that blank VI.

Someone else mentioned that (twitter conversation?) - can you throw together a quick example of using those methods if you've got the time please?

PS: when are you going to get yourself on twitter? :)

Link to comment

QUOTE (crelf @ Jan 29 2009, 05:51 PM)

PS: when are you going to get yourself on twitter? :)

I tried describing Twitter to AQ at either the Norm lunch or the JKI lunch (can't remember which...they were both at the same place, with some of the same people) and I got confused looks and rolled eyes. I'm guessing we won't see him on there anytime soon...

-D

Link to comment

QUOTE (Darren @ Jan 29 2009, 10:44 PM)

I'm so despondant - I thought AQ was one of the cool kids :(

QUOTE (Norm Kirchner @ Jan 29 2009, 10:44 PM)

Something like this Chris?

Oh - yeah - that was going to be my fall-back. Thanks Norm, but I'm glad that the "Create From Reference" method exists.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.