<?php
http://pear.php.net/go-pear
ini_set('include_path', '/Users/alex/puredata/projets/phpext' . ':' . ini_get('include_path'));
require_once 'Net/DataFlow/PhpExt.php';
class PureData_Example extends Net_DataFlow_PhpExt {
@var
var $_vars = array();
function on_phpset() {
$args = func_get_args();
$key = $args[0];
unset($args[0]);
if (is_string($key) || is_int($key)) {
$this->_vars[$key] = $args;
}
}
function on_phpget($key) {
if (isset($this->_vars[$key])) {
$this->send($this->_vars[$key]);
}
}
function on_tellme() {
$args = func_get_args();
$this->send($args);
}
function on_sqrt($num) {
if (is_numeric($num)) {
$result = sqrt((float) $num);
echo $result . " is the result \n";
$this->send($result);
}
}
}
$phpext =& new PureData_Example;
$phpext->setVerbose(TRUE);
$phpext->setPdReceive('localhost', 9090, 'sequential');
$phpext->setPdSend('localhost', 9092);
$phpext->start();
?>