03-13-2008 03:19 PM
03-13-2008 04:56 PM
03-13-2008 05:02 PM
03-13-2008 06:00 PM - edited 03-13-2008 06:03 PM
To read file contents one line at a time you can use Read lines from file.vi in the File palette (possibly in the Advanced sub-palette, I don't remember wxactly and I cannot check at the moment) . Once read, the line could be separated into its components using the Scan string for tokens.vi. In the online reference for the latter two examples are listed that you may want to study.
Last but not least, for LabVIEW related questions I suggest you to post them directly to the LabVIEW forum, since this board is dedicated to LabWindows/CVI: you will find more rapid response there
08-10-2008 12:04 PM
hi ,
i want to read data from file , so i have to use fscanf command to read it , but problem is i can not to do it .
can you give me the exact syntax of fscanf ....i mean i dont know how to use it in my particular case. which is very simple. :(.
data which i have to read is .
8.90
3.30
4.30
08-11-2008 06:15 PM
08-12-2008 03:57 AM
Of course, as you want to read floating point values I'm sure Lars intended to define val1, val2 and val3 as type float. If you prefer to use doubles, the fscanf line would look to be:
double val1, val2, val3;
fscanf (filename, " %lf %lf %lf", &val1, &val2, &val3);
The space character (' ') is equally valid as a separator between fields as the newline one ('\n'), but I find it more intuitive and clearer. The exact syntax of the specification field depends on the exact contents of your file: scanf functions are generally quite complex and can be a challenge to get right. I always prefer to read a line of text from the file into a temporary string buffer first and then use sscanf() to parse it. This allows for easier error handling if things go wrong and also makes debug easier.
JR
09-09-2008 05:04 PM
Hello, Thanks very much for you reply , i have read the Data from the text file, but now i want to know one more thing ,
that is i also want to plot the data on graph , i use PLOT XY function , and all work fine,
but the problem is this function is not plot the negative values , Is there a way to plot the negative values using labwindows ???
09-10-2008 12:05 AM
CVI can treat and plot negative values as well as positive ones without any particular provision, so if you're not seeing them in your diagram the reason can either be that you've not enabled autoranging on graph Y-axis (or you've not set its scale to a reasonable range: check in the UIR editor) or something in scanning routine or the following code prevents you from obtaining negative values from the file. To check the second point place a breakpoint on PlotXY line and examine the array your are to plot in the variable window: pressing Shift-F4 will bring up a small diagram popup for the array so that you can see its values at a glance.
If this does not helps, post the relevant part of your code (variable definitions included) so that we can take a look at it.
09-10-2008 02:02 AM
Hi , my code is this , so i just put the example data in the array and want to plot but this code is not plotting the Negative Values.
int CVICALLBACK Get (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
unsigned int f[8];
f[0]=10;
f[1]=0;
f[2]=20;
f[3]=0;
f[4]=0;
f[5]=-10;
f[6]=0;
f[7]=10;
switch (event)
{
case EVENT_COMMIT:
PlotY (panelHandle, PANEL_GRAPH, f, 8, VAL_UNSIGNED_INTEGER, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
SetAxisScalingMode (panelHandle, PANEL_GRAPH, VAL_LEFT_YAXIS, VAL_MANUAL, -60.0, 60.0);
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}