LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create cases acording to a global variable type "Byte Stream File reference"?

I have 8 global variables and I would like to use the same VI for a specific reading and writing of those files.

The variables are the type "Byte Stream File reference".

How can I create a case structure where I will use a different shift register for each case, using the name of the variables as the name of the cases?

For instance, I have "Text files" and "Results files" as the name of the global variables and I would like to create different cases for each of them, considering that I dont know the content of those files.

Find attached just an example with only one of those variables.

 

 Thank you,

 

Thais Marques

 

0 Kudos
Message 1 of 16
(3,191 Views)

Hi ths,

 

just two three points:

- You cannot wire an array (of any type) to a case selector.

- You cannot wire a reference (of any type) to a case selector.

- You cannot select cases by the names of global variables connected to case structures selector. (What's the point in trying to do so? The connection is static and done at development time, so you know which global is connected...)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 16
(3,188 Views)

Try investigating the concept of LVOOP

 

in LVOOP (classes) you have the ability to use the concept of dynamic dispatch to automatically call child methods

- James

Using LV 2012 on Windows 7 64 bit
0 Kudos
Message 3 of 16
(3,178 Views)

Just to explain , I use this VI several times in my code... I want to use the same VI for doesn't matter which global is connected (actually I dont know which one is connected, depends of each step in my test), I just send attached a simplification of what I am doing. And the purpose is also because in the future I may have even more than 8 globals using this VI.

 

So, for the moment I am improving this existing VI and now, as I need to use different shift registers for each global, I really need different cases.

 

I know that an "stupid" (and somehow easy) solution could be to create one VI for each global, but then I have to replace those VIs in my whole code (several times when it appears) and in the future will also require more work if I need to keep improving this.

 

That is why I need one VI that allows me to use different shift registers according to the global that is connected in that moment!

I know that I can not connect this directly to the case structure, I just wonder if there is any manipulation of data that can, for instance, read the name of the global and convert it to a string.... or something like this...

 

II will read more but please, maybe somebody has any idea how to make it, I appreciate 🙂

0 Kudos
Message 4 of 16
(3,160 Views)

Hi ths,

 

when you want to use references as shown you can get the label of the referenced control and use that label as selector for the cases. Be sure to use the correct name for the cases. And you need to use a (FOR) loop around your case structure...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 16
(3,158 Views)

, I really didnt figure out how to get the label from this kind of type of data. My refnun doesnt keep the label from the label of the global. in the moment I have 8 globals, but maybe 100 different refnuns (because depends of each test).

 

for the moment I am using an existent enum whichcontains the name of those globals, but is bad because I need to add this enum everywhere I call this VI to conect to this new input 😞

 

0 Kudos
Message 6 of 16
(3,142 Views)

Hi ths,

 

sorry, I mixed up the file references with control references...

 

The enum approach seems to be the way to go. I really recommend to define the enum as type definition!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 16
(3,137 Views)

yes no problem... It was already a typedef... and ok, not so much work to put this in my code...

now I have other troubles with this writing data because the modification i did in the VI completely destroyed my results files 😞 lets see... but thanks for attention!

0 Kudos
Message 8 of 16
(3,131 Views)

Perhaps you want something like this:

0 Kudos
Message 9 of 16
(3,115 Views)

sorry pcardinale, I can't open your VI. I currently use LV v.9.0.1.

0 Kudos
Message 10 of 16
(3,098 Views)