ROBOTC.net forums
http://www.robotc.net/forums/

setFriendlyName("Name"); not working in RobotC 3.60
http://www.robotc.net/forums/viewtopic.php?f=1&t=5805
Page 1 of 1

Author:  DiMastero [ Thu May 02, 2013 5:45 pm ]
Post subject:  setFriendlyName("Name"); not working in RobotC 3.60

So yeah, post title says it all. This code doesn't compile:
Code:
void btLSetUp(bool masterOrSlave){ //true = master; false = slave
   setBluetoothOn();
   setBluetoothVisibility(true);
   if(masterOrSlave == true)
      setFriendlyName("Albert");
   else
      setFriendlyName("Jeeves");
}
I get this error for both times setFriendlyName is called:
Code:
**Error**:'const' expressions does not fit. Call to 'setFriendlyName'. Parameter: 'unsigned string & sFriendlyName' is '"Jeeves"' of type 'string'.
From the documentation, I don't see how I'm calling it wrong. Bug?

Thanks,
- Leon

Author:  mightor [ Fri May 03, 2013 1:33 am ]
Post subject:  Re: setFriendlyName("Name"); not working in RobotC 3.60

It has to do with pointers, I suspect. In any case, this bit of code works quite nicely:
Code:
void btLSetUp(bool isMaster){ //true = master; false = slave
  string name;
  setBluetoothOn();
  setBluetoothVisibility(true);
  name = (isMaster) ? "Albert" : "Jeeves";
  setFriendlyName(name);
}

task main()
{
  btLSetUp(true);
}


I've tested this with ROBOTC 3.60.

= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/