Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Dynamically choose and execute a script in another file

Featured Replies

Hi all,

I know how to specify a file and run a script in that file, but can that file be dynamically selected? I plan to use this in my navigation system.

Any ideas?

Tim

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.

  • Author

Thanks Wim,

I am not familiar with vbscripting. Do you know of any links that could help in learning to use it?

Tim

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.

  • Author

Thanks Wim,

I will check it out. Does vbscripting get tricky in a multi-user, server hosted solution?

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.

Let me add that you can also keep a VBscript outside of FM and call it using parameters. That sort of solves the VBscript creation process.

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.

David

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.