View unanswered posts | View active topics It is currently Fri Aug 22, 2014 8:04 am






Reply to topic  [ 4 posts ] 
PlayTone with variable arguments? 
Author Message
Rookie

Joined: Mon Oct 08, 2007 9:21 pm
Posts: 1
Post PlayTone with variable arguments?
Hello, I'm trying to play various tones determined by the sensors, and I'm getting an error when I try to use a variable with PlayTone.
Does anyone have any advice? Thanks

Code:
task main(){
   int frequency = 440;
   PlayTone(frequency, 10);   //**Error**:Undefined   expression in   code generation
  //PlayTone(440, 10);  // constant value works fine
  wait1Msec(1000);
}


Mon Oct 08, 2007 9:26 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
Hmm this is strange, it looks like it is a bug. Please post this in the bug tracking section

http://www-education.rec.ri.cmu.edu/mantis

Also another piece of advice, I would not use Frequency as a variable because RobotC sees it as a keyword and not a variable, and it puts it in blue text.

Thanks for the notice B-)
Scott

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Wed Oct 10, 2007 11:47 pm
Profile WWW
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
Quoe:
"Also another piece of advice, I would not use Frequency as a variable because RobotC sees it as a keyword and not a variable, and it puts it in blue text. "

It's OK to use it as a variable. 'frequency' is used as a parameter in one of the built-in intrinsic functions so that is why it is put in blue color.

But in this case frequency is defined as a local variable. This works fine.

The problem is that the syntax "colorizer" does not have full knowledge of all the scope rules for variables and makes intelligent guesses on keyword/variable colorizing. In this case it "guessed" wrong. I've done a minor tweak to improve this.


Sat Oct 13, 2007 1:06 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
starwarslegokid wrote:
Hmm this is strange, it looks like it is a bug. Please post this in the bug tracking section

This is a bug that has been fixed in a pre-release version that is not publicly available. It had to do with compatibility with the legacy RCX which originally did not have an opcode to except run-time frequencies.

If you send me an email to dickswan@sbcglobal.net I will provide you with a link to site where you can download this pre-release. Or you can wait a few days and it will be available on robotc.net.


Sat Oct 13, 2007 1:33 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.