User:Jrkenti/sandbox

Function wrtpowerXTC2(address,power) Variable address, power SVAR wrtdata, rddata String IDstr="IDXTC2_"+num2str(address) NVAR ud=$IDstr								// ud is a local reference to the global variable. Variable err = 0 String message sprintf message, "wrtpowerXTC2, address=%d, data folder=\"%s\": ", address, GetDataFolder(1)

Variable result = NaN

do sprintf wrtdata,"R11 %4.1f\012",limit(round(power*10)/10,0,99.9) NI4882 /Q ibwrt={ud, wrtdata, strlen(wrtdata)} if (V_ibsta & 0xC000)							// Error or timeout occurred? err = -1 message += "Error during write power." break endif NI4882 /Q ibrd ={ud, 40} rddata = S_value if (V_ibsta & 0xC000)							// Error or timeout occurred? err = -1 message += "Error during read." break endif if ( char2num(rddata[0]) == 10 ) result = 0 else result = -1 message += "Incorrect response." break endif while (0) if (err!=0 || result!=0) Beep Print message endif return result End