[Cs-dev] Is there a way to have a string as an optional
Date | 2013-04-18 23:04 |
From | Andres Cabrera |
Subject | [Cs-dev] Is there a way to have a string as an optional |
Attachments | None None |
input argument to an opcode? Cheers,Andrés |
Date | 2013-04-18 23:23 |
From | Steven Yi |
Subject | Re: [Cs-dev] Is there a way to have a string as an optional |
Hi Andres, There are no optional types for Strings currently. There is a var-arg type "N" that will match against a String, and the var arg types are zero-to-many, but it's not quite the same. Optional types are done by using a new letter; it'd be nice to have the arg specifiers have modifiers for things like k? to mean optional k, or k* to mean var-arg k, but it's not currently possible. steven On Thu, Apr 18, 2013 at 11:04 PM, Andres Cabrera |
Date | 2013-04-19 00:30 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Is there a way to have a string as an optional |
Attachments | None None |
Hi Steven, Thanks. In this case, 'N' will do as the string argument is the last one.Andrés
On Thu, Apr 18, 2013 at 3:23 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Andres, |
Date | 2013-04-19 00:39 |
From | Steven Yi |
Subject | Re: [Cs-dev] Is there a way to have a string as an optional |
Okay, but just to be aware, the semantic checker may then allow for a user to set multiple strings at the end of your opcode, and if that happens, it could possibly overwrite memory if there's not enough space allocated in the dsblksize for your OENTRY. If you go this route, you should probably just pad your opcode struct as a just in case, plus do some init-time checking to see only one string was set. Another option is to add an optional type to csound_standard_types.c for in types. I thought at first that doing something like that might make things harder to change later. If the opcode is included with Csound, then I guess it'd be easy enough to modify the arg string to the opcode in conjunction with any future changes. You'd just have to pick a letter that's not in use right now for any of the in arg types. On Fri, Apr 19, 2013 at 12:30 AM, Andres Cabrera |
Date | 2013-04-19 00:40 |
From | Steven Yi |
Subject | Re: [Cs-dev] Is there a way to have a string as an optional |
Oh, you might also have to modify another string somewhere... but I can't recall at the moment. Anyways, if you try it and it doesn't work, it means there's another place to modify. :P On Fri, Apr 19, 2013 at 12:39 AM, Steven Yi |
Date | 2013-04-19 00:51 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Is there a way to have a string as an optional |
Attachments | None None |
Thanks Steven. I've taken the easy route of using N and allowing 64 arguments, but just using the first one. This is for the chn_k opcode to allow it to take a string as its last argument.Cheers, Andrés On Thu, Apr 18, 2013 at 4:39 PM, Steven Yi <stevenyi@gmail.com> wrote: Okay, but just to be aware, the semantic checker may then allow for a |