5 Replies Latest reply on Jan 3, 2015 9:41 AM by philmodjunk

    getting a script to go home...



      getting a script to go home...


      I know that a script can be 'called' from inside another script, but is there a way for it to go back to the originating script without specifically referencing that original script?

      An example: I've got scripts A, B and C.  Each one of them uses script D.  Can A call on D and have D return control to A without D having something in it that 'knows' that it came from A?

      TIA for any assistance.





        • 1. Re: getting a script to go home...

          Yes. After a sub-script is done executing, control is automatically returned to the parent script at the point of that Perform Script step (assuming the sub-script didn't exit by using the Halt Script step, which I recommend you never use). Further, if the sub-script uses the Exit Script step, it can return a result that can be retrieve in the parent script with the Get ( ScriptResult ) function.

          • 2. Re: getting a script to go home...

            Jeremy, could you be so kind as to explain why you would never use a Halt Script step?

            • 3. Re: getting a script to go home...

              I have seen that advice before (that halt script never be used). I understand the concern--it halts all current scripts, but don't agree that it never be used. 

              • 4. Re: getting a script to go home...

                In any long-lived solution, any script should expect that it can at some point become a sub-script of some other script (even if the file was originally developed with one convention or another that limits which scripts call which other scripts). The Halt Script step interrupts the operation of any parent scripts, which then don't have the opportunity to perform important clean-up operations or restoring the UI to an appropriate state to satisfy user expectations. The counter-claim to this is that you can just open the script you're calling as a sub-script and see if it's using Halt Script or not and adjusting the parent script accordingly. However, by doing so, you'd be robbing yourself of the most important value of having functionality in sub-scripts: you can forget how they work, which frees you to think about other aspects of the application. A script with the Halt Script step is a script that has to stay top-of-mind no matter how deeply buried it winds up in a solution, distracting you from whatever else you have to do.

                • 5. Re: getting a script to go home...

                  I agree that this is a very valid concern. But I would never say "never" to the halt script. It's just too useful in specific cases.

                  Always use Exit Script to exit a script short of the end or to return a value--unless there is a very specific reason that requires that you use Halt Script when Exit script won't do the job.