LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

viscanf() function using question

Solved!
Go to solution

I write a function (not main function) I want to create this function as a dll document,when teststand use dll and run it .

the question is I want to use this function get result from instrument,But I don't confirm viscanf is right?


ViStatus _VI_FUNC Get_Frequency (ViSession instrSession, ViPReal64 frequency,ViString freqCommand)
{
   ViStatus status = VI_SUCCESS;

    ViChar   buf[BUFFER_SIZE];
 ViInt32  retCnt;

 if(status=viPrintf(instrSession,"freqComamnd\n")<0)
     return MT8820B_status;
 if(status=viPrintf(instrSession,"*OPC?\n")<0)
     return MT8820B_status;
 if(=viScanf(instrSession, "f%",&frequency)<0)
     return status

 return MT8820B_status;

}

 

I use viscanf() like that,it's right? thank you

0 Kudos
Message 1 of 4
(3,873 Views)

ViPReal64 frequency is allready  a pointer to a floating point number. So you don't need the & operator in the call of  viScanf.

It should read :

if(status =viScanf(instrSession, "f%",frequency)<0)
     return status ;

 

 

0 Kudos
Message 2 of 4
(3,842 Views)
that's means if I use a ViInt32 data type ,I must use &  . thank you !
0 Kudos
Message 3 of 4
(3,836 Views)
Solution
Accepted by topic author sean_tan

You must  use a pointer to ViReal64 inside your function Get_Frequency () to make use of  it as an output parameter.   When you call  Get_Frequency()  you can use the & operator there with frequency being a ViReal64 ( not a ViInt32 ) :

Get_Frequency (instrSession, &frequency, freqCommand )   

Message 4 of 4
(3,831 Views)