On 2022-05-11 9:56 am, Rob Atkinson wrote:
HI I have a script that behaves as expected in the script editor but
when run as a resource action behaves differently.
two things
- a script that extracts some data from an asset collection and then
inserts it into a different asset collection works from the script
editor, but when run as a resource action doesnt complain or but the
data doesnt show up in the target graph. (The function is tagged as
dash:canWrite true BTW)
One potential difference could be the type of the variable focusNode.
Are you using that variable in your scripts?
and simpler case I noticed:
script assigns a string to a variable using
thing = `string template`
when I run console.log(thing) in the script editor it shows, as expected:
"string template"
but when I run this same code in an ADS resource action it renders it as
"[Object object]"
Hard to say without seeing the surrounding code. But just doing thing =
... may be a variable scope problem. Have you tried using *let* thing =
... instead, to make sure the variable is locally scoped?
And finally:
- is there a way of invoking the resource action directly from the
script editor
No but you could place the body of the resource action into a helper
function with a globally unique name and put that into a
dash:IncludedScript. For example
function myResourceAction(resource) { ... }
and then invoke myResourceAction(resource) from the Script Editor panel.
Or attach it to a class as a ShapeScript if you prefer OO programming style.
- is there any way of using the script debugger from a resource
action, commit or other trigger ?
No, this would be nice but quite hard to implement and get right. You
can imagine that running the debugger is already quite a low-level
operation... But maybe the above trick will help you debug this from the
Script Panel. All you may want to add are some guard clauses to verify
that the argument (resource/focusNode) have indeed the right type.
Holger
--
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/07bf423a-e8ae-3def-a30f-f45d8b05850b%40topquadrant.com.