Send command & receive data from JSDocs?

Just starting out? Need help? Post your questions and find answers here.
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Send command & receive data from JSDocs?

Post 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
Last edited by Mythros on Tue Jun 02, 2020 4:27 pm, edited 1 time in total.
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: Send command & receive data from JSDocs?

Post 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)
Last edited by Mythros on Tue Jun 02, 2020 4:26 pm, edited 1 time in total.
User avatar
Kiffi
Addict
Addict
Posts: 1509
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Send command & receive data from JSDocs?

Post by Kiffi »

That's annoying. This forum is not a chat.
Hygge
Post Reply