| Author |
Message |
|
oli_gould
Rookie
Joined: Tue Feb 26, 2008 4:41 pm Posts: 27
|
 Reading from boolean variables
I' ve noticed twice now that I'm unable to read boolean variables; It may be my code as I'm not experienced - or is it RobotC?
The code would be something like:
I know ofcourse I could use integers with 1 or 0 but sometimes it makes more sense to use booleans. Can anyone help please??
Thanks!
Oli
|
| Fri Mar 28, 2008 2:53 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
what about
if (Flag)
instead of
if (Flag== true)

_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Fri Mar 28, 2008 3:07 pm |
|
 |
|
oli_gould
Rookie
Joined: Tue Feb 26, 2008 4:41 pm Posts: 27
|
yep! thanks Ford. what if I want to use the false aspect? Would that be..
if (!Flag)
{
}
much appreciated
|
| Fri Mar 28, 2008 3:21 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
probably, yes.
But it's supposed to be a bug in RobotC, cause to standard C your code should work.
... developers... 
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Fri Mar 28, 2008 3:24 pm |
|
 |
|
oli_gould
Rookie
Joined: Tue Feb 26, 2008 4:41 pm Posts: 27
|
I just tested it for others' benefit and yes !Flag does work.
|
| Fri Mar 28, 2008 3:33 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
Fine !
Could you please report this bug to RobotC Bug Report?
http://www.education.rec.ri.cmu.edu/too ... n_page.php
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Tue Apr 01, 2008 11:14 am |
|
 |
|
giannisAPI
Rookie
Joined: Sun Mar 02, 2008 9:41 am Posts: 25
|
why dont you just use a define int variable instead of boolean?
|
| Sun Apr 13, 2008 8:13 pm |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
why shouldn't bool be used?
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Tue Apr 15, 2008 1:54 pm |
|
 |
|
giannisAPI
Rookie
Joined: Sun Mar 02, 2008 9:41 am Posts: 25
|
Traditional C language did not have a boolean data type..
But i dont see any reason why not to use it.. Probably in embedded systems applications (with memory constraints) is actually more sensible to use bool as they usually take less space in the memory (8 b) where int usually takes 16.
I was just saying that because u told something about a bug in RobotC thats why.
Regards,
giannis
|
| Wed Apr 16, 2008 9:41 am |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
OK, but
1) I didn't say that bool is ANSI, I just said that the code should work
2) if I wrote e.g.
(or however true and false may have been declared in RobotC) then
should work, or am I wrong?
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
Last edited by Ford Prefect on Wed Apr 16, 2008 3:10 pm, edited 1 time in total.
|
| Wed Apr 16, 2008 10:59 am |
|
 |
|
giannisAPI
Rookie
Joined: Sun Mar 02, 2008 9:41 am Posts: 25
|
|
| Wed Apr 16, 2008 11:16 am |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
hi,
as I meanwhile found out, even boolean variables are standard ANSI C (C99):
http://de.wikipedia.org/wiki/Varianten_der_Programmiersprache_C
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Sat Apr 26, 2008 4:35 am |
|
 |
|
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
|
@developers:
can you confirm this bug?
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
|
| Tue Apr 29, 2008 2:19 pm |
|
|