Jump to content

Dynamically choose and execute a script in another file

This topic is 5645 days old. Please don't post here. Open a new topic instead.

Recommended Posts

The "the perform script" script step does not take a variable as the script name to perform. So you could do it with a huge if...end if statement and hard code all possibilites.

if($_scriptToRun = "this")

perform script "this"

else if($_scriptToRun = "that")

perform script "that"

else if ...


end if

You can do it without hard coding the scripts but it would require going outside of FM and using the Send Event script step to trigger a VBscript that in turn uses the DoFMscript ActiveX function to run a script of your choice. Since the VBscript can be entirely dynamic you can ask it to run any script you want.

Link to comment
Share on other sites

Check the FM help file for "activeX". (note that the examples there are for VB/VBA, not VBscript. But it's very similar).

www.microsoft.com/scripting is probably the best place to get started.

Link to comment
Share on other sites

Not really. These are the challenges though:

- FM cannot execute VBscript syntax directly out of a field (unlike the "perform applescript" script step in the Mac version of FM)

- so you need to take your VBscript syntax out of a field and ceate a physical VBscript file on the hard disk

- what location do you pick for that? The user must have write privileges on that folder

- when you execute that file (with the Send Event script step), FM does not wait for the result, it forges ahead with the next script step and this may cause you some timing issues if you need to wait for the result: how long do you make FM pause?

- when the VBscript is done, you probably need to delete it, otherwise the user may see it somewhere and decide to double-click it... executing it again

Those are the hoops you need to jump through. Totally feasible, I've been doing for years. But then I got tired of it and wrote a plugin to solve all these issues.

Link to comment
Share on other sites

I'll throw in that you could use the EventScript plugin to trigger a script based on a field value. So your generic script would first set a global field, and then send this to EventScript to trigger the specified script.

EventScript is a free plugin, and not that difficult to implement.


Link to comment
Share on other sites

This topic is 5645 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.