Getting Started

Tutorial

If you’re just getting started with Rockstar, the Rockstar Tutorial will walk you through the basics and have you up and rocking in no time.

“Hello, World”

“Hello World” in Rockstar looks like this:

print "hello world" (prints: hello world)

Printing things isn’t very rock‘n’roll, though. Rockers don’t print, they scream, shout, whisper or maybe just say things, so these are all valid aliases for print:

Scream "Hello Cleveland!" (prints: Hello Cleveland!)
Say "All I wanna know is..." (prints: All I wanna know is...)
Shout "Are you ready to rock?" (prints: Are you ready to rock?)

print adds a newline to the end of the output. If you don’t want this, use write:

Write 1. Write 2; write 3!
(writes: 123)

Write "A dream "
Print "of dolphins"
(prints: A dream of dolphins)

To read a line of input from STDIN, use the listen keyword. To read a line into a variable, use listen to <variable>:

Listen to the value
Until the value is nothing
Shout the value
Listen to the value

Almost everything in Rockstar is case-insensitive, and most whitespace is ignored:


  scream "hey!"

Rockstar statements end with a newline, or with any of the punctuation characters .?!;

Say 1. Say 2? Say 3! Say 4; say 5...
(prints: 1
2
3
4
5)

Command line parameters

If you’re running Rockstar from the command line, you can pass parameters to your Rockstar program. Parameters beginning - or -- are for the Rockstar interpreter itself:

| Argument | Effect | | —————– | —————————————————— | | -v, --version | Display the Rockstar version number and exit. | | -t, --timing | Display execution time when your program has completed | All subsequent parameters will be passed to your Rockstar program, where you can access them in a global array called arguments, or its aliases the outside or the world:

for arg in arguments
print arg
end

For every shadow in the world
Whisper the shadow
Yeah

Comments

The use of comments in Rockstar programs is strongly discouraged: this is rock’n’roll; it’s up to the audience to find their own meaning. If you absolutely insist on commenting your Rockstar programs, comments should be contained in parentheses (). Yes, this means you can’t use brackets in arithmetic expressions and may need to decompose complex expressions into multiple evaluations and assignments.

(This is a Rockstar comment)

(Rockstar supports nested comments (like this (see?)))

Shout (as loud as you can (like, REALLY loud!)) "nested comments are cool!"

(prints: nested comments are cool!)

Shout "Comments inside strings (like this (see?)) aren't comments"
(prints: Comments inside strings (like this (see?)) aren't comments)

Line comments

You can also use the # character to indicate a comment. Line comments last until the end of the line.

The only reason I did this is that one of you lot might actually be unhinged enough that you want to put a #!/bin/rockstar at the start of their Rockstar programs so you can run them straight from your terminal… and as much as that’s a terrible idea, I’m not going to stop you.

ChordPro comments

Since Rockstar programs are song lyrics, it stands to reason you might want to include the chords for your programs, so aspiring rockstar developers can play along at home, so Rockstar also allows comments to be surrounded by { } and [ ]

#!/bin/rockstar

{title: The Rockstar Blues}
{artist: Dylan Beattie}
{tempo: 120bpm}

{start_of_verse}
[A] Say "it's one for the money"
[A] Say "it's two for the show"
[D] Say "three to get ready"
[A] Say "now go go go"
{end_of_verse}

{start_of_chorus}
[D] Say 5? [D] Say 6? [A] Say 7? [A] Say 8!
[E] Say 9; [D] Say 10!
[A] Say 11
Say "and that's the Rockstar 12 bar blues"
{end_of_chorus}

Running this program through the ChordPro system produces this:

ChordPro example