open-source utilities and extras for Max/MSP
[ start | index | login ]

Hello World

Created by nick. Last edited by nick, one year and 229 days ago. Viewed 943 times. #1
[edit] [rdf]
labels
attachments
We kick off by writing a simple script which prints "Hello World." to the Max window. The Max window is a console for Max status and error messages; you can open it by selecting "Max Window" from the "Window" menu, or typing Command-M (Mac) or Control-M (Windows).

Since we're going to create a Python script file, we need a decent text editor, ideally one which understands the Python language and can do colour highlighting. On the Mac, I recommend the free >>TextWrangler. (Recommendations for Windows would be welcome.)

This is our "Hello World" script:

'''
This is a script which prints "Hello World"
to the Max window.
'''

print "Hello World."

This script has two parts. The first is the documentation string, a comment describing what the script does (the comment is contained within triplets of single-quote characters):

'''
This is a script which prints "Hello World"
to the Max window.
'''

The second part is the the actual one-line script statement itself:

print "Hello World."

Create a file containing this script, and save it with a name like "HelloWorld.py" in the directory which contains shado-workbench.PLACE_HOLDER. Now click the workbench button labelled "list text files". You should see HelloWorld.py in the dropdown menu.

When you select HelloWorld.py, two things should happen:

  • The "about" text area in the workbench will show the documentation comment for the script
  • The message "Hello World." will appear in the Max window
That's basically it: the script has done its job, and has now finished executing. We haven't yet communicated with the monome, or attempted to use the shado library: that comes next.

Further Reading

There is a long and detailed Python tutorial >>here. I recommend bookmarking it for future reference. (It refers to Python version 2.6; the workbench's Java-based Python interpreter is at version 2.2, but the language differences should be minor.)

There is some discussion of documentation strings >>here.

no comments | post comment



< September 2010 >
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
2627282930

XHTML 1.0 validated
CSS validated
RSS 2.0 validated
RSS Feed

Contact: Nick Rothwell

Powered by SnipSnap 1.0b3-uttoxeter

Open Source Java and UI Software for MaxMSP

ff194

The fireflash spanning router for the >>monome.

shado-small

The shado compositing and sprite library for the >>monome.


jython-logo

The Python programming language embedded in MaxMSP/MXJ


groovy-50

The Groovy programming language embedded in MaxMSP


small_powered_by

A Jetty-based embedded web server for MaxMSP, with JSP support


hsqldb

SQL database support, using HSQL or Apache Derby (embedded), or MySQL


nixie

Nixie tubes for Max


buttonsx

Rotating, alignable, colourable, assignable, pattr-aware arrays of text


Legacy Software

snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt