How to include external scripts

Post Reply
alexbevi
Newbie
Posts: 6
Joined: Thu Feb 14, 2013 6:43 pm

How to include external scripts

Post by alexbevi »

In a lot of scripts that require interacting with external systems, I'm forced to hardcode URLs, connection information, usernames, passwords ... etc.



Is there a way to maintain a single script that can be included in other scripts?



This way if I need to update a constant, I do it once and know it will be used properly?



I'm basically wondering if Switch provides something along the lines of http://requirejs.org
alexbevi
Newbie
Posts: 6
Joined: Thu Feb 14, 2013 6:43 pm

How to include external scripts

Post by alexbevi »

In case any Enfocus developers read this, there's an interesting article at https://github.com/amdjs/amdjs-api/wiki/AMD that may help facilitate this (and similar) requests in the future.
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

How to include external scripts

Post by freddyp »

Not that you have to convince me of how nice it would be to have a sort of include/define capability, but as we do not have it right now, let me suggest the following alternative.



In Switch you can maintain global data which is accessible to all flows. Look at the documentation of the Environment class. It is really easy to make a flow with just one script in it that sets the global data. And in all your scripts you get the global data. When there is a change of parameters you edit the one script, run the flow and all your scripts will access the new values of the global data.



Freddy
alexbevi
Newbie
Posts: 6
Joined: Thu Feb 14, 2013 6:43 pm

How to include external scripts

Post by alexbevi »

Thanks for the feedback Freddy.



I've been using the global data approach to accomplish the equivalent of 'Environment Variables', but what I really want is an attachable source file that would allow for common script functions to be defined.
Post Reply