Loops with goto not working
Date | 2017-02-05 07:53 |
From | Emmett Palaima |
Subject | Loops with goto not working |
Hi, I'm working on a project where Csound is sending out serial messages to an Arduino. I would like Csound to wait for a response from the controller when it sends out a message, as a sort of handshake in order to ensure everything is received correctly.
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
I am doing this with a goto statement: loop1A: kbyte serialRead iPort kcount = kcount + 1 if (kbyte != iknob) goto loop1A prints "Byte: %d Count: %d\n\n", kbyte, kcount This outputs "Byte: 0 Count: 0", when iknob = 1, showing that the loop never actually happens. Why is this? I have tried setting ksmps to 1 so that the conditional is checked on every sample, but the result is the same. Thanks, Emmett |
Date | 2017-02-05 08:10 |
From | "Jeanette C." |
Subject | Re: Loops with goto not working |
Feb 5 2017, Emmett Palaima has written: ... > I am doing this with a goto statement: Have you tried using kgoto? Your if-statement contains both a k-rate and an i-rate variable, that might confuse the issue, since goto is a "...combination of igoto and kgoto". ... > if (kbyte != iknob) goto loop1A ... Best wishes, Jeanette -------- When you need someone, you just turn around and I will be there <3 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 | 2017-02-05 08:33 |
From | Emmett Palaima |
Subject | Re: Loops with goto not working |
I tried kgoto originally. I switched to goto since kgoto wasn't working and it said goto runs at every pass. On Sun, Feb 5, 2017 at 3:10 AM, Jeanette C. <julien@mail.upb.de> wrote: Feb 5 2017, Emmett Palaima has written: |
Date | 2017-02-05 09:14 |
From | "Jeanette C." |
Subject | Re: Loops with goto not working |
Feb 5 2017, Emmett Palaima has written: > I tried kgoto originally. I switched to goto since kgoto wasn't working and > it said goto runs at every pass. Hm, that sounds like the problem right there. kgoto should work at every k-rate pass. Since kgoto does not work, I suppose that goto will also fail at kgoto and must use the igoto part. But I have no idea why it doesn't work. I looked at similar statements in some of my own code, if-statement with comparison of k-rate variables with constants. Maybe, you could try changing the i-rate variable to a k-rate variable using init? ... Best wishes, Jeanette -------- When you need someone, you just turn around and I will be there <3 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 | 2017-02-05 09:36 |
From | Emmett Palaima |
Subject | Re: Loops with goto not working |
Tried it with kgoto, and making the constant a k-rate with init. Result is the same. This is especially weird, since kcount being equal to zero suggests the code inside the loop is never being run at all. On Sun, Feb 5, 2017 at 4:14 AM, Jeanette C. <julien@mail.upb.de> wrote: Feb 5 2017, Emmett Palaima has written: |
Date | 2017-02-05 09:52 |
From | Victor Lazzarini |
Subject | Re: Loops with goto not working |
prints would only run at init time. Try printf or printks.
Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland
|