Crash Course to Hollywood Programming
From MorphOS Library
Author: jPV/RNO (Proofreading by Marq)
Hollywood - the cross-platform multimedia application layer - is an easy programming/scripting language that is designed for the creation of graphical or multimedia-oriented applications, but it can also be used to create other kinds of programs, especially with its comprehensive selection of plugins. Hollywood is loosely based on the popular Lua language.
Hollywood programs are created by writing script files, which are then run from the Hollywood main program, or they can be compiled into applets or standalone executables to be used without the Hollywood environment.
Applets are small platform-independent binary files which can be run using the free Hollywood player on any supported platform. Standalone executables contain the player, a script and optional data files linked into a single executable file. Linking the whole player binary into an executable makes the minimum size of Hollywood executables around 2 megabytes on MorphOS, but then the resulting programs are completely independent and can be run out of the box without any prior installation.
What makes Hollywood special is its ability to cross-compile programs between all supported platforms. Windows, Linux, OS X, or Amiga programs can be compiled just by using MorphOS, and so on. Cross-compiled programs don't usually need any modifications and the same source script will work on all platforms.
Hollywood is an easy, safe, and very well documented language, and thus also suitable for beginners. All Hollywood programs run inside a sandbox, and you can't break or crash the underlying operating system with your programming mistakes. If there's a bug causing an error in the script execution, Hollywood just closes the program and frees the resources with no further harm.
Hollywood is a commercial product which can be bought here. The main package is enough for Hollywood programming and compiling for all other platforms except Android (Windows-only APK Compiler is required for the Android support).
Hollywood Designer is an Amiga-only add-on to create multimedia presentations in a WYSIWYG GUI. It works on Amiga compatible platforms including MorphOS, but the resulting presentations can be compiled for any other supported platform. Anyway, it isn't required for programming with Hollywood, but your own code can be inserted into presentation scripts too.
Hollywood features an IDE (integrated development environment) for Windows, but on other platforms a text editor or a 3rd party IDE is needed.
Cubic IDE offers the best development environment for Hollywood programming on MorphOS. With the Cubic IDE add-on you'll get syntax highlighting, automatic casing, online help, quick access to documentation, automatic indentation, bracket matching, auto completion of keywords, compile and run options, and a lot more.
MiniHollyEdit NG could also be a good freeware option, but it's broken in its current state and needs an update first.
An IDE with Hollywood support is the most comfortable solution of course, but any other text editor will also do.
Running a Script
Hollywood scripts can be run from the Hollywood main executable (the interpreter), and while the main executable accepts tens of command line arguments, you don't usually need many of them.
When you're developing and testing your application, it's enough to just run the script without compiling it. It's a good practise to save your scripts with the .hws extension.
To run a script from the shell:
And without the information window:
Hollywood MyProgram.hws -quiet
Hollywood has a built-in resource monitor, which can be activated with the -resourcemonitor argument. You should check the resources your application uses and that you aren't increasing the memory usage carelessly:
Hollywood MyProgram.hws -resourcemonitor
If you're using Cubic IDE, you don't need the shell at all. You can just press the F4 key to run the script or select other running options from Cubic IDE's menus.
Compiling a Script
When an application is ready for publishing, it should be compiled into a standalone executable, which is done with the -compile argument:
Hollywood MyProgram.hws -compile MyProgram
With the above command you get an executable called "MyProgram" that will run on the same archtecture it was compiled on.
To compile an application for different platforms (OS4 in this example):
Hollywood MyProgram.hws -compile MyProgram -exetype amigaos4
Or for multiple platforms at once:
Hollywood MyProgram.hws -compile MyProgram -exetype morphos|amigaos4|win32|applet
If you want to compress your own data (script and linked data files), add the -compress argument:
Hollywood MyProgram.hws -compile MyProgram -exetype morphos|amigaos4|win32|applet -compress
Compressing can make executables smaller, but it also "hides" any plaintext data from the executables if you prefer that.
Compiling in Cubic IDE is simply done by pressing the F2 key or by selecting the platform for cross-compiling from the menus.
This tutorial has hopefully given you some understanding of Hollywood programming, and it should be easier to learn more about the language by yourself. Hollywood also has a quite active web forum where you can find help on any issues by using the search field or by starting new discussion threads. There are many example scripts included with Hollywood and its plugin packages too. Coding (and especially multiplatform coding) doesn't get easier than this ;)
Have fun with Hollywood and let's see some new products in the future!