[Csnd] #include with macros or strings
Date | 2018-06-06 08:32 |
From | 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE |
Subject | [Csnd] #include with macros or strings |
Dear List, Is there a way to use a macro or a string variable as part on an address of an #include statement? I have several files to include in an orchestra (all in the same directory) so I'd like to write the path of the directory only once. Something similar to this (does not work for me, at least on android): #define PATHH #/path/to/somewere# #include "$PATHH/file1.txt" #include "$PATHH/file2.txt" #include "$PATHH/file3.txt" Instead of (that works but require to change every single statement): #include "/path/to/somewere/file1.txt" #include "/path/to/somewere/file2.txt" #include "/path/to/somewere/file3.txt" Stefano |
Date | 2018-06-06 12:55 |
From | Dave Seidel |
Subject | Re: [Csnd] #include with macros or strings |
I would like this capability as well, In my case, I'd like to be able to define a macro on the command line (using --omacro) and then use the macro in an #include statement, so that I can have different runs use different include files based on the command line. On Wed, Jun 6, 2018 at 3:32 AM <00000008a49663bc-dmarc-request@listserv.heanet.ie> wrote:
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 | 2018-06-06 13:20 |
From | John ff |
Subject | Re: [Csnd] #include with macros or strings |
I will have to look closely at the code as macro expansion is delicate. Will look today.... Sent from TypeApp On Jun 6, 2018, 08:33, at 08:33, 00000008a49663bc-dmarc-request@listserv.heanet.ie wrote: >Dear List, > >Is there a way to use a macro or a string variable as part on an >address of an #include statement? > >I have several files to include in an orchestra (all in the same >directory) so I'd like to write the path of the directory only once. > >Something similar to this (does not work for me, at least on android): > >#define PATHH #/path/to/somewere# > >#include "$PATHH/file1.txt" > >#include "$PATHH/file2.txt" > >#include "$PATHH/file3.txt" > >Instead of (that works but require to change every single statement): > >#include "/path/to/somewere/file1.txt" > >#include "/path/to/somewere/file2.txt" > >#include "/path/to/somewere/file3.txt" > > >Stefano > >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 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 | 2018-06-06 15:23 |
From | jpff |
Subject | Re: [Csnd] #include with macros or strings |
Frst look says it ispossible but with a load a duplicated code. I will try to see if it can be mitigated. At present as the character surrounding the file name can be anything reading the string is not simple. I hope/expect there is a way to refactor but t will take a while. ==John ff On Wed, 6 Jun 2018, Dave Seidel wrote: > I would like this capability as well, In my case, I'd like to be able to > define a macro on the command line (using --omacro) and then use the macro in > an #include statement, so that I can have different runs use different include > files based on the command line. > > On Wed, Jun 6, 2018 at 3:32 AM > <00000008a49663bc-dmarc-request@listserv.heanet.ie> wrote: > > Dear List, > > Is there a way to use a macro or a string variable as part on an > address of an #include statement? > > I have several files to include in an orchestra (all in the same > directory) so I'd like to write the path of the directory only > once. > > Something similar to this (does not work for me, at least on > android): > > #define PATHH #/path/to/somewere# > > #include "$PATHH/file1.txt" > > #include "$PATHH/file2.txt" > > #include "$PATHH/file3.txt" > > Instead of (that works but require to change every single > statement): > > #include "/path/to/somewere/file1.txt" > > #include "/path/to/somewere/file2.txt" > > #include "/path/to/somewere/file3.txt" > > > Stefano > > 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 > > > > -- > http://mysterybear.nethttps://soundcloud.com/mysterybear > https://mysterybear.bandcamp.com > > http://recordings.irritablehedgehog.com/album/dave-seidel-60-hz > 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 > 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 | 2018-06-06 15:43 |
From | luis antunes pena |
Subject | Re: [Csnd] #include with macros or strings |
Would something like this be usefull for you using strings instead of macros? Sdir = "/path/to/something"Sfile1 = "file1" Sfile sprintf "%s/%s.txt", Sdir, Sfile1 Best, Luis Am 06.06.18 um 09:32 schrieb
00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE:
|
Date | 2018-06-06 16:46 |
From | thorin kerr |
Subject | Re: [Csnd] #include with macros or strings |
You could mimic #include with a UDO, which would let you use sprintf like Luis suggests to format the input argument. This seems to work.... although, you mentioned Android, and I don't think it will work in the Csound for Android app if that's what you're using. opcode includer, 0, S Sfile xin cigoto (filevalid(Sfile) == 0), NOTFOUND iline init 0 Sresult = "" while iline != -1 do Sline, iline readfi Sfile Sresult strcat Sresult, Sline od igoto EXITOPCODE NOTFOUND: prints "Could not read file\n" EXITOPCODE: ival evalstr Sresult endop - Thorin On Wed, Jun 6, 2018 at 10:43 AM, luis antunes pena <antunespena@web.de> wrote:
|
Date | 2018-06-06 17:20 |
From | jpff |
Subject | Re: [Csnd] #include with macros or strings |
No that would not work. Includinf of files is done lexically before and parsing of orc code and way before execution. On Wed, 6 Jun 2018, luis antunes pena wrote: > > Would something like this be usefull for you using strings instead of macros? > > Sdir = "/path/to/something" > Sfile1 = "file1" > Sfile sprintf "%s/%s.txt", Sdir, Sfile1 > > Best, > Luis > > Am 06.06.18 um 09:32 schrieb > 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE: > > Dear List, > > Is there a way to use a macro or a string variable as part on an > address of an #include statement? > > I have several files to include in an orchestra (all in the same > directory) so I'd like to write the path of the directory only > once. > > Something similar to this (does not work for me, at least on > android): > > #define PATHH #/path/to/somewere# > > #include "$PATHH/file1.txt" > > #include "$PATHH/file2.txt" > > #include "$PATHH/file3.txt" > > Instead of (that works but require to change every single > statement): > > #include "/path/to/somewere/file1.txt" > > #include "/path/to/somewere/file2.txt" > > #include "/path/to/somewere/file3.txt" > > > Stefano > > 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 > > > -- > http://luisantunespena.eu > http://sumtone.com > 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 > 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 | 2018-06-07 14:37 |
From | jpff |
Subject | Re: [Csnd] #include with macros or strings |
I have a simplified macro in include working, good enough for the example given. It only accepts macros without arguments and without trailing . (but I can easiy remove the latter restriction). Also only written for orc at present but easy to migrate to scores. The question is thus is this sufficient? Adding arguments would be a a lot of code and I am not realy confident about how it would work. Any thoughts welcome It would perhaps be easier if the syntax of iclude was changed so the file name must be in double quotes instead of the current any character. Does anyone use that facility? ==John ff On Wed, 6 Jun 2018, 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE wrote: > > Dear List, > > Is there a way to use a macro or a string variable as part on an address of an > #include statement? > > I have several files to include in an orchestra (all in the same directory) so > I'd like to write the path of the directory only once. > > Something similar to this (does not work for me, at least on android): > > #define PATHH #/path/to/somewere# > > #include "$PATHH/file1.txt" > > #include "$PATHH/file2.txt" > > #include "$PATHH/file3.txt" > > Instead of (that works but require to change every single statement): > > #include "/path/to/somewere/file1.txt" > > #include "/path/to/somewere/file2.txt" > > #include "/path/to/somewere/file3.txt" > > > Stefano > > 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 > 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 | 2018-06-07 15:16 |
From | Steven Yi |
Subject | Re: [Csnd] #include with macros or strings |
Rather than complicate things here, why not just set different INCDIR values? This seems equivalent to using different -I paths with gcc or other compilers. It already works and is rooted in a common practice and wouldn't require more code to maintain. On Thu, Jun 7, 2018 at 6:37 AM jpff <jpff@codemist.co.uk> wrote: I have a simplified macro in include working, good enough for the example |
Date | 2018-06-08 08:18 |
From | 00000008a49663bc-dmarc-request@LISTSERV.HEANET.IE |
Subject | Re: [Csnd] #include with macros or strings |
I only use double quotes, for me not having arguments is not a problem at the moment, don't know for others. Does this work also with -omacro flag? Anyway, thank you
|
Date | 2018-06-08 11:55 |
From | John ff |
Subject | Re: [Csnd] #include with macros or strings |
I should have added that it only works if the body of the macro is text, not macro calls. I have some other ideas to try to generalise.... Sent from TypeApp On Jun 8, 2018, 08:19, at 08:19, 00000008a49663bc-dmarc-request@listserv.heanet.ie wrote: >I only use double quotes, for me not having arguments is not a problem >at the moment, don't know for others. > >Does this work also with -omacro flag? > >Anyway, thank you > > >> Il 7 giugno 2018 alle 15.37 jpff |