Hello,
This is my first question to the list. How can I make the pd equivallent to the "if-then-else" structure in pd?
Regards,
Terumi
ΓñçóéìïðïéΓ₯ΓΓ΄Γ₯ Yahoo! ΓÑñΓ₯Γ¨ΓΓͺÑôΓ₯ ôÑ Γ₯Γï÷ëçôéΓͺà ìçΓΓ½ ìÑôÑ (spam); ΓΓ― Yahoo! Mail ÀéÑèΓΓ΄Γ₯Γ© ôçà ΓͺÑëýôΓ₯Γ±Γ§ ÀáΓÑôà ðñïóôÑóΓΓ‘ ΓͺÑôà ôùà Γ₯Γï÷ëçôéΓͺþà ìçΓáìΓôùà http://login.yahoo.com/config/mail?.intl=gr
Hallo, Tas Pas hat gesagt: // Tas Pas wrote:
How can I make the pd equivallent to the "if-then-else" structure in pd?
This depends on what you want to put in the if-clause. Some useful objects to "branch" are [moses], [select], [route], [==],...
A typical idiom is a comparison operator combined with [select]:
| [> 10] | [select 0 1] | | | > 10 | <= 10
You can use [select some_symbol] to do something, if an incoming symbol matches. Non-matching symbols get send to the second outlet of this [select], so they would be the "else" clause.
[expr] has some shortcuts built in with its "if" operation. Check the helpfile for an example.
Frank Barknecht _ ______footils.org_ __goto10.org__
There are several ways to do it, and it will be a little different than the programming you might be used to.
First you can use the [select] object as a conditional - check the help file that comes with pd on that.
Another more complicated way is to use [expr] and its related objects, which I believe comes standard with Pd? I may be wrong on that because I have it pre-bundled. Anyway, probably better to use [select] first.
The control examples, if you go through them and work with each, will help you understand how to do that and a lot more - they helped me a lot (I just started Pd a couple months ago).
Kevin
On 7/18/06, Tas Pas tprotopgr@yahoo.gr wrote:
Hello,
This is my first question to the list. How can I make the pd equivallent to the "if-then-else" structure in pd?
Regards,
Terumi
Χρησιμοποιείτε Yahoo! Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Thanks for your immediate answer. The problem which occurs with [select] is that, when a match value reaches [select's] inlet, [select] sends a [bang] to the corresponding outlet and not the value it received and triggered the [bang].
What I want to do is to route the messages. If I send values in a specific range, I want them to go somewhere. If I send values beyond tha range, I want them to go somewhere else. In procedural programming languages it can be done with "if-then-else" and a variable. In pd the variable is not passed by the [select] and istead a [bang] message is sent. Is there a way to use [select] and have the value in a outlet or something?
Thank you, and forgive me if I am writing in a confusing way.
Regards,
Terumi
Kevin McCoy km.takewithyou@gmail.com ΓãñÑøΓ₯: There are several ways to do it, and it will be a little different than the programming you might be used to.
First you can use the [select] object as a conditional - check the help file that comes with pd on that.
Another more complicated way is to use [expr] and its related objects, which I believe comes standard with Pd? I may be wrong on that because I have it pre-bundled. Anyway, probably better to use [select] first.
The control examples, if you go through them and work with each, will help you understand how to do that and a lot more - they helped me a lot (I just started Pd a couple months ago).
Kevin
ΓñçóéìïðïéΓ₯ΓΓ΄Γ₯ Yahoo! ΓÑñΓ₯Γ¨ΓΓͺÑôΓ₯ ôÑ Γ₯Γï÷ëçôéΓͺà ìçΓΓ½ ìÑôÑ (spam); ΓΓ― Yahoo! Mail ÀéÑèΓΓ΄Γ₯Γ© ôçà ΓͺÑëýôΓ₯Γ±Γ§ ÀáΓÑôà ðñïóôÑóΓΓ‘ ΓͺÑôà ôùà Γ₯Γï÷ëçôéΓͺþà ìçΓáìΓôùà http://login.yahoo.com/config/mail?.intl=gr
Hallo, Tas Pas hat gesagt: // Tas Pas wrote:
Thanks for your immediate answer. The problem which occurs with [select] is that, when a match value reaches [select's] inlet, [select] sends a [bang] to the corresponding outlet and not the value it received and triggered the [bang].
Yes, [select] just starts another action through a bang, depending on input conditions. If you want to reuse the incoming value, you need to store it temporarily, for example in a [list] object's right inlet. Then bang the [list] with the [select]. Use [t a a] on top to get execution order right.
Frank Barknecht _ ______footils.org_ __goto10.org__
On Wed, Jul 19, 2006 at 10:30:55AM +0100, Tas Pas wrote:
The problem which occurs with [select] is that, when a match value reaches [select's] inlet, [select] sends a [bang] to the corresponding outlet and not the value it received and triggered the [bang].
You could do:
|
|
[t f f]
|
|
|
|
|
|
[select 5]
\ |
\ |
\ |
\ |
\ |
\ |
\ |
\ |
[f ]
What I want to do is to route the messages. If I send values in a specific range, I want them to go somewhere. If I send values beyond tha range, I want them to go somewhere else.
Have you tried [moses] ?
Best,
Chris.
chris@mccormick.cx http://mccormick.cx