electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time
<on air> faux pas quartet and friends Music From Last Thursday
Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
syntax error??!
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
christorb



Joined: Feb 09, 2010
Posts: 17
Location: Cambridge, UK

PostPosted: Tue Feb 09, 2010 6:09 am    Post subject: syntax error??! Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 5457
Location: San Antonio, Tx, USA
Audio files: 236

PostPosted: Tue Feb 09, 2010 6:33 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail
christorb



Joined: Feb 09, 2010
Posts: 17
Location: Cambridge, UK

PostPosted: Tue Feb 09, 2010 6:49 am    Post subject: Reply with quote  Mark this post and the followings unread

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 Smile
Back to top
View user's profile Send private message
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 18181
Location: Netherlands, Enschede
Audio files: 95
G2 patch files: 310

PostPosted: Tue Feb 09, 2010 1:30 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7682
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sat Feb 13, 2010 10:16 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Niio2

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use