LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

what event should I use when loading the xcontrol for the first time?

Hi there,

  I have vi there own 4 path controls, each times before I run the vi, I need to manually change the path for those 4 path controls based on the current date (needed to be done in edit mode before running). It is pretty tedious. I am planning to write a xcontrols to get it doen in program. But there is one problem. I will only do that once when the vi first loaded into the memory and before the it is run. Once the path set, even the subvi closed, if only the code remain in memory, even you load the vi again, the code will not be set again. For example, when we just open the vi, set the path, after that, unless close the labview, even we close the vi and open it again, the path will not be changed again. I am trying to get it doen in some event like 'Init' in xcontrol. But in the 'init' event, it will be active only  for the very first time when we drag the xcontrol to the front panel. I wonder if there is any way to achieve that.

0 Kudos
Message 1 of 4
(3,011 Views)

If you want to do it wihtout xcontrol, you can use an uninitialized shift register with a boolean that turns true on the right side. It will only output false when freshly loaded. Use a case structure with code that generates the file names.

 

If you use an xcontrol, you would adapt the "init" code accordingly.

0 Kudos
Message 2 of 4
(2,975 Views)

@altenbach wrote:

If you want to do it wihtout xcontrol, you can use an uninitialized shift register with a boolean that turns true on the right side. It will only output false when freshly loaded. Use a case structure with code that generates the file names.

 

If you use an xcontrol, you would adapt the "init" code accordingly.


I am developing xcontrol. I am also working wiht "init" but I found that "init" will only be active for the very first time the xcontrol being dragged to or created. If I save the vi, close it and open it again, it seems that "init" will not be active again.

 

Second question is how can I update the control value (the path for path control) in "init" activity?

0 Kudos
Message 3 of 4
(2,966 Views)

The init ability is basically called when the XCtrl is loaded into memory : when opening a VI containing the XCtrl or when dragging a new instance on a front panel. The difference between those two cases is the version number of the XCtrl.

Updating the data or the state of the XCtrl through a user interaction shall make you write code accordingly in the Facade ability. 

 

Side note concerning what you want to achieve : the state of a XCtrl is persistent (data in State.ctl is saved when closing/quitting a VI using a XCtrl). Use this at your advantage 🙂

Other side note : I don't really see why you're making a XCtrl in your case, there are numbers of ways to generate new paths names 🙂 (i.e. altenbach's post is relevant !)

 

 

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

0 Kudos
Message 4 of 4
(2,883 Views)