[Csnd] writing a format string with fprints
Date | 2010-03-21 17:41 |
From | joachim heintz |
Subject | [Csnd] writing a format string with fprints |
Hi all - I want to write a string to a file with fprints, and this string contains a format string, for instance: fprints "/Users/jh/Desktop/fprints.txt", {{Soutnam sprintf "%s_ %d.wav", Sfile, ichn}} This results in a bus error, because of the "%s" and "%d". I tried masking it with "\%d" or "%%d", but this does not work. Can Csound write to a file, so that the file has the line Soutnam sprintf "%s_%d.wav", Sfile, ichn ? Thanks for any help - joachim Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-03-21 18:31 |
From | Jacob Joaquin |
Subject | [Csnd] Re: writing a format string with fprints |
From what I gather, there are two problems with fprints. First, it can't print "%" by itself. For example: fprints "./string_fprint.txt", "%" The other problem is that it doesn't seem to support strings: fprints "./string_fprint.txt", "%s", "Foo" However, %d doesn't seem to be causing any problems: fprints "./string_fprint.txt", "%d", 7897 ; this works Best, Jake -- The Csound Blog - http://csound.noisepages.com/ On Sun, Mar 21, 2010 at 10:41 AM, joachim heintz |
Date | 2010-03-21 18:44 |
From | joachim heintz |
Subject | [Csnd] Re: Re: writing a format string with fprints |
Yes, fprints (like prints) doesn't support the %s modifier. But you can do this in that way: Sfoo sprintf "%s", "foo" fprints "./string_fprint.txt", Sfoo Or even in this way: Sfoo1 sprintf "%s", {{"foo"}} fprints "./string_fprint.txt", Sfoo1 But my case is different. I don't want to resolve a format string before writing to file with fprints (like in your example), but I do want to write the format string itself to a file (because I want to execute the file later, and then resolving the format string with different arguments). So in fact I need to write "%" itself, but Csound doesn't let me do so :( Perhaps with the Python opcodes? I don't know them good enough. joachim Am 21.03.2010 um 19:31 schrieb Jacob Joaquin: > From what I gather, there are two problems with fprints. First, it > can't print "%" by itself. For example: > > fprints "./string_fprint.txt", "%" > > The other problem is that it doesn't seem to support strings: > > fprints "./string_fprint.txt", "%s", "Foo" > > However, %d doesn't seem to be causing any problems: > > fprints "./string_fprint.txt", "%d", 7897 ; this works > > Best, > Jake > -- > The Csound Blog - http://csound.noisepages.com/ > > > > On Sun, Mar 21, 2010 at 10:41 AM, joachim heintz > |
Date | 2010-03-21 18:55 |
From | Jacob Joaquin |
Subject | [Csnd] Re: Re: Re: writing a format string with fprints |
Originally, I thought I'd be able to trick it with: fprints "./string_fprint.txt", "%s", "%" Looking at the manual, it says %c works with ascii codes. But guess which one doesn't work? 37. And 37 == %. fprint really doesn't like %. There's some wonky design issues with fprints. For example, one has to write out %! for a semi-colon, because back in 1997, the semi-colon was interpreted has a comment. However, the problem should have been fixed in the parser, not the opcode. Best, Jake -- The Csound Blog - http://csound.noisepages.com/ On Sun, Mar 21, 2010 at 11:44 AM, joachim heintz |
Date | 2010-03-21 18:57 |
From | Martin Peach |
Subject | [Csnd] Re: Re: Re: writing a format string with fprints |
joachim heintz wrote: > So in fact I need to write "%" itself, but Csound doesn't let me do so :( Usually printf-type functions will print '\%' as '%'. Martin Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-03-21 19:00 |
From | Jacob Joaquin |
Subject | [Csnd] Re: Re: Re: Re: writing a format string with fprints |
> Usually printf-type functions will print '\%' as '%'. I've been playing with fprint for nearly an hour. I've come to the conclusion that fprint is anything but standard-c printf() compliant. :( Best, Jake |
Date | 2010-03-21 19:01 |
From | joachim heintz |
Subject | [Csnd] Re: Re: Re: Re: writing a format string with fprints |
yes, but fprints does not ... did you try? Am 21.03.2010 um 19:57 schrieb Martin Peach: > joachim heintz wrote: > >> So in fact I need to write "%" itself, but Csound doesn't let me do >> so :( > > Usually printf-type functions will print '\%' as '%'. > > Martin > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2010-03-21 20:02 |
From | Martin Peach |
Subject | [Csnd] Re: Re: Re: Re: Re: writing a format string with fprints |
joachim heintz wrote: > yes, but fprints does not ... did you try? > No, I just assumed it was like fprintf, but looking at the source code I see it's not the same at all. I should just shut up ;) Martin > > Am 21.03.2010 um 19:57 schrieb Martin Peach: > >> joachim heintz wrote: >> >>> So in fact I need to write "%" itself, but Csound doesn't let me do >>> so :( >> >> Usually printf-type functions will print '\%' as '%'. >> >> Martin >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email sympa@lists.bath.ac.uk with body >> "unsubscribe csound" >> >> > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe > csound" > > > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |