pass parameter in flex NativeProcess

I want to pass two parameter to nativeProcess.

While i am running exe file using windows command with parameter, it is working. Command for window is "abc.exe a.txt b.txt"

How can I pass two parameters to the exe in that format using flex nativeProcess?

This is what I have so far:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="windowedapplication1_applicationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            private var process:NativeProcess;
            protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
            {
                if (NativeProcess.isSupported)
                {
                    callExe();
                }
                else
                {
                    textReceived.text = "NativeProcess not supported.";
                }
            }

            public function callExe():void
            {
                var a_FilePath:String = File.applicationStorageDirectory.resolvePath("dist/a.txt").nativePath;
                var b_FilePath:File = File.applicationStorageDirectory.resolvePath("dist/b.txt").nativePath;

                if (Capabilities.os.toLowerCase().indexOf("win") > -1)
                {
                    var file:File = File.applicationStorageDirectory.resolvePath("dist/abc.exe");
                }

                var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

// i put the line below and it works in my case

nativeProcessStartupInfo.workingDirectory = File.applicationStorageDirectory.resolvePath();

nativeProcessStartupInfo.executable = file;

                var args:Vector.<String> = new Vector.<String>();
                args.push(a_FilePath);
                args.push(b_FilePath);

                nativeProcessStartupInfo.arguments = args;

                process = new NativeProcess();
                process.start(nativeProcessStartupInfo);
                process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
                process.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, inputProgressListener);
                process.addEventListener(ProgressEvent.PROGRESS, progressEvent);
                process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, errorData);
            }

            public function inputProgressListener(event:ProgressEvent):void
            {
                textReceived.text += "Input Progress Event";
            }
            public function onOutputData(event:ProgressEvent):void
            {
                textReceived.text += "Output Event";
            }
            public function progressEvent(event:ProgressEvent):void
            {
                textReceived.text += "Progress Event";  
            }
            public function errorData(event:ProgressEvent):void
            {
                textReceived.text += "Error Event";
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <mx:TextInput id="textReceived" width="352" height="200"/>

</s:WindowedApplication>

Answers


I solved my puzzle by adding the line below in bold:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="windowedapplication1_applicationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            private var process:NativeProcess;
            protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
            {
                if (NativeProcess.isSupported)
                {
                    callExe();
                }
                else
                {
                    textReceived.text = "NativeProcess not supported.";
                }
            }

            public function callExe():void
            {
                var a_FilePath:String = File.applicationStorageDirectory.resolvePath("dist/a.txt").nativePath;
                var b_FilePath:File = File.applicationStorageDirectory.resolvePath("dist/b.txt").nativePath;

                if (Capabilities.os.toLowerCase().indexOf("win") > -1)
                {
                    var file:File = File.applicationStorageDirectory.resolvePath("dist/abc.exe");
                }

                var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

// i put the line below and it works in my case

nativeProcessStartupInfo.workingDirectory = File.applicationStorageDirectory.resolvePath();

nativeProcessStartupInfo.executable = file;

                var args:Vector.<String> = new Vector.<String>();
                args.push(a_FilePath);
                args.push(b_FilePath);

                nativeProcessStartupInfo.arguments = args;

                process = new NativeProcess();
                process.start(nativeProcessStartupInfo);
                process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
                process.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, inputProgressListener);
                process.addEventListener(ProgressEvent.PROGRESS, progressEvent);
                process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, errorData);
            }

            public function inputProgressListener(event:ProgressEvent):void
            {
                textReceived.text += "Input Progress Event";
            }
            public function onOutputData(event:ProgressEvent):void
            {
                textReceived.text += "Output Event";
            }
            public function progressEvent(event:ProgressEvent):void
            {
                textReceived.text += "Progress Event";  
            }
            public function errorData(event:ProgressEvent):void
            {
                textReceived.text += "Error Event";
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <mx:TextInput id="textReceived" width="352" height="200"/>

</s:WindowedApplication> 

Need Your Help

Python/Numpy/Scipy: Draw Poisson random values with different lambda

python random numpy scipy poisson

My problem is to extract in the most efficient way N Poisson random values (RV) each with a different mean/rate Lam. Basically the size(RV) == size(Lam).

Should the GraphicsPath be disposed after use

c# winforms memory graphicspath

I am making some utility classes that make different types of symbols to place onto an elevation of CAD drawings.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.