10.1 Variables and constants

A variable can be used to store a piece of data under a given name. In Hollywood variables do not have to be declared. This means that you can simply assign a value to a variable without having to define the type for the variable first. Hollywood will do this automatically. Your variable name must start with a character from the English alphabet (a-z) or an underscore (_). After the first character, you may also use numbers, the exclamation mark (!) and the dollar sign ($). It is suggested that you use the dollar sign only in variables of the type string. As Hollywood is a case insensitive language, all variable names are case insensitive too. This means that, for example, the names "MYVAR" and "myvar" refer to the same variable. Hollywood is a dynamically typed language, which means that variables are also dynamic. For instance, the following does work without problems:

myvar = 1.5
myvar = "Hallo"
myvar = {1, 2, 3}
myvar = Function(s) DebugPrint(s) EndFunction

You can change the type of a variable on-the-fly. But this is not good programming practice!

Constants are fixed values that are globally available from everywhere in your script. They are prefixed with a hash character (#) so that you can distinguish them from variables and functions.

Show TOC