09-06-2006 11:29 AM
09-06-2006 05:15 PM
int i1, i2, i3;
char a[16];
Option 1, with the use of a single Scan function as you want:
strcpy (a, "&D034007147");
n = Scan (a, "%s[i3]>%d[w1]%d[w1]%d[w2d]%d[w1]", &i1, &i2, &i3);
Option 2, directly getting character value ("0" is ascii 48, "1" is ascii 49 and so on):
strcpy (a, "&D034007147");
i1 = a[3] - 48;
i2 = a[4] - 48;
i3 = a[7] - 48;
09-07-2006 02:03 AM
Hello Stuart.
If you're not familiar with the Scanning function, it might be interesting to user the Wizard. You can find this program on your hard disk: C:\Program Files\National Instruments\CVI80\bin\fmtwz.exe. Note that the name of the directory CVI80 can be different on your system, depending on your CVI version. It is possible to add a shortcut to the LabWindows/CVI Tools Menu. To do so, select "Customize" from the Tools menu and add the program.
09-07-2006 02:31 AM
Some comment on this Scan function which is powerful and painful at the same time
:
n = Scan (a, "%s[i3]>%d[w1]%d[w1]%d[w2d]%d[w1]", &i1, &i2, &i3);
| | | | |
| +-----+-----|------+---> Read an integer consuming one byte in the source
| +----------> Read 2 bytes from the source discarding them
+-----------------------------> Read the string starting from the 3rd character
09-07-2006 09:42 AM
Thank you both very much for the replys. Roberto, not only have you provided me with code which does exactly what I want, but your explanation will help me to use the function in the future (I learn much better by applying other examples to my situation). Wim, I didn't know that wizard was there. It will also be a good tool in helping me to make good use of this function.
Best regards,
Stuart Van Deusen