« Close

Datasheets and User Guides

App Notes

Software & Driver


2.9 - GetFirstResult() and GetNextResult()

Calling either Go function creates a list of results that matches the list of requests. Use GetFirstResult() and GetNextResult() to step through the list of results in order. When either function returns LJE_NO_MORE_DATA_AVAILABLE, there are no more items in the list of results. Items can be read more than once by calling GetFirstResult() to move back to the beginning of the list.

UserData is provided for tracking information, or whatever else the user might need.

None of the Get functions clear results from the list. The first AddRequest() call subsequent to a Go call will clear the internal lists of requests and results for a particular device.

When processing raw in/out or stream data requests, the call to a Get function does not actually cause the data arrays to be filled. The arrays are filled during the Go call (if data is available), and the Get call is used to find out many elements were placed in the array.

It is acceptable to pass NULL (or 0) for any pointer that is not required.

The parameter lists are the same for the GetFirstResult() and GetNextResult() declarations.


LJ_ERROR _stdcall GetFirstResult (  LJ_HANDLE Handle,
                                    long *pIOType,
                                    long *pChannel,
                                    double *pValue,
                                    long *px1,
                                    double *pUserData)

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.

  • Handle – Handle returned by OpenLabJack().


  • pIOType – A pointer to the IOType of this item in the list.
  • pChannel – A pointer to the channel number of this item in the list.
  • pValue – A pointer to the result value.
  • px1 – A pointer to the x1 parameter of this item in the list.
  • pUserData – A pointer to data that is simply passed along with the request, and returned unmodified. Can be used to store any sort of information with the request, to allow a generic parser to determine what should be done when the results are received.


Hello, I am trying to get a special range (0 to 3.6 volt) using the following code: I got a Labjack U3-LV but my program stop responding when either using GetFirstResult or GetNextResult and GetResult only gives me a zero. Wr is the channel. Written in C. 


Sleep(100); //Give time to Analog Input to read the valu




resultArray[ctrlinput] = dblValue7;


You should check the returns of your calls like in the C examples to see if an error code was returned, but my guess is that channel "wr" is not configured as an analog input. There is some pseudocode in the user's guide demonstrating how to configure lines to analog input:


Your AddRequest call looks fine, but I would recommend something like this for your GetFirstRequest for pointer safety:

GetFirstResult(lngHandle, &lngIOType, &lngChannel, &dblValue7, &px1, &pUserData);

If that doesn't help, check the returns of your calls for a clue on what is going on and so we can help further.

The problem is that I can't see what value is returning since the program stop responding completely. It was working correctly when reading voltages from 0 to 2.4 V (single-ended) but when I tried to use this special voltage reading, it stops working. Since I read from an excel file which establishes the pin configuration, wr stands for the pin I am configuring in that certain loop. I don't know if explain myself, is there any other way I can do a reading between 0 - 3.6 V. 

Did you try theGetFirstResult call I suggested where lngIOType, lngChannel, px1, and pUserData variables are declared and passed to prevent memory errors which could be the cause of your program. In my tests passing zeros was crashing my application as they are pass by reference.

You can try eAIN or eGet to read the analog input in one call:

eAIN(lngHandle, wr, 32, &dblValue7, 0, 0, 0, 0, 0, 0);

Also, for testing try commenting out your LabJack calls to make sure other parts of your code aren't causing your program to stop responding unexpectedly.

When using eAIN is working almost perfect, the only problem I am having is that when I declare two or more AIN, when getting the result, the first AIN gets the correct the voltages but the other gets incorrect voltages reading.



Real Input: 3.4, 2.8, 1.5, 1.1, 


First, lets try analog input testing using the test panel in LJControlPanel? Try connecting one of the U3's DACs to one if its analog inputs and change the DAC value to see the changes. Then try your signal that was producing the 3.4, 2.8, 1.5 and 1.1 voltages with the analog inputs and see if they look correct in the test panel.

Next, in your code what analog inputs are you trying to read from and what does your eAIN calls look like. Double check that you are setting the positive channel to the correct AIN and that you have a good connection to it.

Last, what is the source of your voltages?