Send commands to sclang on Windows

Hey! Is it possible to send commands (sclang code) to a sclang process sitting in the background on Windows after it was started? Basically I assume this is what the SC IDE is doing, right?

Also I am curious if there is an interactive command line mode on Windows like in MacOS, after I started sclang from a terminal.

For the first question, something like this?

EvalListener  {
	classvar listener;
	*init {
		listener.free;
		listener = OSCFunc(path: '/eval', func: {
			arg message, time, address, receivePort;
			var result = message.second.asString.interpret;
			address.sendMsg("/result", result.asString);
		}).permanent_(true)
	}
}

Hey, thank you for the answer. Is it possible to explain a bit what it should do and how it would be implemented? It’s a bit above my knowledge about those things, I suppose. Actually I was searching for a way to send commands to sclang without launching the IDE at all.

Seems no, based on a test.

hjh

Just FYI the interactive command line on Windows has been fixed in the develop branch and will be available in the 3.13 release (or the current develop build).

EvalListener listens for /eval Osc messages. /eval has one argument, a string, which is interpreted. The result is converted to a string and sent as a /result reply message.

// initialise
EvalListener.init

// evaluate for effect (ignoring answer)
NetAddr("localhost", 57120).sendMsg("/eval", "{ SinOsc.ar(400, 0) * 0.1 }.play")

// evaluate for answer (with handler)
OSCFunc(path: "/result", func: { arg message, time, address, receivePort; message.postln }).oneShot;
NetAddr("localhost", 57120).sendMsg("/eval", "3 + 4")

Ps. sclang can run as a daemon (see the -D flag).