Hallo Brien, briencrean@eircom.net hat gesagt: // briencrean@eircom.net wrote:
I have attached a simple patch below in txt format. I dont understand why when using the 'symbol' object I can instantiate the $1 variable to a string and when I try the same with the $2 variable it says "error: $2: argument number out of range".
You've run into one of the issues in Pd that is most difficult to understand for beginning Pd users (the other is execution order, which you will probably run into next week. ;)
The culprit is the funky way, Pd messages are constructed. I would recommend to read http://puredata.info/dev/PdMessages for an introduction. Basically it's this: Pd messages consist of two parts, the so called "selector" and the "data" following it. The selector tells Pd what kind ob data it should expect. Typical selectors are "symbol" "float" and "list". A complete symbol-message then looks like this: "symbol WORD". Sometimes the selector is implicit and can be omitted. "float 3" is the same as "3" because of this. However the "symbol"-selector never can be omitted: "symbol WORD" is something different from "WORD". The latter is a "WORD"-message, but no "symbol"-message anymore. (Those kinds of messages sometimes are called "meta-messages". The [read -resize somefile.wav( message of soundfiler is an example: It's a "read"-meta-message.)
Now comes the tricky part: In dollar expansion, the selector is ignored. $1 starts counting at the first element of the data-part of a message. So if you have a message [$1( and send it a [symbol WORD( message, it will result in "WORD", however if you send just "WORD" it will give you a: "error: $1: argument number out of range" warning.
My hope is to use the $1 and $2 as part of a message for a read message for the 'soundfiler' object so that I can read multiple sound files into multiple tables using a text file (which will contain the sound file names and table name).
You can do two things here: Either store stuff with the proper selector like "symbol filename.wav;" in your [textfile] or use another common trick: [list] is a fabulous object to convert everything to proper Pd messages. Just put a [list] in from of your [open $1( message and all will be fine and dandy.
For example if you send [WORD( into [list] out comes a "symbol WORD" message just as you want for your [read $1( message box.
Frank Barknecht _ ______footils.org_ __goto10.org__
On Wed, 19 Jul 2006, Frank Barknecht wrote:
The selector tells Pd what kind ob data it should expect.
The selector tells Pd which method to select.
However, four selectors have predecided signatures:
bang : no arguments float : 1 A_FLOAT symbol : 1 A_SYMBOL pointer : 1 A_POINTER
Outside of this, selectors typically don't indicate kinds of data: instead they indicate which action should happen or which attribute should be modified, because those are the things that distinguish one method from another.
Those kinds of messages sometimes are called "meta-messages".
They are also sometimes called "anythings" or "anything elses" or just "messages" or...
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada