Results 1 to 3 of 3

Thread: POpen

  1. #1

    POpen

    I would like to run a simple command line program with popen (unless there is a better option)... I seem to be getting lost in the examples because they always define something as text and what I want is binary (or I am having trouble understanding why they are defining text). ... what I want to run is something like


    empython programname functionname

    (I compiled a c example from python)
    http://dexrow.blogspot.com/2007/09/land-of-cigo-roguelike-w-source.html

  2. #2

    I found the answer

    I answered my own question... python uses popen (c varients cross platform) and free pascal uses a different method... This is modified from the wiki to execute a program (and is free pascal only)..

    Code:
    // This is a demo program that shows how to launch
     // an external program.
    // program launchprogram;
     unit launchprogram;
    
    interface
    
     procedure runprogram(name :string);
     // Here we include files that have useful functions
     // and procedures we will need.
    // uses
    //   Classes, SysUtils, Process;
     
     // This is defining the var "AProcess" as a variable 
     // of the type "TProcess"
     //var
    //   AProcess: TProcess;
    implementation
    uses
     Classes, SysUtils, Process;
     
     // This is where our program starts to run
     procedure runprogram(name :string);
     var 
       AProcess: TProcess;
     begin;
       // Now we will create the TProcess object, and
       // assign it to the var AProcess.
       AProcess := TProcess.Create(nil);
     
       // Tell the new AProcess what the command to execute is.
       // Let's use the FreePascal compiler
       AProcess.CommandLine := name; //'ppc386 -h';
     
       // We will define an option for when the program
       // is run. This option will make sure that our program
       // does not continue until the program we will launch
       // has stopped running.                vvvvvvvvvvvvvv
       AProcess.Options := AProcess.Options + [poWaitOnExit];
     
       // Now that AProcess knows what the commandline is 
       // we will run it.
       AProcess.Execute;
     
       // This is not reached until ppc386 stops running.
       AProcess.Free;   
     end;
    end.
    http://dexrow.blogspot.com/2007/09/land-of-cigo-roguelike-w-source.html

  3. #3
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    POpen

    You can try ShellExecute, uses ShellAPI. (google for "ShellExecute Delphi", lots and lots of references!)
    NecroSOFT - End of line -

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •