Hi Alexandros
You can compare symbols for string equality by pointer equality (because
symbols are interned in a table and never released - fast equality check
is the whole point of symbols in Pd).
Something like this (untested):
static t_symbol *s_at_sync = 0;
extern void foo_setup(void)
{
s_at_sync = gensym("@sync");
...
}
void *foo_new(int argc, t_atom *argv)
{
if (atom_getsym(argv[3]) == s_at_sync)
{
sync();
}
...
}
Or you can get the pointer to the symbol's string from the symbol
struct, see m_pd.h for details. You must not modify the string, but you
could access it to see if it starts with '@' for example.
Claude
On 02/08/18 21:02, Alexandros wrote:
Coming back to this thread after some time.
I'm trying to check whether a given argument to an external I'm
writing starts with "@" or if it is actually "@sync", but can't seem
to make it work. Can't really understand how t_symbol works. I'm
iterating though the arguments with int argc and t_atom *argv and if
there are the right number of arguments, I'm retrieving the argument
that's supposed to be "@sync" with atom_gensym(argv);
I don't know how to compare that to a hard-coded string, like "@", or
"@sync". I tried comparing straight to these strings, tried strcmp(),
but I don't know how to do this, and couldn't find examples online.
Any hints?
On 26/02/2018 07:36 μμ, IOhannes m zmölnig wrote:
On 02/26/2018 08:09 PM, Alexandros wrote:
Being informed about the mailing list archive correct link, I searched
for messages about this but didn't find something (it's possible I've
missed something though).
I'm writing an external and I want to use an @ argument (for example
"@sync hard"). How does one implement this in C code?
either use flext (but then you write C++) and it comes for free.
or simply iterate over the arguments, looking for symbols starting with
"@" (or simply search for symbols that are "@sync"), then check whether
there's another argument after that and see which value it has.
fgdamrs
IOhannes
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management
->https://lists.puredata.info/listinfo/pd-list
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
https://lists.puredata.info/listinfo/pd-list
--
https://mathr.co.uk
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
https://lists.puredata.info/listinfo/pd-list