ProgramRunning

Just starting out? Need help? Post your questions and find answers here.
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 182
Joined: Thu Dec 28, 2023 9:04 pm

ProgramRunning

Post by rndrei »

Gives an error: ERROR: The program is no longer running

Code: Select all

    prog_run=RunProgram(f_path+file,"","" #PB_Program_Open | #PB_Program_Read | #PB_Program_Write | #PB_Program_Error | #PB_Program_Hide)
        While ProgramRunning(prog_run)         
          If AvailableProgramOutput(prog_run)
            Output_run=ReadProgramString(prog_run)
            PrintN(Output_run)
            if key_enter=#True
              WriteProgramStringN(prog_run, GetGadgetText(#String_run))                
            endif
          EndIf
       Wend
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: ProgramRunning

Post by NicTheQuick »

What program did you start with it? Maybe it has terminated itself already.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 487
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: ProgramRunning

Post by Mindphazer »

You should check if your RunProgram() is valid :

Code: Select all

prog_run=RunProgram(f_path+file,"","" #PB_Program_Open | #PB_Program_Read | #PB_Program_Write | #PB_Program_Error | #PB_Program_Hide)
If prog_run
  While ProgramRunning(prog_run)         
    If AvailableProgramOutput(prog_run)
      Output_run=ReadProgramString(prog_run)
      PrintN(Output_run)
      If key_enter=#True
        WriteProgramStringN(prog_run, GetGadgetText(#String_run))                
      EndIf
    EndIf
  Wend
EndIf
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
Axolotl
Addict
Addict
Posts: 872
Joined: Wed Dec 31, 2008 3:36 pm

Re: ProgramRunning

Post by Axolotl »

First, there is an error in the RunProgram() parameter list, because after the last "" the comma is missing.
Secondly, I feel that the WriteProgramString() function should not be included in the block if AvailableProgramOutput() .... .
BTW: Without a running code, it is hard to help.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: ProgramRunning

Post by BarryG »

rndrei wrote: Wed Apr 02, 2025 3:40 pmERROR: The program is no longer running
Maybe you need the #PB_Program_Wait flag for RunProgram(), because you didn't include it.
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

Re: ProgramRunning

Post by AZJIO »

rndrei wrote: Wed Apr 02, 2025 3:40 pm

Code: Select all

RunProgram(f_path+file
The first parameter must be a executable file. There should not be "+file".
Axolotl
Addict
Addict
Posts: 872
Joined: Wed Dec 31, 2008 3:36 pm

Re: ProgramRunning

Post by Axolotl »

As I already wrote, the code is unfortunately not complete....
So we can only assume things. Maybe it is like this

Code: Select all

Global f_path.s ; = <valid path to executables> 
Global file.s   ; = <valid name of an executable> 
Maybe it isn't?
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
rndrei
Enthusiast
Enthusiast
Posts: 182
Joined: Thu Dec 28, 2023 9:04 pm

Re: ProgramRunning

Post by rndrei »

I figured it out! Lay out all the code, it is very large.The error was in Closeprogram ()
Post Reply