[Csnd] Using macros in strings
| Date | 2024-06-14 09:18 |
| From | "Jeanette C." |
| Subject | [Csnd] Using macros in strings |
Hey hey,
is there a way to use a macro inside a double quoted string, something like:
Sname = "$PREFIXsuffix"
or
#include "$MYDIR/subfolder/file.inc"
Admittedly, the first case can be achieved with string functions and a global
string, but the latter can't.
Best wishes,
Jeanette
--
* Website: http://juliencoder.de - for summer is a state of sound
* Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
* Audiobombs: https://www.audiobombs.com/users/jeanette_c
* GitHub: https://github.com/jeanette-c
... About some useless information,
Supposed to fire my imagination <3
(Britney Spears)
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |
| Date | 2024-06-14 11:24 |
| From | Kevin Welsh |
| Subject | Re: [Csnd] Using macros in strings |
Hey Jeanette! It has been a while and I'm rather out of practice... but I used macros a lot when I was working with csound/cabbage more regularly. According to the score macro manual page, https://csound.com/docs/manual/ScoreMacros.html : $NAME. -- calls a defined macro. To use a macro, the name is used following a $ character. The name is terminated by the first character which is neither a letter nor a number. If it is necessary for the name to be immediately followed by a leter or digit, a period, which will be ignored, can be used to terminate the name. So in your case that might look like: #include "$MYDIR./subfolder/file.inc" Hopefully that helps! On Fri, Jun 14, 2024 at 4:18 AM Jeanette C. |
| Date | 2024-06-14 11:41 |
| From | "Jeanette C." |
| Subject | Re: [Csnd] Using macros in strings |
Hi Kevin,
Jun 14 2024, Kevin Welsh has written:
...
> So in your case that might look like: #include "$MYDIR./subfolder/file.inc"
...
Thanks Kevin. I was aware of the basic syntax and even the dot operator,
which I SHOULD have mentioned. It appears that macro substitution simply
does not work in strings:
#define MYDIR #csound/udos/#
#include "$MYDIR.opcode.udo"
Will output the error message:
Cannot open #include'd file $MYDIR.opcode.udo
I think I'm stuck with external means to adapt such things.
Best wishes and thanks,
Jeanette
--
* Website: http://juliencoder.de - for summer is a state of sound
* Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
* Audiobombs: https://www.audiobombs.com/users/jeanette_c
* GitHub: https://github.com/jeanette-c
Don't, don't let me be the last to know
Don't hold back, just let it go <3
(Britney Spears)
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |
| Date | 2024-06-14 12:02 |
| From | Richard Knight |
| Subject | Re: [Csnd] Using macros in strings |
Hi
#include isn't subject to macro expansion- but #includestr is, maybe
that will do what you want.
best,
Richard
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |
| Date | 2024-06-14 12:03 |
| From | Kevin Welsh |
| Subject | Re: [Csnd] Using macros in strings |
Strange, I could have sworn it was that simple. I'll poke around a little in my old code repository on github, because I seem to recall having the exact same problem... once upon a time. On Fri, Jun 14, 2024 at 6:41 AM Jeanette C. |
| Date | 2024-06-14 12:35 |
| From | "Jeanette C." |
| Subject | Re: [Csnd] Using macros in strings |
Hi richard,
thanks, #includestr does the trick perfectly!
Best wishes,
Jeanette
--
* Website: http://juliencoder.de - for summer is a state of sound
* Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
* Audiobombs: https://www.audiobombs.com/users/jeanette_c
* GitHub: https://github.com/jeanette-c
Don't, don't let me be the last to know
Don't hold back, just let it go <3
(Britney Spears)
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here |
| Date | 2024-06-14 14:53 |
| From | Steven Yi |
| Subject | Re: [Csnd] Using macros in strings |
FWIW I'd suggest setting the INCDIR environment variable rather than try to do this with a macro. On Fri, Jun 14, 2024 at 7:35 AM Jeanette C. |