1 Reply Latest reply on Jan 5, 2011 5:28 PM by jordana309-36

    Playing with NativeProcess output


      I have a video encoding program that uses several batch (.bat) files to encode a movie. Formally, since AIR 1.5 couldn't start processes, this had to be started using Directory Monitor (another program), which watched a folder that AIR could touch, and then Directory Monitor would actulaly start the encoding. Now, AIR can starting the encoding, but I have problems with variables coming in (CMD batch files are rather confusing sometimes to work with), which means I've had to do some really odd hack-arounds. Plus, my client also wants to be able to start these batch files seperate from AIR, which means that it can't rely on AIR at any point of the encoding process for input. Currently, then, I have AIR  execute a batch file with the following code:


      @ECHO OFF

      REM Global Variable declairation

      SET appRoot=%USERPROFILE%\Desktop\DEV FOLDER\Program Folder

      SET appTempPath=%USERPROFILE%\ProgramName

      SET startString="%appRoot%\Working Folder\getVariables.bat" "%appRoot%" "%appTempPath%"


      START CMD /C "%startString%"

      REM or, use CALL %startString% to start the process, let it remain hidden, and be grabbable by AIR


      The first call (START) allows me to  see the CMD window (which I wanted to do), and works alright. That "getVariables.bat" will actually go to the database, grab variables, organize them, determine which specific file for encoding to start next, and then start it. However, I lose control of the process handle,  and can no longer show that text inside my AIR app, if a user wanted to see it there, too. I'm tempted to just start the process normally (meaning I won't see the actual CMD window when it starts in AIR--that's the CALL), but that causes other problems:


      I currently am able to catch any output from the batch files, and redirect that output to a window that I've created for that purpose. The command-line programs used in my batch files show their status in a single line that they erase and replace with a new line (so that you don't see:




      But rather the line just updates).


      The problem is that I cannot catch that using STANDARD_OUTPUT_DATA event handler, because that only gets output when there's a new line. It records every change, and then, when it finishes and releases the output, then every percentage is printed to my terminal window in a billion-line long list and then it moves on.


      Is there any way that I can mimic this behavior, and actually show it in my program? Or will I have to facilitate catching this information in the command line batch files that I used to create the encoding process?


      If you need more clarification on what I'm doing, let me know. My client does not want me to code a C app to handle this, and I don't know how to use C, so the learning curve would be too high anyway (this project is due by Christmas if possible). Thank you so much for your help in advance.