LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why string arrays not allow in shared variables?

I'm changing a program to replace some global variables with shared variables.  The need for an executable is the reason the globals are being replaced with SV's.  At least one of the variables is a 2 diminsion array of strings.  Under the 'data type' drop down list on the shared variable properties there is no option for an array of strings among the 28 posibilities.  Any way this can be accomplished?  I'm using version 8.0
thanks, Mike
0 Kudos
Message 1 of 17
(4,762 Views)
Hi!

I think you should try with the Variable type Shared Variable. First you have to cast anything into Variable type, then you can write it into a variable type shared variable, and on the other side, when you read it back you have to cast it back to the proper data type.


I hope this will help you!

Regards,

       Peter Smith
0 Kudos
Message 2 of 17
(4,757 Views)
I'm using 8.5, and there is an "Array of String" data type available.

You will need to create a custom control for the 2d array of strings data type.  Right click a node in your project and do New->Control.  In the control place an array, add your string control/indicator, and then add your 2nd dimension.

Save the control somewhere convienant.  Now, add a shared variable and select "From Custom Control..." from the Data Type drop-down.  Select whatever you saved the 2d array of strings control as.  That should do it.
0 Kudos
Message 3 of 17
(4,736 Views)
thanks for the suggestion Peter.  I will look into that as a possibility.
0 Kudos
Message 4 of 17
(4,706 Views)
Thanks Nick.  Seems kind of complex but then I've never messed with custom contols so maybe it won't be so bad.  Guess i could always upgrade. 
0 Kudos
Message 5 of 17
(4,701 Views)
There really isn't anything to the type of custom control you need.  Just place the data type as a control on the front panel and save it as a control is all you need.

I will typically use this approach for cluster data that I have defined and need to use as a shared variable.

The other approach that was suggested to use the Variant data type will work equally as well.  The first thing that popped into my head was that using the Variant data type would be waistful in terms of memory usage, but then I remembered that you are using strings which will use about the same amount of memory as the variant type.  Although you will be casting into the Variant data type and casting back into your 2d array of strings...
0 Kudos
Message 6 of 17
(4,696 Views)
If your data type was a 2d array of boolean values, for example, than casting that into a Variant data type would be extremely waistful... although I'm not sure how the variable engine eventually packages everything up and sends across the network so I could be completely wrong.
0 Kudos
Message 7 of 17
(4,694 Views)
Nick, I am attempting your solution.  I upgraded to 8.5, created a custom control as a 2 diminsional array and made it a shared variable.  it works fine in uncompiled mode but when the programs are made executables the array info is not passed.  Now I have to say I find the whole compile process with Labview pretty confusing so I'm guessing I'm doing something wrong in that procedure or I am simply misunderstanding this whole data passing concept on some fundemental level. .  I have attempted several different compile property setting under the "Source Files" page.  Both the write and read programs are in one project along with the custom control and the shared variable.  I compile two applications using the write and read vi's as startup files and have included the custom control and the shared variable in the "always included" area.  I've tried including the last two files or not including them in the compile and it makes no difference.  Setting the variable as 'single process or  'network published'  makes no difference either.   
0 Kudos
Message 8 of 17
(4,661 Views)
Sorry, posting a project file doesn't seem to supply the necessary files so here are the files included in the project.
Download All
0 Kudos
Message 9 of 17
(4,656 Views)
You also need to post the library where you keep your Variables.  It would be more helpful if you zipped up the contents of your project and post the zip file.

Did your executable work without the custom control, and with one of the built in data types?

Are you trying to run these executables on computers that don't have LabVIEW installed?

I am not 100% sure, but I think you will need to include the .ctl file in your build directory or even include it in the executable as one of the source files.

If you are installing the executable to a machine that does not have LabVIEW installed then you will need to create an "installer" that includes the variable engine.

Yes, I agree... building executables takes awhile to get use to and isn't very intuitive.

-Nic
0 Kudos
Message 10 of 17
(4,641 Views)