Page 1 of 1

Send command & receive data from JSDocs?

Posted: Tue Jun 02, 2020 3:14 pm
by Mythros
Hi all! So I'm trying to send a command to JSDocs via hidden command prompt then receive data back in program.

Any help as always is GREATLY appreciated!

Thank You! <3

Re: Send command & receive data from JSDocs?

Posted: Tue Jun 02, 2020 3:39 pm
by Mythros
Here is what I have so far thanks to Kiffi & a few others :

Code: Select all

EnableExplicit

Define TempJsFilename.s = "temp.js"

CreateFile(0, TempJsFilename)
WriteStringN(0, "a")
CloseFile(0)

Define Dummy.s
Define RPE.s ; ReadProgramError
Define RPS.s ; ReadProgramString
Define Exitcode

Define NodeJs = RunProgram ( "cmd.exe", "/c node " + Chr(34) + TempJsFilename + Chr(34), "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Error | #PB_Program_Hide)

If NodeJs
 
  While ProgramRunning(NodeJs)
   
    Dummy = ReadProgramError(NodeJs)
   
    If Dummy
      RPE + Dummy + #CRLF$
    EndIf
   
    Dummy = ReadProgramString(NodeJs)
   
    If Dummy
      RPS + Dummy + #CRLF$
    EndIf
   
  Wend
 
  Exitcode = ProgramExitCode(NodeJs)
 
  CloseProgram(NodeJs) ; Close the connection to the program
 
EndIf

Define Output.s

If RPS <> ""
  Output + "ReadProgramString: " + #CRLF$ + RPS + #CRLF$
EndIf

If RPE <> ""
  Output + "ReadProgramError: " + #CRLF$ + RPE + #CRLF$
EndIf

If Exitcode <> 0
  Output + "ExitCode: " + Exitcode  + #CRLF$
EndIf

MessageRequester("", Output)

DeleteFile(TempJsFilename)

Re: Send command & receive data from JSDocs?

Posted: Tue Jun 02, 2020 3:54 pm
by Kiffi
That's annoying. This forum is not a chat.