How do I return a value from my LC customer component back to a variable in FileMaker?
My stack now appears when I run the line
Set Variable [$Output; Value: LC(“configuiv1”;”ABC”)]
So, “ABC” is an inbound parameter…and that is working great.
But now I want an outbound parameter as well.
There’s a bunch of JSON or XML I want to send back from LC to FM.
I don’t see this covered in the docs, but I assume it’s possible.
I suppose I can leverage FMPURL if necessary, but I’m assuming you have a better method.
Outbound Parameters?
Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller
Re: Outbound Parameters?
Hi @dan.toadllc
You can use the `return` statement in either a function or custom component. It's probably simpler to leave the XML in LiveCode and access it from FileMaker although you could return it all as text if you want. So your custom component might be something like this:
You can return any of the data types listed in the FileMaker Interoperation > Values section of the Handbook http://downloads.livecode.com/filemaker ... ndbook.pdf
You can use the `return` statement in either a function or custom component. It's probably simpler to leave the XML in LiveCode and access it from FileMaker although you could return it all as text if you want. So your custom component might be something like this:
Code: Select all
on FileMakerAction pAction
local tResult
switch pAction
case "SomethingThatCreatesXML"
put revXMLCreateTree("<some><thing>" & fmParam(1) &"</thing></some>", true, true, false) into tResult
if tResult is not an integer then
put fmErrorValue(tResult) into tResult
end if
break
case "GetXMLNodeContent"
put revXMLNodeContents(fmParam(1),fmParam(2)) into tResult
if tResult begins with "xmlerr" then
put fmErrorValue(tResult) into tResult
end if
break
end switch
-- tResult is the value that your action will return to filemaker
return tResult
end FileMakerAction
Code: Select all
Set Variable [$xmlID; Value: LC(“configuiv1.SomethingThatCreatesXML”;”ABC”)]
Set Variable [$value; Value: LC(“configuiv1.GetXMLNodeContent”;$xmlID, "/some/thing")]
--> $value should be "ABC" now
Last edited by monte on Thu Jul 13, 2017 12:31 am, edited 1 time in total.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: Outbound Parameters?
I have opened a report on improving the discussion of this in the handbook http://quality.livecode.com/show_bug.cgi?id=20075
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/