Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the Handle of an Existing Task?

I'm using a National Instruments board with Matlab.  This is allowing me to perform interactive command-line development.  But, I've run into an interesting problem.  I can create a task and forget the handle.  Now I cannot use the task (forgot the handle), but it is still allocated and I cannot re-use the task name (until I stop & restart Matlab).  I realize this is sloppy programming and simply a result of me typing in DAQ commands one at a time from a command line, but - is there any way to return a task handle if the task name is known?  I've searched for a function int32 __CFUNC DAQmxGetTask(const char taskName[], TaskHandle *taskHandle) but it doesn't seem to exist.  Any chance you guys could write one and add it to the library?  It would make interactive development through Matlab easier.
0 Kudos
Message 1 of 3
(3,517 Views)

Hello bsimon,

It's been a while since I've programmed in Matlab and I've never used DAQmx in Matlab (in my experience, LabVIEW, CVI, C/C++, any of the .NET languages and even VB, though I hate it, would seem to be vastly superior ADEs because the DAQmx API actually supports these languages).  In spite of my stated inexperience, if you are just making C function calls from the command-line, can't you just 1) directly access whatever variable you are currently passing in for *taskHandle OR 2) explicitly create a TaskHandle *taskHandle at the command line and just access this variable?

Eric
DE For Life!
Message 2 of 3
(3,511 Views)
I can & will keep track of the memory objects - but life would be easier if you could determine if a task exists by name, and then get the handle without secondary ops (such as setting the handle to NULL after a DAQmxClearTask and later testing for handle = NULL before attempting a another create).
 
As much as possible I'd like to create stateless routines.  Local storage and setting the handle to NULL after a clear would do the trick, I was just hoping for a NIDAQmx call to return the handle.
0 Kudos
Message 3 of 3
(3,504 Views)