Page 1 of 1

retrieve the results of a program in a variable

Posted: Sun Mar 01, 2015 11:36 am
by NY152
Hello,

For need a program, I need to run another program and retrieve its result in a variable. I do not know how. Anyone have an idea?

In advance, thank you

Re: retrieve the results of a program in a variable

Posted: Sun Mar 01, 2015 11:55 am
by firace
Here's a simple example:

Code: Select all

PRG = RunProgram("cmd" , "/c echo %computername%" , "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)

If PRG 
  While ProgramRunning(PRG)
    If AvailableProgramOutput(PRG)
      V$ = ReadProgramString(PRG)
      Debug V$ 
    EndIf
  Wend
  
  CloseProgram(PRG) 
EndIf
Hope this helps.