Execute -- synchronously execute a program
Execute(file$[, args$, t])
Deprecated syntax
Execute(cmdline$[, resetkeys])
This function executes the program specified by file$ synchronously and passes the arguments specified in args$ to it. If you need to execute a program asynchronously, you have to use the Run() function. See Run for details.

If supported by the operating system, this command can also be used to view data files like documents or images using their default viewer. In that case, file$ can also be a non-executable file like a JPEG image or an MP3 file.

On Android file$ has to be either a data file like a JPEG image or a package name like com.airsoftsoftwair.hollywood if you want this function to start another app.

Note that due to historical reasons, there are some pitfalls when using this function. Before Hollywood 9.0 this command expected program and arguments combined in just a single cmdline$ string. In that case, extra care has to be taken when dealing with spaces (see below for details). Starting with Hollywood 9.0, there is a new syntax which allows you to pass program and arguments as two separate arguments which makes things much easier. However, to maintain compatibility with previous versions this new syntax can only be used if you explicitly pass a string in the second argument. So if you want to use the new syntax, make sure to pass a string in the second argument. If the program you want to start doesn't need any arguments, just pass an empty string ("") just to signal Hollywood that you want to use the new syntax.

If you don't pass a string in the second argument, the old syntax will be used which means that you need to be very careful when passing program paths that contain spaces since the very first space in cmdline$ is interpreted as the separator of program and arguments. If you want to start a program whose path specification uses spaces, you need to use double quotes around this path specification or it won't work. You can easily avoid these complications by simply passing a string in the second argument, even if it is empty (see above for details).

Starting with Hollywood 9.0, it is possible to specify the program and its arguments in two separate arguments, which makes things much more convenient. Also, there is a new optional table argument now that can be used to specify further options.

The following options are currently supported by the optional table argument:

This table argument allows you to set the current directory for the program that is to be started. (V9.0)

This table argument is only interesting for advanced users. If this is set to False, Execute() won't reset all internal key states after executing the program. By default, all key states will be reset when Execute() returns because programs started using Execute() often assume the keyboard focus and Hollywood might be unable to reset its internal state flags because the new program started via Execute() takes over keyboard focus. That's why by default Execute() will reset all internal key state flags when it returns. Disabling this behaviour can make sense if you use Execute() to start programs that don't have a GUI and don't take away the keyboard focus. Defaults to True. (V5.1)

If this tag is set to True, Execute() will always treat the file passed in file$ as an executable. This is only useful on Linux and macOS because on those platforms files that have an extension will be treated as data files so Hollywood will try to launch the corresponding viewer for the data file instead. Thus, trying to use Execute() on an executable named "test.exe" will not work on Linux and macOS because of the *.exe extension. By setting ForceExe to True, however, you can make it work. Defaults to False. (V9.0)

On Windows, this can be set to a string telling Execute() what to do with the file. This can be one of the following verbs:

Opens the specified file in an editor.

Opens the specified folder in Explorer. When using this verb, you must pass a folder instead of a file to Execute().

Opens the search dialog for the specified folder. When using this verb, you must pass a folder instead of a file to Execute().

Opens the specified file.

Prints the specified file.

Launches the specified file in administrator mode.

Note that the Verb tag is only supported on Windows. (V9.1)

the program (or data file) to be started
optional: arguments to pass to the program; note that you must pass this parameter to signal Hollywood to use the new syntax; you can do so by just passing an empty string (""); see above for a detailed discussion (V9.0)
optional: table containing further arguments (see above) (V9.0)
On AmigaOS systems the above code executes the locale preferences. Your script's execution will be halted until the user closes the locale preferences (synchronous execution).

Execute("Echo", ">Ram:Test \"Hello World\"")
On AmigaOS systems the above code writes "Hello World" to "Ram:Test".

Execute("\"C:\\Program Files (x86)\\Hollywood\\ide.exe\"")
The code above runs the Hollywood IDE on Windows systems. Note that we've embedded the program specification inside double quotes. This is absolutely necessary because the first space in the string passed to Execute() is normally interpreted as the separator between program and arguments. If we didn't use double quotes in the code above, Execute() would try to start the program "C:\Program" and pass the arguments "Files (x86)\Hollywood\ide.exe" to it which we obviously don't want. Note that since Hollywood 9.0, it is now much easier to deal with spaces in paths. You just need to use the new syntax which takes the program and its arguments in two separate arguments. With Hollywood 9.0, you could simply use this code:

Execute("C:\\Program Files (x86)\\Hollywood\\ide.exe", "")
Note that passing the empty string in the second argument is absolutely necessary here to signal Hollywood that you want to use the new syntax. See above for a detailed discussion on this.

Show TOC