[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

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,
Score Macros :

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!

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

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
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

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.

Hi richard,
thanks, #includestr does the trick perfectly!

Best wishes,

Jeanette

FWIW I'd suggest setting the INCDIR environment variable rather than
try to do this with a macro.