Number of arguments passed to the count function

There are built-in functions that can count the number of arguments passed to a function? Obviously (arguments) StructCount doesn't work here because "the scope always contains an entry 'slot' for each argument declared, even if you do not pass the argument to the function.»

Copy the following code always returns "Count = 3 '. I want to output 'Count = 1' because the only argument has been passed to the function. The functions of any integrated to do this or am I stuck do manually: a loop + structKeyExists?

< cfset comp = createObject ("component", "MyComp") >
< cfset comp.showArgs (id = 1) / >

<! - MyComp - >
< cfproperty >
< cffunction name = returntype "showArgs" = "Sub" output = "true" >
< name cfargument = "id" type = "numeric" required = "true" / >
< name cfargument = "FirstName" type = "string" required = "false" / >
< name cfargument = "name" type = "string" required = "false" / >
Count = < cfoutput > #StructCount (arguments) # < / cfoutput > < br >
< / cffunction >
< / cfproperty >

Thanks for the replies.

My question was not so much about how it works. I understand that CF always adds a slot in the structure of optional arguments. Maybe its just me, but it seems a bit logically inconsistent to return different results of StructCount (etc.) and StructKeyExists? If StructCount "counts the number of keys in a structure" then StructKeyExists should behave in accordance with the StructCount, but it doesn't. I understand why its done in this way, but it still seems a bit inconsistent.

In any case, because there isn't a built-in method to return only the arguments provided, I ended up doing manually as I've described before.

Tags: ColdFusion

Similar Questions

  • count the number of lines without using the count function

    Hello
    How count the number of lines without using the count function?

    Thank you

    Assuming that your statistics table are updated:

    select num_rows
    from   all_tables
    where  table_name = 'YOUR_TABLE_NAME_IN_UPPERCASE';  
    

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14237/statviews_2105.htm#REFRN20286

  • I can't the arguments passed to the AWR Design environment?

    From a script Visual Basic can I get a list of command line arguments that were used to start Office from microwave or VSS?

    The command line arguments passed to the application at startup are accessed through the collection of application arguments MWOffice.Arguments . Each whitespace delimited command line argument is available as an argument object in the collection. The Argument.Value property contains the value of this argument. For example, the following script displays a list of the arguments passed to the application in the debug output window.

  • How can I compare the value of column within the COUNT() function?

    I want to compare the value of the column within the COUNT() function as below how ever it gives me the error. I want to calculate the percentage, how can I do this task?
    Thank you.


    SELECT department_id
    , COUNTY (salary < 250000) / COUNT (*)
    OF plch_employees
    GROUP BY department_id
    ORDER BY department_id;
    SELECT  department_id.
            COUNT(CASE WHEN salary < 250000 THEN 1 END) / COUNT(*)
      FROM  plch_employees
      GROUP BY department_id
      ORDER BY department_id
    /
    

    SY.

  • fgetc reports ' argument open stream ", the fopen() function succeeded

    Hello

    I'm looking to implement the GNU 'getline()' function in CVI and the function starts as:

    getline.dll:

    Ssize_t getline WINAPI LIBAPI (char * lineptr, size_t * n, FILE * stream) {}

    int c;

    While (TRUE) {}

    c = fgetc (stream);    Error occurs here

    ...

    }

    }

    (LIBAPI is DLLEXPORT or DLLIMPORT). It is then compiled as a DLL and put it somewhere in the world. Then I have another DLL that does this:

    Driver.dll:

    int ReadWaveform (void) {}

    FILE * fwave;

    char * lineptr = NULL;

    int n = 0;

    fwave = fopen ("waveform.txt", "r");

    Len = getline (& lineptr, & n, fwave);

    ...

    }

    I get the error "Argument must be an open stream" when the 'fgetc()' function is called. It does not produce an error if this fgetc() is put in the ReadWaveform() function. The file exists, it is readable (the permissions of files are read-only, but read/write changes its behavior either). The two libraries are compiled in debug (or the getline.dll has also been compiled as a liberation, but does not change because the file can not be read and fgetc() reports EOF immediately that it should in case of error).

    So there seems to be some issues to limit cross-DLL when using file streams if open the stream in the DLL driver.dll and work with her in getline.dll. I did not have this problem with other C languages.

    any help on this would be appreciated. I use CVI 9.0 on Windows XP.

    Thank you

    Jason.

    I think this problem is the same as malloc/free deliver you in the other thread. Basically, I think that your two dll is built with runtime different support options, and so, engine running different CVI DLLs are called to manage resources. If you build your dll/program with the same runtime support option, then you should be able to share the FILE pointer through modules - you can't always do it for other reasons of design.

  • What does the argument [] State_Information in the FIRFiltering() function?

    I'm writing a digital filtering code, but I have no experience with digital filters.  I think I need the advanced analysis library FIRFiltering() function.  This feature provides arguments for the input data table, all of the coefficients of the filter, the output array and also a table called the State_Information.  Whence this table and what is it?

    Original terms of X contains the most recent entries. The last entry prior should be the last item in the array. The number of elements in this array must be less than the number of items in the table of Coefficients of FIR.

  • number of conditional, exclusion of the counted and other.

    Hi guys,.

    I have the following table:

    MATRIX - ID - Reason_1___Reason_2

    001004 7 B - 2014/04471 2

    001004 R/2014/000046 8 1

    001004 R/2014/000963 7 1

    001001 R/2014/000963 7 1

    001004 102311427365 7 1

    001004 102311428653 8 1

    001004 102311429331 7 1

    001004 102311429818 7 1

    001001 102311429818 7 5

    001004 14 - 0027835 7 1

    001001 14 - 0124520 7 1

    001004 14 - 0124520 2 1

    001004 7 1 2014MEL008627

    001004 7 1 2014MEL013736

    001004 7 1 2014MEL013737

    I need a meter that shows me the following:

    3 separate ID are displayed for both, matrix 001004 and 001001 (those who are R/2014/000963 102311429818 14-0124520)

    9 separate ID appear only for 001004 (3 above must have been excluded).

    0 distinct ID appear only for 001001 (the first 3 should have been excluded).

    No idea how to solve this problem?

    SQL> with t
      2  as
      3  (
      4  select '001004' matrix, 'B-2014/04471' id, 7 reason_1, 2 reason_2 from dual union all
      5  select '001004' matrix, 'R/2014/000046' id, 8 reason_1, 1 reason_2 from dual union all
      6  select '001004' matrix, 'R/2014/000963' id, 7 reason_1, 1 reason_2 from dual union all
      7  select '001001' matrix, 'R/2014/000963' id, 7 reason_1, 1 reason_2 from dual union all
      8  select '001004' matrix, '102311427365' id, 7 reason_1, 1 reason_2 from dual union all
      9  select '001004' matrix, '102311428653' id, 8 reason_1, 1 reason_2 from dual union all
     10  select '001004' matrix, '102311429331' id, 7 reason_1, 1 reason_2 from dual union all
     11  select '001004' matrix, '102311429818' id, 7 reason_1, 1 reason_2 from dual union all
     12  select '001001' matrix, '102311429818' id, 7 reason_1, 5 reason_2 from dual union all
     13  select '001004' matrix, '14-0027835' id, 7 reason_1, 1 reason_2 from dual union all
     14  select '001001' matrix, '14-0124520' id, 7 reason_1, 1 reason_2 from dual union all
     15  select '001004' matrix, '14-0124520' id, 2 reason_1, 1 reason_2 from dual union all
     16  select '001004' matrix, '2014MEL008627' id, 7 reason_1, 1 reason_2 from dual union all
     17  select '001004' matrix, '2014MEL013736' id, 7 reason_1, 1 reason_2 from dual union all
     18  select '001004' matrix, '2014MEL013737' id, 7 reason_1, 1 reason_2 from dual
     19  )
     20  select matrix
     21       , count(case when cnt > 1 then 1 end) common_id_count
     22       , count(case when cnt = 1 then 1 end) unique_id_count
     23    from (
     24            select matrix
     25                 , id
     26                 , count(distinct matrix) over(partition by id) cnt
     27              from t
     28         )
     29   group
     30      by matrix;
    
    MATRIX COMMON_ID_COUNT UNIQUE_ID_COUNT
    ------ --------------- ---------------
    001001               3               0
    001004               3               9
    
    SQL>
    
  • How to get the value of DeviceKet in the QueryChangedDiskAreas function?

    Hello

    I'm trying to get the value of block changed to an ESXi Server virtual computer. I have the reference to object for the virtual machine must be passed to the QueryChangedDiskAreas function and snapshot. How can I get the 3rd parameter deviceKey - which I understand is the disc I get the Changed block for. Does someone can tell how I can get this value?

    Thank you

    . / Siva

    Hello Shiva!

    I suggest to use the property of the data object VM.config.hardware.device [] .key. You will for sure have to analyze the table first of all find the virtual disk in question. I can say that the deviceKey is the array index. But I would not count on that. In order to better use its practical value.

    Hope this helps

  • @count function

    Hello

    I read that some old codes of my work and not quite understand how they use @count function.

    [code]

    DIFFICULTY (@relative ("B & R", 0), @relative("WBS",0), "Working")

    FIX (@children ("All_Appr_Year"))

    'Account '.

    (

    'Work' = @Count (SKIPBOTH, 1, @relative ("B & R", 0));

    )

    ENDFIX

    ENDFIX

    [/ code]


    B & R, WBS, Appr_Year work are the dimension names. account is a member in the dimension account. The code attempts to count the number of rows of records there by B & R for each year of appr. I don't know what is the use of 1 in the @count function. If I write it, I write looks like: counts=@count (skipboth, @range ('charges', @relative("B&R",0)). 'cost' is another Member in the dimension account.


    Can someone explain it to me?


    Thank you


    Per the documentation through the 'skip' is the list of expressions to count.  If your '1' is actually being counted, as it is a non - #Missing, a value non-zero.

    In other words, the function returns the @COUNT (@RELATIVE ("B & R", 0)), plus 1.  Note that this is not because the value of this constant is '1', but because it is counted.  Put in there instead of 1 999 would always produce the same result.

    Why you do this to a functional / perspective of requirements, I can't tell you.  And it's a confusing way to write it - there may be a subtlety I'm missing, but I don't see why this couldn't be written as much more readable:

    @COUNT (@RELATIVE ("B & R", 0)) + 1

  • Count function problem

    I thought it would be a simple query to write, but experiences many difficulties, maybe one of you can tell me what im doing wrong. I have a page of items in stock of the screen, and they have a category, subcategory and a specifications. I want that it displays the items once the user chooses a subcategory and then have the technical choices on the side to refine the search if they so decide. I want him to have a number in brackets next to the name of spec telling you how many lines have this specification.
    In the example, if they choose audio video devices, so they choose receivers, all receivers will be displayed on the page (which works fine now), but in the sidebar, I want him to have something like this:
    Single channel (16)
    Multi channel (22)
    Distribution (7)
    The user can click on one of these, then it will restrict research. IM able to get everything well except fact for the numbers in brackets next to the name of spec. Any time I use the count function seems to have trouble, btw I use MS Access. How can I modify the code below to work for it...
    Thank you
    Mike

    You don't know if I can answer all of your questions, but in regard to your question, if you use count(), you don't have really not distinct, but you do ned to the GROUP BY the other non-comte parameters. In addition, you must use an alias for your count() field.

    SELECT i.spc_id, s.spc_name, COUNT (i.spc_id) AS spc_count
    SPEC s INNER JOIN stock I have ON s.spc_id = i.spc_id
    WHERE i.cat_id = #cat #.
    AND i.sub_id = #sub #.
    I.spc_id GROUP, s.spc_name

    Phil

  • SetCtrlVal used during the Thread function works causes memory leaks

    I am writing a program that works if... Or not work if... - see the next lines... :-)...

    The program includes a section, mostly GUI - and User Interaction.

    The other part is a DLL. In the DLL we readings on an external consultant controller RS232. Sometimes the controller card needs (called how much) time and this time must pass then the result can be read card controller... and so on...

    Blocking is not GUI-user-program for the expectation of the return value of the DLL functions (which need a few seconds to be finished) I start a thread in the DLL with

    CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, THREAD_FunctionX, & tmpTFP, NULL);

    with "tmpTFP" as an instance of type "TYPE_THREAD_FUNCTION_PARAMETERS":

    typedef struct
    {
    //
    int IntVal1;                // 1. Integer-Wert
    int IntVal2;                // 2. Integer-Wert
    int IntVal3;                // 3. Integer-Wert
    int IntVal4;                // 4. Integer-Wert
    int IntVal5;                // 5. Integer-Wert
    //
    int IntBuffer1 [32];            // 1. Integer-buffer (aktuell genugt einer)
    //
    Double DblVal1;                // 1. Double-value
    Double DblVal2;                // 2. Double-value
    Double DblVal3;                // 3. Double-value
    Double DblVal4;                // 4. Double-value
    Double DblVal5;                // 5. Double-value
    //
    char CharVal1;                // 1. (Single)- Tank-Wert
    char CharVal2;                // 2. (Single)- Tank-Wert
    char CharVal3;                // 3. (Single)- Tank-Wert
    char CharVal4;                // 4. (Single)- Tank-Wert
    char CharVal5;                // 5. (Single)- Tank-Wert
    //
    char CharBuffer1 [1024];        // 1. Char buffer (akutell einer genugt)
    //
    } TYPE_THREAD_FUNCTION_PARAMETERS;

    In the GUI-user program - I get fast by default-return value of the thread start function.

    Then I asked the DLL (some global state variables are used for this) when it is finished.

    According to the map-controller (RS232) contacted the waiting time depends on the 'mood' of the controller card.

    In the DLL-mark of the GUI-user-program routine now everything works fine - without using "SetCtrlVal!"

    In my GUI, there is a text box of the info/comment for messages. If I do a few outputs user using 'SetCtrlVal' I always errors, caused by the false "TYPE_THREAD_FUNCTION_PARAMETERS"-values in the service of thread. "» If I set a breakpoint at the beginning thread-function I see mostly erroneous values in my transfer structure variables. If I put a breakpoint in the thread-function-calling 'CmtScheduleThreadPoolFunction (...)"and at the beginning of the thread values are (mostly) correct!

    I tried several and different things - but:

    If I ONLY (!)  Commenting on the (!) of a line with "SetCtrlVal", the program works, all States are asked out of the DLL.

    If I replace the "SetCtrlVal" with a written record-file function clean everything works fine and after completing the program I can look at the log file and see all the user information. BUT with 'SetCtrlVal' instead or set or (...) it does not work.

    My description is maybe not entirely clear, but believe me: only ONE line the «SetCtrlVal "line - should be commented out to let the program run properly!»

    Because if the line "SetCtrlVal"is program-user-GUI, after the call to the thread in the DLL, the DLL-memory seems to be corrupted by the call "SetCtrlVal" in the user-GUI program.»

    Best regards

    F.

    There may be a problem in your structure that your variable is set.

    You said that, after the address of the variable in the thread function the appellant one ends. Now, as you can read help each value passed in parameter threadFunctionData of the layed function must point to an area of memory that persist when the fuction is running: If your variable is defined at the level of the functions it is not valid when the thread runs since the appellant finished and released its local memory.

    Your approach with a global variable is a valid alternative, but if it is the solution, you will find data passed to the thread function must be valid for all his life.

  • Create parameters for the WriteData function

    Hello

    How would create parameters for the writedata function to populate the html code?

    CODE:

    Function GetCluster {}
    and {{foreach ($Datacenter (Get-Data Center))
    foreach ($Cluster in (Get-Cluster-location $Datacenter)) {}
    New-Object PSObject-property @ {} TypeName
    vCenter = $Datacenter.Uid.Split("@") [1]. Split(":") [0]
    Datacenter = $Datacenter.Name
    Cluster = $Cluster.Name
    HAEnabled = $Cluster.HAEnabled
    DrsEnabled = $Cluster.DrsEnabled
    DrsMode = $Cluster.DrsMode

    }
    }
    }
    # Function compiles the data transmitted by the GetCluster function in HTML table format
    Function writedata {
    param ($vCenter, $Datacenter, $Cluster, $HAEnabled, $DrsEnabled, $DrsMode)
    # < td > < Center > < b > < of police = "Tahoma" > $Datacenter < / police > < / b > < / center > < table


    {$tableEntry = "< tr > < td > < font ="Tahoma">$vCenter< / fonts > < table > < td > < Center > < b > < of police ="Tahoma">$Datacenter< / font > < / b > < / center > < table > < td > < Center > < b > < of police ="Tahoma">$Cluster< / fonts > < / b > < / center > < table > < td > < Center >"} < b > < of police = "Tahoma" >$HAEnabled< / fonts > < / b > < / center > < table < td > < Center > < b > < font = "Tahoma" >$DrsEnabled< / police > < / b > < / center > < table < td > < Center > < b > < font = 'Tahoma' color 'dark blue' = >$DrsMode< / fonts > < / b > < / center > < table > < /tr ' > '.
    Add-Content, $fileName $tableEntry
    Write-Host $tableEntry}

    Thank you

    You specify when you call the writedata function, so I guess it's in the function Get-Cluster.

    You can pass the object you create in the GetCluster function as a parameter.

    Try something like this

    Function GetCluster {
        & { foreach ($Datacenter in (Get-Datacenter)) {
                foreach ($Cluster in (Get-Cluster -Location $Datacenter)) {
                    $clusObj = New-Object -TypeName PSObject -Property @{
                        vCenter = $Datacenter.Uid.Split("@")[1].Split(":")[0]
                        Datacenter = $Datacenter.Name                    Cluster = $Cluster.Name                    HAEnabled = $Cluster.HAEnabled                    DrsEnabled = $Cluster.DrsEnabled                    DrsMode = $Cluster.DrsMode
                    }
                    writedata $clusObj            }
            }
        }
    }
    
    # Function will compile the data passed from the GetCluster Function into HTML table format
    Function writedata {
        param ($object)
    
        $tableEntry = "$($object.vCenter)" +
            "
    $($object.Datacenter)
    " + "
    $($object.Cluster)
    " + "
    $($object.HAEnabled)
    " + "
    $($object.DrsEnabled)
    " + "
    $($object.DrsMode)
    " Add-Content $fileName $tableEntry Write-Host $tableEntry}
  • Need help with the analytic function

    I want to get the highest employee details and the 2nd highest employee for a particular service. But also the Department should have more than 1 employee.
    I tried the query and it gave me the correct results. But I wonder if there is another solution than to use the subquery.

    Here is the table and the query result:
    with t as
    (
    select 1 emp_id,3 mgr_id,'Rajesh' emp_name,3999 salary,677 bonus,'HR' dpt_nme from dual union
    select 2 ,3 ,'Gangz',4500,800,'Finance' from dual  union
    select 3 ,4 ,'Sid',8000,12000,'IT' from dual  union
    select 4 ,null,'Ram',5000,677,'HR' from dual  union
    select 5 ,4,'Shyam',6000,677,'IT' from dual union
    select 6 ,4 ,'Ravi',9000,12000,'IT' from dual   
    )
    select * from 
    (select emp_id, mgr_id, emp_name, dpt_nme, salary, row_number() over (partition by dpt_nme order by salary desc) rn from t where dpt_nme in 
    (select dpt_nme from t group by dpt_nme having count(*) > 1)) where rn < 3

    Hello

    You need a subquery, but you don't need more than that.
    Here's a way to eliminate the additional subquery:

    WITH     got_analytics     AS
    (
         SELECT  emp_id,     mgr_id,     emp_name, dpt_nme, salary
         ,     ROW_NUMBER () OVER ( PARTITION BY  dpt_nme
                                   ORDER BY          salary     DESC
                           )         AS rn
         ,     COUNT (*)     OVER ( PARTITION BY  dpt_nme
                                       )         AS dpt_cnt
         FROM     t
    )
    SELECT  emp_id,     mgr_id,     emp_name, dpt_nme, salary
    ,     rn
    FROM     got_analytics
    WHERE     rn     < 3
    AND     dpt_cnt     > 1
    ;
    

    Analytical functions are calculated after the clause WHERE is applied. Since we need to use the results of the analytical ROW_NUMBER function in a WHERE clause, which means that we have to calculate ROW_NUMBER in a subquery and use the results in the WHERE clause of the main query. We can call the COUNT function analytical in the same auxiliary request and use the results in the same WHERE clause of the main query.

    Would what results you if there is a link for the 2nd highest salary in some Department? For example, if you add this line to your sample data:

    select 7 ,3 ,'Sunil',8000,12000,'IT' from dual  union
    

    ? You can use RANK rather than ROW_NUMBER.

  • Problem with counting function, passing VARs between functions.

    Hi guys, I have a problem with this section of code...

    Could anyone suggest how to fix the function at the bottom so that when the button forward_btn with label "go to next Point training" when you click on recalculate the fields created in the function fileLoaded

    var xmlData:XML = new XML ();
    var theURL_ur:URLRequest = new URLRequest ("xml.xml");
    var loader_ul:URLLoader = new URLLoader (theURL_ur);
    var more: RegExp = / \ + / g;
    var t:Number = 0;
    var tmax:Number = 0;

    loader_ul.addEventListener ("complete", fileLoaded);

    function fileLoaded(e:Event):void {}
    xmlData = XML (loader_ul.data);
    Tmax = xmlData.Record.length ();
    trace (tmax);

    trace (unescape (xmlData));
    trace (xmlData.Record.length ());


    var title_tp:String = unescape(xmlData.Record.TP.Title[t]).replace (, "");
    Title_TP_txt. Text = title_tp;

    var intro_tp:String = unescape(xmlData.Record.TP.Introduction[t]).replace (, "");
    Intro_TP_txt. Text = intro_tp;

    static_tp_intro.y = Title_TP_txt.y + Title_TP_txt.textHeight + 10;
    Intro_TP_txt.y = sta_tp_intro.y + sta_tp_intro.textHeight + 5;

    Title_TP_txt. AutoSize = TextFieldAutoSize.LEFT;
    Intro_TP_txt. AutoSize = TextFieldAutoSize.LEFT;
    }

    forward_btn.label = "go to the next Point training";
    forward_btn.addEventListener (MouseEvent.CLICK, next_if);

    function next_if (me: MouseEvent): void {}


    If (t == tmax) {play();  }


    else {t = t + 1;
    fileLoaded () ;}
    }

    I don't see where you have a question from vars between functions because you do not pass everything.  Maybe that's your problem.  The function fileLoaded expects an argument, but you are not providing one.  To get around that you should provide any argument being sent in the first function...

    function fileLoaded(e:Event=null):void {}

    Another option would be to separate features and put a quick end to the function fileLoaded and create another function that holds the rest of the code...

    function fileLoaded(e:Event):void {}
    xmlData = XML (loader_ul.data);
    Tmax = xmlData.Record.length ();

    processXMLData();

    }

    function processXMLData (): void {}
    trace (tmax);

    trace (unescape (xmlData));
    trace (xmlData.Record.length ());

    var title_tp:String = unescape(xmlData.Record.TP.Title[t]).replace (, "");
    Title_TP_txt. Text = title_tp;

    var intro_tp:String = unescape(xmlData.Record.TP.Introduction[t]).replace (, "");
    Intro_TP_txt. Text = intro_tp;
      
    static_tp_intro.y = Title_TP_txt.y + Title_TP_txt.textHeight + 10;
    Intro_TP_txt.y = sta_tp_intro.y + sta_tp_intro.textHeight + 5;
      
    Title_TP_txt. AutoSize = TextFieldAutoSize.LEFT;
    Intro_TP_txt. AutoSize = TextFieldAutoSize.LEFT;
    }

    forward_btn.label = "go to the next Point training";
    forward_btn.addEventListener (MouseEvent.CLICK, next_if);

    function next_if (me: MouseEvent): void {}

    If (t == tmax) {}

    Play();

    } else {}

    t = t + 1;
    processXMLData();

    }
    }

  • Function DAQmxRegisterEveryNSamplesEvent can be used for the counter input channels

    Hi all

    I have a request to count the number of digital pulses. I want to know the time of impulses coming which start from 1 and an increase in later, 4 as 1, 5, 9, 13... The time interval between each pulse is not a fixed value. So I tried to use DAQmxRegisterEveryNSamplesEvent and DAQmxCreateCICountEdgesChan functions. But afterI calls the DAQmxStartTask function, it has always failed.  The advice that I used is the NOR-PCIe-6320. Here's the part of my code.

    DAQmxErrChk (DAQmxCreateTask("",&m_taskhandle));
    DAQmxErrChk (DAQmxCreateCICountEdgesChan (m_taskhandle, "Dev1/ctr0", "", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp "));
    DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent (m_taskhandle, DAQmx_Val_Acquired_Into_Buffer, 4, 0, EveryNSamplesCallback, this));
    DAQmxErrChk (DAQmxStartTask (m_taskhandle));

    I don't know the reason. Can someone give me help. Thank you.

    Yang

    DAQmxRegisterEveryNSamplesEvent only works with the buffered in memory tasks.  That's what you should do anyway (if you want to use the callback or not):

    1. make your external signal the sample clock (DAQmxCfgSampClkTiming).

    2. use one of the basics of internal time as the source (DAQmxSetCICountEdgesTerm).

    Each sample you read will give the count in ticks of the time base.  Multiply the number by the base of your time period and you now have a timestamp.  Keep in mind the counter roll to 2 ^ 32 therefore account for this in your program.

    The recall is not necessary, but it is useful that you can make sure that you block your main thread until the samples are available.

    Best regards

Maybe you are looking for