LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Network Variable string array

Solved!
Go to solution

Hi all

I am working on a project that would require one program to talk to another program(same computer), hence the use of the network variable.

Now say I have a list or table of names that changes in one program, what I would like to do is take parts of the list that is in one program and transfer certain parts of the list to the other program.

The list needs to be able to transferred with at least 40 single names of different size with letters.

I have the data arrays ready I just need to figure out the transfer part.

I tried the 3D.sim but there seems to be a problem when I am using strings especially when the strings are different lengths.

Also when using the CNVCreateArrarDataValue errors on the array value occur being to small on the array size?

Array listings of strings are usually 2D (Row, and size) does this factor in??

 

Assume network variable is declared

exp code just to get the idea...

 

int i=0, numItems=10;

CNVData data=0, NVlist[120]={0};

size_t dim={0};

size_t dim2={0};

for(i=0;i<numItems;i++)

{

   char listName[20]="/0";

   GetTabelCellValue(panel, PANEL_LIST, MakePoint(2,i), listName);

   dim[0]=strlen(listName);       // i tried size_of but that definalty makes the dim to big

   CNVCreateArrayDataValue(&NVList[i], CNVString, listName,1, dim)    /////i keep getting array size issues here

   dim2++;

CNVCreateStructDataValue(&data, NVList,dim2)    ///here is another issue with dimensions

CNVPutDataInBuffer(Handle, data,2000);

 

i also tried

 

for(i=0;i<numItems;i++)

{

   char listName[20]="/0";

   GetTabelCellValue(panel, List, MakePoint(2,i), listName);

   dim[0]=strlen(listName);

   CNVCreateDataValue(&NVList[i], CNVString, listName)   

   dim2++;

CNVCreateStructDataValue(&data, NVList,dim2)    ///one string value transfers

CNVPutDataInBuffer(Handle, data,2000);

 

i think i am close but jsut cannot get the right sequenceSmiley Sad

Thanks ahead of time

 

0 Kudos
Message 1 of 6
(4,323 Views)

lriddick,

 

It looks like listname is just one string, not an array of strings. 

Humphrey H.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(4,301 Views)

i see the confusion you are mentioning i was tyring to give a free hand code snipit

lets say i have an array

char listName[10][20]
listName[0] ="dog"

listName[1] ="bulldozer"

etc...

Now how do i get the network variable Array or struct to be sent with all the values listed (dog , bulldozer, )

 

 

0 Kudos
Message 3 of 6
(4,296 Views)

What happens if you just send one string at a time and add it into the array on the reader side rather than sending the entire array at once?

Humphrey H.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(4,278 Views)
Solution
Accepted by topic author lriddick

lriddick,

 

You can write an array of strings easily, but it must be an array of strings. It can't be a two-dimensional array of chars, which is not the same thing. For example, the following code should work (I replaced your table with an array called "table" but the rest should be the same). Note that I only create a single CVNData, not an array of CNVData's:

 

    char *table[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"};
    char *listName[10];
    CNVData data=0, NVList;
    size_t dim[]={10};
    for(i=0;i<numItems;i++)
    {
        listName[i] = malloc (strlen (table[i]) + 1);
        strcpy (listName[i], table[i]);
    }
    CNVCreateArrayDataValue(&NVList, CNVString, listName, 1, dim);
    for(i=0;i<numItems;i++)
        free (listName[i]);

    CNVPutDataInBuffer (handle, NVList, CNVWaitForever);

0 Kudos
Message 5 of 6
(4,209 Views)

thanks...

that worked

 

0 Kudos
Message 6 of 6
(4,185 Views)