

When code is not surrounded by parentheses it is generally intended to be executed one line at a time. Experiment with this to learn how your system behaves. Then stick to the technique that works best for you. to first always check you have selected all of the intended code, regardless of the selection technique, before pressing either Ctrl-Enter or Shift-Enter (Cmd-Return or Shift-Enter on macOS). Thus it may be good, to make it a habit to stick to a particular technique. On some it may only select the double clicked word. (ĭouble clicking inside a pair of enclosing parentheses may not select the entire region on all systems, notably not on modern Macs. You can have your cursor anywhere in this region (or on the line of the parentheses on macOS), then double-click and press Ctrl-Enter or Shift-Enter (Cmd-Return or Shift-Return on macOS) - this selects the whole region and executes it. In general, when you are meant to execute several lines of code at the same time they will be surrounded by parentheses, as in the example below. The first line, 'Hello there, I'm SuperCollider!' would not have printed if we didn't have the explicit postln. "Hello there, I'm SuperCollider!".postln Select both lines of text by clicking and dragging over them, and then execute, i.e. So in this case we didn't really need the postln bit. So it first prints because we explicitly told it to print, and then it prints the result of this operation, which happens to be the same in this case. Why did it print twice? Well, when you execute code in SC, it always posts the result of the last bit of code (the last statement). This can be very handy when tracking down bugs in your code. You can apply it to almost anything in SC and get something meaningful back. postln, says 'print me (or a meaningful description of me) to the post window.' Remember postln, it's your friend. More about that later, but for now just understand that a String is a way of representing a bit of text. An object is basically just a way of representing something in the computer, for instance a bit of text, or an oscillator, that allows you to control it and send messages to it. The first bit, "Hello World!", is a kind of Object, called a String. Now let's take a closer look at the code. Hello World!Īlternatively you can also first select the code you wish to execute (by clicking and dragging over the text until it is highlighted) and then press Ctrl-Enter (Cmd-Return on macOS). If all went well, you should see this in the post window.

To execute it, simply click to place the cursor somewhere on the same line as the code and then press Shift-Enter (Shift-Return on macOS).

It's also where we'll get the result of our Hello World program, which you can see below: "Hello World!".postln The post window is the one that opened up when you first started SC, and a bunch of stuff was printed there which looks something like this: init_OSCĬompiling dir: '/Applications/SC3/SCClassLibrary'ĭon't worry too much about what all that means just now, just keep in mind that this is where SC will send you information.

In SC that's a place called the post window. This just makes the program print the text 'Hello World!' to well, wherever it prints text. It is traditional when learning a new programming language to start with a simple program called 'Hello World'. See the helpfile Keyboard Shortcuts for key commands when using other tools such as SC enhanced editors, e.g. menu commands, are platform specific, but the principles extend to all platforms. NOTE: This document is written so that it can be used on all supported systems, though having first of all macOS in mind using the application SuperCollider (SCapp).
