Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to convert functional components to scripted components

24 views
Skip to first unread message

awiddie

unread,
Jan 25, 2011, 1:31:41 PM1/25/11
to
Hi,

We have created some functional components (FC) on our AL, but because
you cannot step through these with the debugger we are considering
changing them to script components (SC). However, if we do that, how
can we pass different variables (work attributes) to the script
components from the AL? Is there a way to define a subroutine that I
just call (like a library) from a FC without having to call hang my
script component on the AL?

For example, could we use a FC that has an input and output map to the
AL and it calls a routine I have defined in a script component? If
so, this is possible, can we use the debugger to step through the SC
as soon as it gets called?

Any other suggestions?

Thanks,
Amy

Eddie Hartman

unread,
Jan 26, 2011, 5:30:22 AM1/26/11
to

I know your pain, Amy. But unlike Scripted Connectors and FCs, the
Script components in your AL all share the Script Engine context
with the other comps. So a variable you declare in a Hook can
later be used in an AttMap, Condition or Script comp. So you
Script has access to the work Entry, as well as 'task' (the AL
itself).
When you script a Connector or Function Interface then you don't
have this luxury and must pass info to the component via the
Output Map or parameter settings. If you need to share
variables between different Scripted components then there
is the naughty technique of reading and writing to Java
properties. For example,

... In once component:
java.lang.System.getProperties().put("savedEntry", myEntry);
... In another comp:
retEntry = java.lang.System.getProperties().get("savedEntry")

Tread wisely :) When it comes to maintaining a script library for a
project, what I often do is set up one or more Global Prologs
that define my script functions. These are Scripts in the Navigator
that
I tell my AL to load at startup (via AL Options button > AL Settings
>
Include Prologs). If you don't need the scripted functions in the Feed
section, then you can implement as a Script in the AL itself. This
also simplifies debugging. To avoid redefining functions every cycle,
or resetting variables, I use the lazy-man's approach:
---
if (typeof(firstTime) != "undefined")
return; // no need to init once more

firstTime = true;

// define functions and init variables...
---
Scripted components are another matter.
Since you can't debug scripted comps, I also implement them
as a Script in the AL, calling the selectEntries() or putEntry() or
perform() directly, simulating att maps, etc. Then I slap a FormEntry
Connector into Feed and load it up with some relevant data.
Now I can step through the logic in the Debugger, checking that
my assumptions (and inspirations) hold water. Afterwards I copy
this code into the FC or Connector interface script. And I have
a testbed AL for future troubleshooting.

Hope this helps.
-Eddie

0 new messages