RNP
void
alias event = (M:Event, string); alias rudderTrimtabPos = (L:RudderTrimtabPos, number); // Handle some events here. if event == 'LeftSingle' { (L:LastPos) = (M:X); } if event == 'WheelUp' { (K:RUDDER_TRIM_RIGHT) = 0; } if event == 'WheelDown' { (K:RUDDER_TRIM_LEFT) = 0; } if event == 'LeftDrag' { if ((M:X, number) - (L:LastPos, number)) > 5 { rudderTrimtabPos += 2; (L:LastPos) = (M:X); } if ((M:X, number) - (L:LastPos, number)) < -5 { rudderTrimtabPos -= 2; (L:LastPos) = (M:X); } } macro mapf($n, $inMin, $inMax, $outMin, $outMax) { ($n - $inMin) * ($outMax - $outMin) / ($inMax - $inMin) + $outMin } /* * A long paragraph explaining in great detail the exact * logic that is performed here. There are some edge cases * that Dave found in the 7th edition of the maintenance * manual that make this code way more complex. Thanks, Dave! */ let throttle = (A:GENERAL ENG THROTTLE LEVER POSITION:#ID#, percent); (L:MY_THROTTLE) = if throttle > 0 { mapf(throttle, 0, 100, 25, 100) } else { mapf(throttle, -20, 100, 0, 25) }; (L:Hello) = 'hello, world'.toUpperCase(); if #ID, number# == 1 { // #ID# is 1 } #MORE_LOGIC#;
RPN