How to create a ScriptAction: HelloWorld

Now we will describe to create a nice small ScriptAction in a typical programmers scenario: Hello World! This is the most common scenario any programmer went through when he started to learn programming. So let's not break up with this tradition.

First of all we will need a button image again. As everyone (or nearly everyone) loves Koalas let's pick it as our example.

Then we will pick the "Blank Action" from the ScriptActions-tag in the left sided menu...

... and drag it onto our sweet koala.

Now we can start to edit our blank ScriptAction. Simply pick "Edit ScriptAction" from the context-menu.

On the first page we first define a nice fitting name for our new ScriptAction. Let's say it will be called "Hello World". For the internal usage it is needed that the "Script Name" is a legit JavaScript name for functions - this means no whitespaces, special characters and no leading number!

When we are finished picking a nice name we simply add a new script template with the green plus sign marked in the figure below.

Now we can start with the programming of our JavaScript. Let's use our high skills to write this really difficult programm...

Okay, okay... This was way to easy, wasn't it? So let's make it more dynamic by introducing a parameter which defines whom we want to greet. So click on the green plus sign next to the headline "Parameters" and define a simple text parameter as seen in the following figure:

The defined "Name in Script" has to fit the rules for JavaScript names as we will use this one to refer to the value.


Below is an example on how we can refer to our new parameter as it comes as function parameter for our HelloWorld function:

But you could also use the double curly brackets syntax to refer to the parameter as seen below - this could be easier at some points during the programming, especially when building output strings. Both ways are possible and you can pick what fits you the best.

Finally we can now edit the value from the outside without looking at the code to find the correct spot. This is perfect when working with non-programming people on the same campaign.

You could also assign a database column as seen in the figure below...

But be aware that this will only work in a pURL and not on a static page - there you will only see your reference directly :-)

Finally you can see here the result - tickle the koala's nose:

Congratulations!! You have successfully created your first own ScriptAction. Now you can go on and use the full force of JavaScript in your crossmedia campaigns.