Code covered by the BSD License  

Highlights from
Counter Example

from Counter Example by Scott Hirsch
An example using generic dll calling to use the counter on an NI daq card.

loadNIcns(filename);
function param = loadNIcns(filename);

% Copyright 2002-2004 The MathWorks, Inc

if nargin==0
    [filename,pathname] = uigetfile('nidaqcns.h','Please find nidaqcns.h');
    filename = [pathname filename];
end;

% filename = 'D:\Applications\National Instruments\NI-DAQ\Include\nidaqcns.h';
fid = fopen(filename,'r');

%Read in the file
nlines = 0;
L = {};     %The lines
while 1
    fline = fgetl(fid);
    
    if ~ischar(fline), break, end
    if strncmp(fline,'#define ND',10)
        nlines = nlines+1;
        L{nlines} = fline;
    end;
end;
fclose(fid);

%Now, define the variables.  Store them all in a structure

for ii=1:nlines
    %I catch all the longs.  enum's are skipped
    try
        [name,val] = strread(L{ii},'#define %s     %dL');
        param.(name{1}) = val;
    catch
    end;
    
end;

Contact us at files@mathworks.com