Difference between revisions of "Crash Course to Hollywood Programming"

From MorphOS Library

 
(11 intermediate revisions by the same user not shown)
Line 36: Line 36:
 
(Windows-only APK Compiler is required for the Android support).
 
(Windows-only APK Compiler is required for the Android support).
  
 +
[[File:HollywoodCourse-CubicIDE.gif|frame|240px|Cubic IDE with the Hollywood add-on]]
 
[http://www.hollywood-mal.com/designer.html Hollywood Designer] is an Amiga-only add-on to create multimedia presentations in a WYSIWYG GUI. It works
 
[http://www.hollywood-mal.com/designer.html 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
 
on Amiga compatible platforms including MorphOS, but the resulting presentations can be compiled for any
Line 47: Line 48:
 
a text editor or a 3rd party IDE is needed.
 
a text editor or a 3rd party IDE is needed.
  
[https://www.softwareandcircuits.com/division/amiga/products/cubic/index.html Cubic IDE] offers the best development environment for Hollywood programming on MorphOS. With the Cubic IDE [http://www.hollywood-mal.com/download.html add-on] you'll get syntax highlighting, automatic casing, online help, quick access to documentation,
+
The easiest way to get started is with [[Applications/FlowStudio|Flow Development Studio]], which is bundled with MorphOS. It includes a lexer for Hollywood, and offers syntax highlighting and other features.
 +
 
 +
[https://www.softwareandcircuits.com/division/amiga/products/cubic/index.html Cubic IDE] is still probably the most comprehensive development environment for Hollywood programming on MorphOS, although it is getting a bit outdated on some parts. For example, it doesn't have UTF-8 support and GUI isn't as flexible as a MUI GUI would be. With the Cubic IDE [http://www.hollywood-mal.com/download.html 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.
 
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
+
MiniHollyEdit NG could also be a good freeware option, but it's broken in its current state and needs an update first.
update first.
 
  
 
An IDE with Hollywood support is the most comfortable solution of course, but any other text editor will also do.
 
An IDE with Hollywood support is the most comfortable solution of course, but any other text editor will also do.
Line 57: Line 59:
  
 
=== Running a Script ===
 
=== Running a Script ===
+
 
 
Hollywood scripts can be run from the Hollywood main executable (the interpreter), and while the main executable
 
Hollywood scripts can be run from the Hollywood main executable (the interpreter), and while the main executable
 
accepts tens of command line [http://www.hollywood-mal.com/docs/html/hollywood/ManualUsage.html arguments], you don't usually need many of them.
 
accepts tens of command line [http://www.hollywood-mal.com/docs/html/hollywood/ManualUsage.html arguments], you don't usually need many of them.
Line 65: Line 67:
  
  
 +
[[File:HollywoodCourse-Run.png|thumb|240px|Running a script]]
 
To run a script from the shell:
 
To run a script from the shell:
 
  Hollywood MyProgram.hws
 
  Hollywood MyProgram.hws
Line 73: Line 76:
  
  
 +
[[File:HollywoodCourse-ResourceMonitor.png|thumb|116px|Resource monitor]]
 
Hollywood has a built-in resource monitor, which can be activated with the '''-resourcemonitor''' argument.
 
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
 
You should check the resources your application uses and that you aren't increasing the memory usage
Line 89: Line 93:
 
  Hollywood MyProgram.hws -compile MyProgram
 
  Hollywood MyProgram.hws -compile MyProgram
  
 +
[[File:HollywoodCourse-Compile.png|thumb|240px|Compiling a script]]
 
With the above command you get an executable called "MyProgram" that will run on the same archtecture it
 
With the above command you get an executable called "MyProgram" that will run on the same archtecture it
 
was compiled on.
 
was compiled on.
Line 98: Line 103:
  
 
Or for multiple platforms at once:
 
Or for multiple platforms at once:
  Hollywood MyProgram.hws -compile MyProgram.exe -exetype morphos|amigaos4|win32|applet
+
  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:
 
If you want to compress your own data (script and linked data files), add the '''-compress''' argument:
  Hollywood MyProgram.hws -compile MyProgram.exe -exetype morphos|amigaos4|win32|applet -compress
+
  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
 
Compressing can make executables smaller, but it also "hides" any plaintext data from the executables if
Line 112: Line 117:
  
  
== First Test ==
+
== Examples ==
 
 
Let's type this into a text editor and save it as a file called '''RAM:firsttest.hws''':
 
[http://www.hollywood-mal.com/docs/html/hollywood/atBGPIC.html @BGPIC] 1, "SYS:MorphOS/Prefs/Wallpapers/1024x768/Arida.png"
 
[http://www.hollywood-mal.com/docs/html/hollywood/TextOut.html TextOut](100,10,"Hello World!")
 
[http://www.hollywood-mal.com/docs/html/hollywood/WaitLeftMouse.html WaitLeftMouse]()
 
; Program exits after the last line in a script, but you can also terminate it with the [http://www.hollywood-mal.com/docs/html/hollywood/End.html End]() command
 
 
 
The first line is a [http://www.hollywood-mal.com/docs/html/hollywood/PrgPreproc.html preprocessor command] which loads the given image file as a Hollywood background
 
picture. Objects in Hollywood are handled by their '''ID numbers''', and in this case we load the image as
 
a bgpic number 1. That bgpic is also loaded initially when the application opens its window.
 
 
 
All preprocessor commands are prefixed with the '''@''' character and processed before the actual
 
script execution. Data files loaded with the preprocessor commands are also '''linked''' into the executable when
 
compiling a program. If you don't want to link the files, you can load them separately later in the script.
 
  
The second line prints the "Hello World!" text at x=100, y=10 (in pixels) over the background image.
+
* [[Crash_Course_to_Hollywood_Programming/Example_1_-_The_First_Test|Example 1: The First Test]]
 +
* [[Crash_Course_to_Hollywood_Programming/Example_2_-_Hollywood_Programming|Example 2: Hollywood Programming]]
 +
* [[Crash_Course_to_Hollywood_Programming/Example_3_-_System-Friendly_GUI|Example 3: System-Friendly GUI]]
  
The third line waits for the user to press the left mouse button. Without this line, the program would just end
 
and close its window, and we wouldn't see much.
 
  
The last line is a comment line, which is just a note inside the code. Comment lines can be inserted between
 
'''/*''' and '''*/''', or the rest of the line can be commented out with the ''';''' character.
 
  
 +
== Summary ==
  
Let's run the script to see the results. Hit the F4 key in Cubic IDE or type this in the shell:
+
This tutorial has hopefully given you some understanding of Hollywood programming, and it should be easier to learn more about the language
Hollywood RAM:firsttest.hws -quiet
+
by yourself. Hollywood also has a quite active [http://forums.hollywood-mal.com/ 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 [http://www.hollywood-mal.com/download.html plugin packages] too. Coding (and especially multiplatform coding) doesn't get easier than this ;)
  
Hollywood opens a new window and takes its dimensions from the background picture. If we wouldn't preload any
+
Have fun with Hollywood and let's see some new products in the future!
background picture, then the display would be opened in the default 640x480 resolution, or you could define
 
its dimensions with the [http://www.hollywood-mal.com/docs/html/hollywood/atDISPLAY.html @DISPLAY] preprocessor command.
 
  
  
Next let's compile the program into a standalone executable. Hit the F2 key in Cubic IDE or use the shell (you don't
+
== Links ==
have to define the paths if you've already changed directory to RAM: in the shell):
 
Hollywood RAM:firsttest.hws -compile RAM:firsttest
 
  
Now we have a new executable file that also contains the preprocessed/linked background graphics in it. The program
+
* [http://www.hollywood-mal.com/index.html Hollywood]
works even if you don't have the ''Arida.png'' file in the system.
+
* [http://forums.hollywood-mal.com/ Hollywood forums]
 +
* [https://www.softwareandcircuits.com/division/amiga/products/cubic/index.html Cubic IDE]
 +
* [http://jpv.wmhost.com/morphos/hollywood/ Files from this tutorial]

Latest revision as of 17:07, 10 September 2020

Author: jPV/RNO (Proofreading by Marq)

Preface

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.


Getting Started

Requirements

Hollywood

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).

Cubic IDE with the Hollywood add-on

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.


Text Editor

Hollywood features an IDE (integrated development environment) for Windows, but on other platforms a text editor or a 3rd party IDE is needed.

The easiest way to get started is with Flow Development Studio, which is bundled with MorphOS. It includes a lexer for Hollywood, and offers syntax highlighting and other features.

Cubic IDE is still probably the most comprehensive development environment for Hollywood programming on MorphOS, although it is getting a bit outdated on some parts. For example, it doesn't have UTF-8 support and GUI isn't as flexible as a MUI GUI would be. 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.


Running a script

To run a script from the shell:

Hollywood MyProgram.hws


And without the information window:

Hollywood MyProgram.hws -quiet


Resource monitor

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
Compiling a script

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.


Examples


Summary

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!


Links