[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

Command line execution, stdin, stdout, etc.

Lars K. Schunk

11/13/2005 10:20:00 AM

Okay, here's my new problem:

I have a command line program that takes a text file as input and produces
another text file. I want to create the input text file from within Axapta,
then pass this text to the command line program, and finally receive the
output text in Axapta again.

At the moment, I'm using a rather ugly solution. I create the text in a
TextBuffer object, write this buffer to a file, run WinAPI::shellExecute()
passing in the command line program, which produces the output file, and
finally I read this file into another TextBuffer object. This can be a
problem when Axapta runs ahead of the disk operations and cannot read the
file produced by the command line program because the file is in the process
of being created when Axapta attempts to read it.

Q1) The command line program is able to use stdin and stdout. How can I take
advantage of this from within Axapta, so I can avoid using disk operations?

Q2) If Q1 is not possible, is there an elegant way of making Axapta wait for
the file (i.e., not checking for the file within a while loop)?

Thanks for your time.

Cheers,
Lars


2 Answers

Mike Frank

11/14/2005 8:28:00 AM

0

Q1) I don't know. The preferred way of communicating with external programms from within Axapta is
COM, though you can make calls to Win32 dlls as well. Maybe you could rewrite your programm accordingly.

Q2) There are two solutions
a) Use the WinAPI functions CreateProcess and WaitForSingleObject to execute and wait for your programm
b) Use the scripting engine to do the same

There are samples for both solutions in recent posts (from me ;-) If you can't find them I can repost.

Mike

Micha³ Kupczyk

11/14/2005 9:22:00 AM

0


"Lars K. Schunk" >
> I have a command line program that takes a text file as input and produces
> another text file. I want to create the input text file from within
> Axapta, then pass this text to the command line program, and finally
> receive the output text in Axapta again.
>[...]
>
Just rewrite the following in Axapta

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_...

--
Michal