From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy scrolled text to notepad on request?

Hi, currently using v6.0, I have a text box on the a UIR which I use basically as a status window. By the end of the program it has scrolled down, I am looking for a way of copying all the text in that box to a notepad file if requested by user.

any ideas?

thanks
0 Kudos
Message 1 of 3
(2,886 Views)
Hello NatzW,

I wrote a quick callback function that will save the lines of text from your textbox to a file.

First, you get the number of text box lines.
Then, by index, get each text box line and write it to a file.
Finally, Close the file.

NOTE: If you know the maximum length of a line of text that will be displayed in your text box, then
you can declare you text array to be that size.


FILE * outputFile;
. . .
int CVICALLBACK SaveToFile (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int numLines = 0;
int i = 0;
char text[MAX_LINE_LEN];

switch (event)
{
case EVENT_COMMIT:
outputFile = fopen ("OutputFile.txt", "a");
GetNumTextBoxLines (panelHandle, PANEL_TEXTBOX, &numLines);
for (i = 0; i < numLines; i++) {
GetTextBoxLine (panelHandle, PANEL_TEXTBOX, i, text);
fprintf(outputFile, "%s\n", text);
}
fclose(outputFile);
break;
}
return 0;
}


Hope that helps.
Wendy L
LabWindows/CVI Developer Newsletter
Message 2 of 3
(2,873 Views)
Brilliant - thanks exactly what I needed
0 Kudos
Message 3 of 3
(2,842 Views)