LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with CNVGetVariables functionality

Solved!
Go to solution

Hi,

 

A colleague and I have been looking into using the function CNVGetVariables().

 

We couldn't get the function to work as we believed it should work (according to the CVI help files).

 

I then managed to get it to work in a fashion having seen a post on this forum suggesting it worked solely for variables on the host system (see post http://forums.ni.com/t5/LabWindows-CVI/NetworkVariablePopup-only-shows-running-processes/td-p/115864...)

 

However, I was using CVI 2010 and my colleague was using CVI 2012. The help in CVI 2010 suggests that CNVGetVariables() refers to processes on the host machine only, and forbids the use of process names containing '\' characters - however, the help in CVI 2012 suggests that it is possible to specify processes on other machines and explains how to use '\' characters with escape sequences - this is the functionality that we can't get to work in CVI 2012.

 

For instance, my local machine reports having a process 'weather data' which has several example network variables associated with it.

 

CNVGetVariables("weather data", &MyVariableList, &iNumVars); works correctly, but

CNVGetVariables("\\\\localhost\\weather data, &MyVariableList, &iNumVars); returns with result -6393 "Argument is invalid"

 

I think the help is rather opaque in specifying how URLs should be stated, but it may seem to suggest that because I am using '\' characters, then I should use:

 

CNVGetVariables("\\\\localhost\\'weather data', &MyVariableList, &iNumVars); but this too returns with -6393 "Argument is invalid"

 

What am I doing wrong?

 

Thanks

Chris

0 Kudos
Message 1 of 10
(4,502 Views)

Hi Crispie,

 

Could you just check the formatting of 

 

CNVGetVariables("\\\\localhost\\weather data, &MyVariableList, &iNumVars);

 

I do not believe 4 "\" are needed. You also require " ' " either side of the process name. If you keep to the formatting laid out in CVI help what do you get? 

The help file gives this  - \\localhost\\'process''Name'\'variable.Name'.

 

 

Nathan
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 2 of 10
(4,455 Views)

Hi Nathan,

 

I have tried without the four backslashes, and get the same error. In this instance, I suspect the help file of being wrong, as in other functions using network variables, four backslashes are required, for instance with the function CNVCreateSubscriber().

 

The formatting stated in the help file is for specifying a process variable, and not an actual process, and whilst I think that I've understood what it is implying I can't get it to work.

 

The formatting stated in the help file is also inconsistent; the help file reads:

 

For example, to specify \\localhost\process'Name\variable.Name as a URL, enter the following:

  • 'process''Name' as the process name
  • 'variable.Name' as the variable name


The resulting URL is \\localhost\\'process''Name'\'variable.Name'.

Note that the double backslash is represented as a double backslash in the 'resulting URL', but so is the single backslash. I have tried many variants without success, and just want to know what will work.

 

Thanks

Chris

0 Kudos
Message 3 of 10
(4,448 Views)

The Network Variable Configuration functions like CNVGetVariables only work for network variable processes and variables on the local machine. Also, these functions do not expect or support passing a machine name in the 'Parent Path' parameters - if you pass a machine name here, the function should return an error. I see the following in the help for the Parent Path parameter of the CNVGetVariables function:

The network variable path. You can specify a process name or a process name
followed by one or more folder names delimited with the backslash path
separator. Do not include a trailing backslash in the path.

So, the correct argument to pass for this parameter in your case is "weather data". Note again that you cannot get the variables from network variables process running on remote machines.

0 Kudos
Message 4 of 10
(4,443 Views)

Crispie's point is that the text in the help file has changed between CVI 2010 and CVI 2012.

In CVI 2010, it states:

 

Purpose

Obtains the names of the variables in the network variable process you specify

 

 

In CVI 2012, the helpfile for the same function now states:

 

Purpose

Obtains the names of the variables in the network variable path you specify.

 

 

Why would this have changed, if not to imply that the function has been upgraded to interrogate any Network Variable server that the machine can connect to?

Even if it can only get variable names on the local machine, why does the documentation not clearly state that?

0 Kudos
Message 5 of 10
(4,433 Views)

Hi Mohan,

 

As I notice has been pointed out - the help text you quote is from CVI 2010, and in CVI2012, it reads differently, which I take to mean that the functionality has been upgraded, which I believe is the point of the whole query - if the help file has changed then why, and if was because new functionality has been added, then how do we use it correctly?

 

Cheers

Chris

0 Kudos
Message 6 of 10
(4,425 Views)
Solution
Accepted by topic author Crispie

The reason the documentation states "path" in 2012 versus "process" in 2010 is because in 2012 this function also supports Network Variable folders - not remote machines. Before 2012, callers can only get the variables directly under a process and cannot get the variables under a network variable folder or sub-folder.

 

And, by the way, I did quote the help from 2012.

0 Kudos
Message 7 of 10
(4,410 Views)

Mohan,

 

You are right - sorry about that - the 2010 help mentions explicitly that backslashes may not be used as part of the process name, and I assumed you were quoting that part.

 

Thanks also for explaining about the folders.

 

I would still suggest that the example quoted in the help file of how to specify a path implies that machine names/ip addresses can be specified.

 

For example, to specify \\localhost\process'Name\variable.Name as a URL, enter the following:

  • 'process''Name' as the process name
  • 'variable.Name' as the variable name


The resulting URL is \\localhost\\'process''Name'\'variable.Name'.

This rule does not apply to computer names.

 

Thanks again,

Chris

0 Kudos
Message 8 of 10
(4,400 Views)

Ah, I understand. I wrote bug ID 396521 to fix the example path in the documentation.

0 Kudos
Message 9 of 10
(4,373 Views)

OK - thanks.

0 Kudos
Message 10 of 10
(4,367 Views)