LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

get external application text output thru CVI then save that text to an incrementing text file

Hello All,
 
Thank you first for helping me with this one,
 
I have a Labwindows CVI project working, it basically used for testing disc drives,
 
There is an external application that monitors the the firmware of that disc drive by dispaying printf's on that external application only, without an option of saving that displayed text. By the way, the connection is rs232 by that external application application to the middle hardware then to the drive, the connection of the drive is IDE to PC.
 
So, basically the problem is I want my project get those displayed text to that external program then saves it to a file. Say, that external program displays Hello, my project will get that Hello then save it to hello.txt. Then after the next test, the external program again displays the the next hello of the next test(currently used), then my project again will get that second hello then saves it to hello1.txt. Is it possible in Labwindows CVI?
 
Regards,
Leo
 
 
________________________________________________________________
Electronics Manufacturing Tester Forum
0 Kudos
Message 1 of 11
(4,968 Views)
I assume the external program just writes to the command window from where it was started ?
if so, you can pipe the output to your cvi-program, which should be compiled as 'console application'.
like this:
externalprog | cviprog
the cvi program should read from standard input using ansi-c functions (e.g. 'gets' for reading strings).



--
Once the game is over, the king and the pawn go back into the same box.
0 Kudos
Message 2 of 11
(4,951 Views)
Smoken,
 
As long as you have the text as a string in memory, you can use the stdio.h API to do this. 
 
Example:
 

FILE *myFile
 
myFile = fopen ("hello.txt", "a+") //append text to hello.txt
 
fprintf ("%s", myDataString) //write the string from memory to the file 
 
fclose (myFile); //close the file

0 Kudos
Message 3 of 11
(4,943 Views)
Hello all,
 
thank you for replying to my problem, and sorry for asking questions, basically i dont know how this pipe works and dont know also how to do it, can you give me a sample?
 
also, the text in the external application doesn't reside to any file in the memory, it just displays in the textbox of that external application.
 
regards,
 
________________________________________________________________
Electronics Manufacturing Tester Forum
0 Kudos
Message 4 of 11
(4,909 Views)
well,
pipes do basically only work in console mode, that means, you start your program in a console-window (cmd.exe), and this program writes to stdout,
e.g.:

printf("Hello World\n");

- this output can be 'piped' to another program which processes it.
like so:

hello.exe | myprog.exe

where hello.c prints 'Hello World' and myprog.exe will get this text via stdin.
however, from your description, I doubt this will work, as you mention the program displays it's output in a 'text box' which seems to be
part of a graphical user interface - right ?




--
Once the game is over, the king and the pawn go back into the same box.
0 Kudos
Message 5 of 11
(4,900 Views)
yes it is part of the gui, actually the external prog was created in delphi 7.0, i dont have the source only the exe. thank you for helping, really appreciate it.
________________________________________________________________
Electronics Manufacturing Tester Forum
0 Kudos
Message 6 of 11
(4,887 Views)
Hello smoken,
 
Since your third-party application is an executable with a separate GUI it's going to be more difficult to interact with the data that is being displayed in that interface.  It might be easier to recreate that interface in CVI then use the CVI or ANSI C file I/O functions to save the results to disk.  Also, if the third-party application provides an ActiveX interface, you could possible access the information that is being written to the display as you would with Microsoft Word or any other ActiveX server. 
 
Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 7 of 11
(4,872 Views)
Thank you wendy, that is what i am planning, to create new thru CVI, the 3rd party doesn't have an activex interface like what you said,
 
Can you help me to start with this? Maybe just a sample or code snippet, basically, the UIR will display the strings of text in the textbox being sent by the the comport. then this text or strings will be automatically be save to a file when i close the uir or application, then start again with an incrementing saved filename. Nay help will be greatly appreciated.
 
Thank you...
________________________________________________________________
Electronics Manufacturing Tester Forum
0 Kudos
Message 8 of 11
(4,841 Views)
>Can you help me to start with this? Maybe just a sample or code snippet, basically, the UIR will display the strings of text in the textbox being sent by the the comport. then this text >or strings will be automatically be save to a file when i close the uir or application, then start again with an incrementing saved filename. Nay help will be greatly appreciated.

that is easy - just also write the strings you display in the text box to a file.
close the file upon closing uir/application.

as for automatic filename creation based on increasing numbers, you may want to take the following code snippet as a starting point:

void IncFileName(char *Name, int inc)
{
        char NewName[STRSIZ],NumStr[8];
        int Num = 0,l = 0;
        char c;
        double expo=0;
        StringLowerCase (Name);
        strcpy(NewName,before(Name,".dat"));
        l = strlen(NewName);
        l--;
        while (isdigit(c = NewName[l]))
        {
                Num = (int)(Num + (c - 48) * pow(10.0,expo));
                expo++;
                l--;
        }
        Fmt(NumStr,"%s<%d",Num);
        strcpy(NewName,before(NewName,NumStr));
        Num = Num + inc;
        Fmt(NumStr,"%s<%d",Num);
        strcat(NewName,NumStr);
        strcpy(Name,NewName);
        strcat(Name,".dat");
}


(which basically takes a filename of the form 'anynameXXXXXXXX.dat' as an argument (X's represent numbers) and increments XXXXXXXX by inc -
note that 'before' is a self written string function which extracts the part of 1st argument string which is before the 2nd one)

--
Once the game is over, the king and the pawn go back into the same box.
0 Kudos
Message 9 of 11
(4,836 Views)

Thanks for the help, josswern, i really appreciate the answers from this community,

how about the sample for displaying the strings of data being sent by the device via rs232 from say com1 to the textbox?

________________________________________________________________
Electronics Manufacturing Tester Forum
0 Kudos
Message 10 of 11
(4,832 Views)