From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get tag list from LabView DSC using C++ Active X

I am trying to read the group list from LabViewDSC 6.1 using C++ and Active X.
I started from the Aquire6 example and modify it to load Get Group List.vi.
The problem I have is that I can read a boolean or a number control, but a string
array control makes the program crash.
I will appreciate any hints on how to read "group list" and "error out" controls.

Thanks.



// Acquire.cpp : This source code is an Automation client. It calls the
// LabVIEW 6.0's automation server. It loads the VI Acquire 1 Point from 1 Channel
// VI and runs it.
//

#define VC_EXTRACLEAN
#define _WIN32_WINNT (0x0400)
//#define LABVIEW_70

#include "windows.h"
#include "stdio.h"
#include "conio.h"
#include
#include
#include
#ifdef LABVIEW_70
#import "\Program Files\National Instruments\Labview 7.0\RESOURCE\labview.tlb"
#else
#import "\Program Files\National Instruments\Labview 6.1\RESOURCE\labview.tlb"
#endif


int main(int argc, char ** argv)
{
int size = 0;
char Path[1000],Password[60] = "";


// define the path to the application
char VIPath[1000] = "\\vi.lib\\lvdsc\\TagAttr\\User\\Get Group List.vi";
// generate a namespace declaration to and identify and assign a name to a declarative region.
// In this case we are assigning the LabVIEW.
using namespace LabVIEW;
_ApplicationPtr pLV;
VirtualInstrumentPtr pVI;

CoInitialize(NULL);
do
{

pLV.CreateInstance("LabVIEW.Application");
if (pLV == NULL)
{
printf("LV must be running, exiting ...\n");
break;
}
pVI.CreateInstance("LabVIEW.VirtualInstrument");

// Get Group List
// assign an object reference to the pVI.
strcpy(Path, pLV->ApplicationDirectory);
strcat(Path, VIPath);
#ifdef LABVIEW_70
pVI = pLV->GetVIReference(LPCTSTR(Path), LPCTSTR(Password), 0, 0x10);
#else
pVI = pLV->GetVIReference(LPCTSTR(Path), LPCTSTR(Password), 0);
#endif
pVI->FPWinOpen = TRUE;

//Transfer control to LabVIEW with the Run statement. The call function passes the parameter names
// and data to the LabVIEW VI.
pVI->Run(0);

VARIANT notLoaded;
VARIANT errorOut;
VARIANT list;
notLoaded = pVI->GetControlValue("no .scf loaded");
errorOut = pVI->GetControlValue("error out");
list = pVI->GetControlValue("group list");

while( !kbhit() )
cout << "Hit any key to continue\r";
fflush( stdin );
// pVI->CloseFrontPanel();
// pLV->AutomaticClose=0;
pLV->Quit();

} while (0);
CoUninitialize();
return (0);
}
0 Kudos
Message 1 of 3
(2,644 Views)
Hi Mariana,
I have also to the support email you sent. I assume you got the acquire6.cpp example from http://forums.ni.com/ni/board/message?board.id=170&message.id=66444&requireLogin=False .

If you read the response from the NI AE in that post, you will see another solution posted. I would highly recommend his suggestion to use specific datatypes instead of Variants. For example, try using a 2-dimensional character array for the string array control and use a struct for the Error Out cluster. Please try that and see if it works better.

Hope this helps. Please let me know if you have any further questions.

A Saha
NIC
Anu Saha
Academic Product Marketing Engineer
National Instruments
0 Kudos
Message 2 of 3
(2,623 Views)
Thank you for reply.

Using a char array instead of VARIANT to read the group list, causes the program not to compile.

What am I doing wrong?
0 Kudos
Message 3 of 3
(2,604 Views)