> On 29 Nov 2019, at 22:13, Michael Phelan <[email protected]> wrote: > > Are there examples of: > 1. returning a value from a ui:Operations subclass
ui:Operations subclasses cannot return a value other than the DOM nodes generated by its prototype. > 2. assigning a variable the value of the result of a ui:Operations subclass See above. > 3. updating an Argument in Pass By Reference style Arguments in SWP are passed by value. If you need to pass information between SWP elements in a way that doesn't match the usual control flow, you have a number of options: 1. Use global variables: https://uispin.org/ui.html#setGlobalVar <https://uispin.org/ui.html#setGlobalVar> 2. Store information in a temporary graph: https://uispin.org/ui.html#tempGraph <https://uispin.org/ui.html#tempGraph> 3. Make the SWP element a ui:Function, which is like a spin:Function with the body being an SWP script (ui:prototype instead of spin:body) and the result of the function returned via ui:return. See the comment on ui:Function in TBC for details. 4. Make the SWP element a normal element (not a ui:Operation), return the result as a text DOM node, and in the calling code assign the DOM result to a variable via ui:bind/ui:stringify: https://uispin.org/ui.html#bind <https://uispin.org/ui.html#bind> If all you need to pass around is a scalar value or string, then I would recommend option 1. If a more complex temporary data structure is needed, I would recommend option 2. Option 3 can work fine, but I avoid ui:Function when possible, because it mixes SWP elements and SPARQL functions in such a weird way (it's an SWP element, but you can't call it like an SWP element, but need to call it like a SPARQL function). Option 4 is too obscure for my taste. Hope that helps, Richard -- You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/A7B190A4-8465-46F1-A3C1-5CF85E8FCAB0%40topquadrant.com.
