Page 1 of 1

SendRexxCommand does not return result

Posted: Sun May 31, 2020 5:19 pm
by amiga23
When using SendRexxCommand no result is returned.

Using a simple ARexx Script works fine.

Tested on AmigaOS 3.1.4.1 and MorphOS 3.13

Server:

Code: Select all

@VERSION 8,0

Function p_EventFunc(msg)
  Switch msg.action
  Case "OnARexx"
    Switch msg.command
    Case "EXIT"
      DebugPrint("Exit received! Quitting now.")
      End
    Case "GETSTRING"
      DebugPrint("GetString called")
      Return("GETSTRING called")
    Case "GETNUMBER"
      DebugPrint("GeNumber called")
      Return(10)
    Default
      Local t = SplitStr(msg.args, "\0")
      DebugPrint(msg.command, "called with", msg.argc, "argument(s)")
      For Local k = 1 To msg.argc
        Return("Argument " .. k .. ":" .. t[k - 1])
      Next
    EndSwitch
  EndSwitch
EndFunction
CreateRexxPort("MYCOOLPORT")
InstallEventHandler({OnARexx = p_EventFunc})
Repeat
  WaitEvent
Forever

End
Client:

Code: Select all

@VERSION 8,0

res$ = SendRexxCommand("MYCOOLPORT","GETSTRING")

DebugPrint("Result: " .. res$)


res$ = SendRexxCommand("MYCOOLPORT","GETNUMBER")

DebugPrint("Result: " .. res$)

res$ = SendRexxCommand("MYCOOLPORT","SOMETHING 'SOMEARGUMENT'")

DebugPrint("Result: " .. res$)    
ARexx test script:

Code: Select all

/* remember the first line of every Rexx script must be a comment */
OPTIONS RESULTS

/* the port of our Hollywood script is now the host */
ADDRESS MYCOOLPORT

GETSTRING

SAY RESULT

GETNUMBER

SAY RESULT

SOMETHING "SomeArgument"

SAY RESULT 

Re: SendRexxCommand does not return result

Posted: Mon Jun 01, 2020 12:21 am
by PEB
Try this for your client:

Code: Select all

@VERSION 8,0

res$ = SendRexxCommand("MYCOOLPORT","options results\nGETSTRING\nreturn result")

DebugPrint("Result: " .. res$)


res$ = SendRexxCommand("MYCOOLPORT","options results\nGETNUMBER\nreturn result")

DebugPrint("Result: " .. res$)

res$ = SendRexxCommand("MYCOOLPORT","options results\nSOMETHING 'SOMEARGUMENT'\nreturn result")

DebugPrint("Result: " .. res$)

Re: SendRexxCommand does not return result

Posted: Mon Jun 01, 2020 9:04 am
by amiga23
Thank you for this work arround, works great

Code: Select all

@VERSION 8,0

Function _SendRexxCommand(port, command)
  DebugPrint("SendRexxCommand >>> "..SendRexxCommand(port,command))
  DebugPrint("  With options >>>> "..SendRexxCommand(port,"OPTIONS RESULTS;"..command..";RETURN result"))
  DebugPrint("RunRexxScript >>>>> "..RunRexxScript("ADDRESS "..port..";"..command, True))
  DebugPrint("  With options >>>> "..RunRexxScript("ADDRESS "..port..";OPTIONS RESULTS;"..command..";RETURN result", True))
  DebugPrint("")
EndFunction

_SendRexxCommand("MYCOOLPORT","GETSTRING")

_SendRexxCommand("MYCOOLPORT","GETNUMBER")

_SendRexxCommand("MYCOOLPORT","SOMETHING 'SOMEARGUMENT'")