This is a basic question, but I'm hoping someone can help decipher this line of code for me. I can't find a reference anywhere to what the period in this statement does. I assume by the setup that it is some sort of conditional, but would appreciate any further info. Is it Keil specific? Counter[CounterInstance].Output = FALSE
"In C, to access a member of a specific structure, you use a '.' and then the name of the member" Although they're called "records" rather than "structures" in Pascal, the notation is identical - so even a Pascal programmer should understand it!
We started with
Counter[CounterInstance].Output = FALSE
if( something == TRUE )
A comparison of 'C' and Pascal Syntax: http://www.cs.gordon.edu/courses/cs320/handouts/C_C++_Syntax_vs_Pascal.html Note that his comment, "0 = false and 1 = true" is not quite right - see above. Note also that it originated in 1989, so some of his reference to "modern", etc, are now a bit dated.
"if( something == TRUE ) is likely to give unexpected results..." Naturally 'C' provides some fun ways to get round this problem: #define TRUE 1 #define FALSE 0 if(something?1:0 == TRUE) { //Result as expected } or even better: if(!!something == TRUE) { //Result as expected }
Naturally 'C' provides some fun ways to get round this problem: You skipped the most important way: not to create the problem in the first place, so you don't have to work around it:
if(something)
Someone did indeed plunk a load of C source code and asked me to do some white box testing of some new revisions. I have much more experience with C++ and Assembly, but minimal C experience. Reading through Dietel and Dietel's "C-How to Program" obviously did not "teach" me the language as it should be taught (with examples, etc), as can be told by how I did not know the answer to this simple question. Thanks again, guys.
"I have much more experience with C++" But the '.', '=', and '==' operators in C++ are identical to those in 'C'!!
"But the '.', '=', and '==' operators in C++ are identical to those in 'C'!!" Ah, but if you didn't know 'C' you wouldn't know that...
"It's as simple and obvious as that." Sssh, don't tell everybody.
"It's as simple and obvious as that." and it works in C++ and Pascal, too!
and it works in C++ and Pascal, too! In C++, sure --- that's part of its C heritage. But, although it's been quite a while since last used any of it, I'm almost certain that Pascal won't accept an integer abused as a boolean, like we were discussing here --- it has to be a "real" Boolean expression there. But then, no dyed-in-the-wool Pascal programmer would ever commit such blasphemy anyway ;-), so it's a non-problem for them, too.
"I'm almost certain that Pascal won't accept an integer abused as a boolean" Quite so. "But then, no dyed-in-the-wool Pascal programmer would ever commit such blasphemy anyway" Of course not - that's why I didn't bother to even mention it... ;-)