Quote:
|
Originally Posted by TEAM1949
Yeah got it.
But doesn't the EasyC won't allow to do that.
I mean let the 'd' to equale both things, but I'll try that today.
Tnx anyway.
|
Actually EasyC (which is just a specialized GUI for 'C') does allow it, because I copied it directly from our EasyC code. All programming languages (that I am aware of) allow this type of variable manipulation. You should keep in mind that while assignments may LOOK like algebra, they really aren't. So statements like d = d/45 are perfectly valid, because you are assigning to d the value of the expression d/45. Also another misconception you might have is that all of the lines of code are evaluated simultaneously, which is not correct. Programs are always executed line by line. Which means that
Code:
d = GetGTSensor ( GTS_DIG_IO ) ;
is executed first THEN:
Code:
d = d/ GEAR_COUNT_PER_INCH ;
is executed. d DOES NOT equal both simultaneously, but it does equal the last value assigned to it. If you are still uncomfortable with this, you can easily change it like this:
Code:
long temp_d;
temp_d = GetGTSensor ( GTS_DIG_IO ) ;
d = temp_d/ GEAR_COUNT_PER_INCH ;
OR you can simply put it in one line:
Code:
d = GetGTSensor ( GTS_DIG_IO )/ GEAR_COUNT_PER_INCH;
Every single one of those results in the same output
