July 11, 201015 yr Commercial Member Both of these return zero for me at all altitudes and speeds. I have to assume that I'm not seeing the wood for the trees - would someone be kind enough to point out my error? RANKINE_TO_CELSIUS does work, BTW. //**************************************************************************// Standard atmospheric temperature//**************************************************************************double getSAT(double temp){ double data=0; execute_calculator_code("(A:STANDARD ATM TEMPERATURE, rankine)",&data,NULL,NULL); return(RANKINE_TO_CELSIUS(data));}//---snip---//double temp=0;getSAT(temp);sprintf(pelement->string, "%30s%4.0f","Standard ATM temp (celsius) = ",temp);//**************************************************************************// Total air temperature - air temp at the front of the aircraft with ram pressure//**************************************************************************double getTAT(double temp){ double data=0; execute_calculator_code("(A:TOTAL AIR TEMPERATURE, celsius)",&data,NULL,NULL); return data;}//---snip---//double temp=0;getTAT(temp);sprintf(pelement->string, "%27s%4.0f","Total air temp (celsius) = ",temp); Many thanks.-Dai
July 11, 201015 yr Commercial Member SAT works, but I don't know if 'rankine' works since I obtain it as a celcius directly. TAT... I use the default token var TOTAL_AIR_TEMP and not an execute_calc call. Ed Wilson Mindstar AviationMy Playland - I69
July 11, 201015 yr Author Commercial Member Thanks Ed - now I have to find what I'm doing wrong! :( -Dai
July 11, 201015 yr Author Commercial Member Huh - these work. Go figure.... sprintf(pelement->string, "%27s%4.0f","Total air temp (celsius) = ",getTAT(temp));//sprintf(pelement->string, "%30s%4.0f","Standard ATM temp (celsius) = ",getSAT(temp)); -Dai
July 11, 201015 yr Commercial Member Out of curiosity... why are you doing this: sprintf(pelement->string, "%30s%4.0f","Standard ATM temp (celsius) = ",getSAT(temp)); instead of this: sprintf(pelement->string, "Standard ATM temp (celsius) = %4.0f",getSAT(temp)); It's less code execution to do the latter, fewer CPU cycles, etc. Also, why are you passing 'temp' as a variable that's unused in the function? Ed Wilson Mindstar AviationMy Playland - I69
July 12, 201015 yr Author Commercial Member Simple answer Ed - because I've never known any other way to do it. As for passing 'temp' - in the original code //**************************************************************************// Standard atmospheric temperature//**************************************************************************double getSAT(double temp){ double data=0; execute_calculator_code("(A:STANDARD ATM TEMPERATURE, rankine)",&data,NULL,NULL); return(RANKINE_TO_CELSIUS(data));}//---snip---//double temp=0;getSAT(temp);sprintf(pelement->string, "%30s%4.0f","Standard ATM temp (celsius) = ",temp); -if I didn't pass in a variable to contain the return, I got a compiler error. Maybe that changes with the way you're suggesting?-Dai
July 12, 201015 yr Commercial Member This should compile and work: double getSAT(){ double data=0; execute_calculator_code("(A:STANDARD ATM TEMPERATURE, celcius)",&data,NULL,NULL); return data;}double temp=0;temp = getSAT();sprintf(pelement->string, "Standard ATM temp (celsius) = %4.0f",temp); Ed Wilson Mindstar AviationMy Playland - I69
July 12, 201015 yr Author Commercial Member Which it does, of course! :( Thanks for the lesson Ed (stares dully at the lines and lines and lines of code that could be changed....).-Dai
July 12, 201015 yr Commercial Member This also should work: double getSAT(){ double data=0; execute_calculator_code("(A:STANDARD ATM TEMPERATURE, celcius)",&data,NULL,NULL); return data;}sprintf(pelement->string, "Standard ATM temp (celsius) = %4.0f",getSAT()); Ed Wilson Mindstar AviationMy Playland - I69
July 12, 201015 yr Author Commercial Member It does... ironically enough, I just stumbled across that by accident - a typo almost!-Dai
Create an account or sign in to comment