is possible to convert a symbol to int?
i have a number into a symbol, and:
[symbol (5442)] | [ set $1 ( | [ numberbox ]
but when i bang the symbol object pd says:
error: Bad arguments for message 'set' to object 'nbx'
is there a specific object to do this?
Maybe [set float $1 < ?
I dunno...
B.
federico wrote:
is possible to convert a symbol to int?
i have a number into a symbol, and:
[symbol (5442)] | [ set $1 ( | [ numberbox ]
but when i bang the symbol object pd says:
error: Bad arguments for message 'set' to object 'nbx'
is there a specific object to do this?
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
hi
you can use a really bad hack, if you don't want to use any externals. just put a [netsend]/[netreceive]-pair between (see attachment). it seems, that this takes the 'headers' of the list elements away and converts msgs to what you would see, when you print them. but be aware that you cannot do this when triggering [symbol 234], since you will loose control over the execution order. (it's just a very bad hack)
roman
federico wrote:
B. Bogart ha scritto:
Maybe [set float $1 < ?
I dunno..
nope.
with set float $1 any symbol is converted to zero.
do i really need an atoi() (or stoi()) external?
federico wrote:
B. Bogart ha scritto:
Maybe [set float $1 < ?
I dunno...
nope.
this does not work since pd tries to parse as few messages as possible. creating a message [float 123( will make pd parse this message resulting in an atom of type float with the value 123. however, sending a symbol "123" to [set float $1( will produce a message that looks like [float 123( but this message is already parsed (and internally saved as an identifier "float" followed by a symbol "123"), so this is a no go.
using roman's suggestion with using [netsend]/[netreceive], you ensure that the message is parsed again (since pd doesn't know what is coming in over the net)
with set float $1 any symbol is converted to zero.
do i really need an atoi() (or stoi()) external?
[atoi] is part of zexy.
mfg.a.dr iOhannes
On Sat, 11 Jun 2005, federico wrote:
is possible to convert a symbol to int? i have a number into a symbol, and: [symbol (5442)] but when i bang the symbol object pd says: error: Bad arguments for message 'set' to object 'nbx' is there a specific object to do this?
pd -lib gridflow
and put this external in your ~/.gridflow_startup :
GridFlow::FObject.subclass("atof",1,1) { def _0_symbol s m = /[-+0-9.eE]+/ .match s.to_s send_out 0, Float(m[1]) end }
This is a [atof] external which will extract the first numeric string in a symbol message and output the corresponding float.
note: I didn't test the above code, so if someone tells me it doesn't work, I'll correct the typos. (my computer just blew up so I don't have access to PureData at the moment)
,-o--------o--------o--------o-. ,---. irc.freenode.net #dataflow |
| The Diagram is the Program tm| | ,-o-------------o--------------o-.
-o------------o-------------o-' | | Mathieu Bouchard (Montréal QC) | | téléphone:+1.514.383.3801
---' `-o-- http://artengine.ca/matju -'
On Sat, 11 Jun 2005, Mathieu Bouchard wrote:
GridFlow::FObject.subclass("atof",1,1) { def _0_symbol s m = /[-+0-9.eE]+/ .match s.to_s send_out 0, Float(m[1]) end }
sorry, I wanted to say send_out 0, Float(m[0])
,-o--------o--------o--------o-. ,---. irc.freenode.net #dataflow |
| The Diagram is the Program tm| | ,-o-------------o--------------o-.
-o------------o-------------o-' | | Mathieu Bouchard (Montréal QC) | | téléphone:+1.514.383.3801
---' `-o-- http://artengine.ca/matju -'
pd -lib gridflow
and put this external in your ~/.gridflow_startup :
GridFlow::FObject.subclass("atof",1,1) { def _0_symbol s m = /[-+0-9.eE]+/ .match s.to_s send_out 0, Float(m[1]) end }
This is a [atof] external which will extract the first numeric string in a symbol message and output the corresponding float.
note: I didn't test the above code, so if someone tells me it doesn't work, I'll correct the typos. (my computer just blew up so I don't have access to PureData at the moment)
whooops.. i read too late your post, and my hand was faster than me to write this external: atoi (any-to-int) http://xaero.ath.cx/cms/?53
however i saw interesting features in gridflow, and when i got a moment i will install it..