06-27-2011 10:22 AM
Below is the program. Exactly i wanted to know how the sprintf line execute and what is mean by "O1$J%5.1f$X%8.3f$" and what this will do while execution of the program?
fLastDisp = SP.fDisp;
GetCtrlVal(panel, PN_TEST_NU_RETURN_RATE, &fReturnRate);
GetCtrlVal(panel, PN_TEST_NU_INCR, &fIncr);
sprintf(sText, "O1$J%5.1f$X%8.3f$", fReturnRate, fabs(fIncr));
FlushInQ (CC.uComPort);
ComWrt (CC.uComPort, sText, strlen(sText));
TimeDelay(.5);
SetCtrlVal(pnTest, PN_TEST_TX_STATUS, "jogged upwards..");
Thanks in advance.
06-27-2011 10:52 AM
This string appears as a setting command to an external device.
Supposing:
fReturnRate = 123.4
flncr = -98765.4
the resulting output string will be "O1$J123.4$X98765.400$"
Only "%5.1f" and "%8.3f" are evaluated in sprintf, the other characters are transferred to the output string unchanged.