Module 2 - Hello, World!
(Starts from the new "HelloWorld" script)
Huh? What does that mean? Well, it's a term used by programmers to embrace the concept of the very first program they write in any new programming language they learn. It represents probably the simplest thing they can get the code to do, and they then work their magic from there. Why that phrase in particular? Well, if you were a new-born baby and you could talk as soon as you were born, wouldn't your first words be "Hello, world - here I am!". Thus, to a programmer it represents the birth of their new set of skills in the new programming language.
Since scripting is a form of programming, we are going to follow that tradition. Our first script is going to do the same.
- Assuming your editor is open, click Insert Text on the CONTENT ribbon panel and enter "Hello, World!" into the single line edit box and click Insert:
You should see the command go into the pane on the right as TEXT "Hello, World!", and on the page to the left...
Disappointed? Nothing appears. What's gone wrong? Answer: nothing - we just haven't given the parser enough information to do what we want.
- Click End Of Line on the CONTENT ribbon panel.
Now are you happy? As long as you haven't accidentally clicked in the box to the right and changed where the solid bar was, you should now see your masterpiece rendered on the left.
So, why did we need that end of line ("EOL" in the script)? Why didn't it print it out straight away? Answer: how can it know you meant that that was the entire line you wanted? What if you wanted more text on that same line? You could argue that if you had wanted more, you'd have put more into the box when you entered the text the first time; but there are good reasons for it, which you will see later.
For now, understand that in order to render a line of text, the parser needs to see an EOL at some point to know when the current line is complete. Think of it like having to use the lever to push the typewriter's barrel back to the start position after each line.
For practice, exit the script editor using the OK button to save this script, and then start a new script called "TextChunk" (no quotes). When you're back with the editor open and waiting, read on.
For practice, exit the script editor:
Now start a new script called "TextChunk" (no quotes). When you are back with the editor open and waiting, read on.