Running and compiling your first script
Experimenting in the REPL is fine for small code fragments and you should definitely use it, but soon you will want to keep your code in a file. Use your preferred code editor (or look at the last Development environments for writing Red section of this chapter for editors and IDEs with support for Red development) and type in the following text:
;-- see Chapter02/hello-world.red: Red [ Title: "Simple hello world script" ] print "Hello Red World!"
Save the file as hello-world.red
; .red
is the extension for Red source code files.
The Red [ ]
header block is mandatory; we'll see its purpose in the next chapter.
Executing a script in the Red console
Using the Red console, we can execute this script in five ways:
- If it is a small script, you could just copy the code that starts after the header and paste it into the REPL.
- Right-click on
hello-world.red
and chooseOpen With
. Browse to the Redbat
file (on Windows), and select it. The console opens up with the...