| Author |
Message |
christorb
Joined: Feb 09, 2010 Posts: 17 Location: Cambridge, UK
|
Posted: Tue Feb 09, 2010 6:09 am Post subject:
syntax error??! |
 |
|
Hi all, I'm just getting started with ChucK as an audio and technology student at uni. I've been using miniAudicle but I've run into a problem...
I'm literally going through the online tutorial and typing in the code, however when I try to run the patch I'm being told that there's a syntax error on line 2 char 1. As far as I can tell there's nothing wrong with it.
All I'm trying to run is this piece of simplicity:
1. SinOsc s => dac
2. while( true )
3. {
4. 2::second => now;
5. }
Whenever I run the examples that came with miniAudicle they work without a hitch, so I really don't understand what the problem is! In fact, whenever I use the line 'while( true )' in any patch I'm writing myself I get a syntax error from it, but like I said, if I've loaded up an example with that line in it it just seems to work!! Am I missing something obvious here?
Cheers guys,
Chris |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 5457 Location: San Antonio, Tx, USA
Audio files: 236
|
Posted: Tue Feb 09, 2010 6:33 am Post subject:
|
 |
|
Hi and welcome to the forum. You need a semicolon at the end of line 1. The console window will report the following line number when you leave out a semicolon for some reason, and this is common to every semicolon-deliniated language that I have ever programmed.
Don't feel foolish, I'm a fairly experienced programmer and have been coding ChucK for over two years, yet I occasionally make this same mistake!
Les _________________ No matter how much society beats it out of me, I STILL want to make the world a better place. I am sick of the abuse yet I am powerless to stop it. |
|
|
Back to top
|
|
 |
christorb
Joined: Feb 09, 2010 Posts: 17 Location: Cambridge, UK
|
Posted: Tue Feb 09, 2010 6:49 am Post subject:
|
 |
|
Ah, that was exactly it! Thanks for the reply - though I feel kind of stupid now :S!! I got so hung up on the second line that I wasn't paying attention to anything else!
Many thanks again, now onwards with ChucK  |
|
|
Back to top
|
|
 |
Blue Hell
Site Admin

Joined: Apr 03, 2004 Posts: 18181 Location: Netherlands, Enschede
Audio files: 95
G2 patch files: 310
|
Posted: Tue Feb 09, 2010 1:30 pm Post subject:
|
 |
|
| Inventor wrote: | | The console window will report the following line number when you leave out a semicolon for some reason |
No ... but the compiler will report on the first occasion that it can actually detect the error .. for instance try what happens if you put two statements on the same line forgetting the semicolon in between ... white space usually is allowed before the semicolon, so the line end is not an error ... that would be the reason. _________________ Jan |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7682 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sat Feb 13, 2010 10:16 am Post subject:
|
 |
|
Indeed. And this is good as it can be useful to break up statements in code over several lines. This is a good idea for long statements that contain several more or less independent parts, for example more complicated "if" statements. Like this;
| Code: | if (foo == bar &&
baz < 10 &&
now > last_time)
{
do.stuff()
more.stuff()
} |
So, yes; strictly speaking the error *is* in the second line from the perspective of the parser as the second line doesn't relate to the first in the expected way.
At first this stuff might look more confusing that it really is and you'll get the hang of it. When using brackets and missing one the error can be reported as being quite a few lines away from where you needed the bracket to be. This takes a bit of experience to get used to. _________________ Kassen |
|
|
Back to top
|
|
 |
|