Expressions and GetVar Codes

In APL, expressions are evaluated based on a stack-based pseudo-machine that processes its internal operations in double precision (64-bit / C Double) floating-point numbers. The opcodes that apply to this pseudo-machine, as well as opcodes that can be used individually to specify data elements, are collectively called GetVar codes. The GetVar codes are described in the following table.

GetVar Code Description
GETVAR_END (0) Control. Marks the end of a GetVar expression. The value of the expression is the value at the top of the stack.
GETVAR_EXPRESSION (1) Control. Marks the beginning of an expression that is expressed with multiple GetVar codes. GetVar codes, until the next GETVAR_END, are part of the expression.
GETVAR_I8 (2) Operand. Next byte is an 8-bit signed integer constant.
GETVAR_I16 (3) Operand. Next 2 bytes are a 16-bit signed integer constant.
GETVAR_I32 (4) Operand. Next 4 bytes are a 32-bit signed integer constant.
GETVAR_FPVAL (5) Operand. Next 8 bytes are a double precision floating-point constant.
GETVAR_APL_VAR (7) Operand. Next 4 bytes are 32-bit offset of an APL user variable.
GETVAR_FS_VAR (8) Operand. Next 2 bytes are 16-bit token number of a Flight Simulator variable. See the table at the end of this topic for token number values for Flight Simulator variables.
GETVAR_PLUS (9) Binary operator. Pop two values from the stack and push the sum.
GETVAR_MINUS (10) Binary operator. Pop A from stack. Pop B from stack. Push B–A.
GETVAR_TIMES (11) Binary operator. Pop two values from stack and push the product.
GETVAR_DIVIDE (12) Binary operator. Pop A from stack. Pop B from stack. Push B/A.
GETVAR_IDIV (13) Binary operator. Pop A from stack. Pop B from stack. Push int(int(B)/int(A)).
GETVAR_IREM (14) Binary operator. Pop A from stack. Pop B from stack. Push B MOD A.
GETVAR_BITWISE_AND (15) Binary operator. Pop two values from stack and push the bitwise And.
GETVAR_BITWISE_OR (16) Binary operator. Pop two values from stack and push the bitwise Or.
GETVAR_BITWISE_XOR (17) Binary operator. Pop two values from stack and push the bitwise exclusive Or.
GETVAR_EQ (18) Binary operator. Pop A from stack. Pop B from stack. If A=B push 1, else 0.
GETVAR_NE (19) Binary operator. Pop A from stack. Pop B from stack. If A is not equal to B push 1, else 0.
GETVAR_LT (20) Binary operator. Pop A from stack. Pop B from stack. If B is less than A push 1, else 0.
GETVAR_LE (21) Binary operator. Pop A from stack. Pop B from stack. If B is less than or equal t A push 1, else 0.
GETVAR_GT (22) Binary operator. Pop A from stack. Pop B from stack. If B is greater than A push 1, else 0.
GETVAR_GE (23) Binary operator. Pop A from stack. Pop B from stack. If B is greater than or equal to A push 1, else 0.
GETVAR_LOGICAL_AND (24) Binary operator. Pop two values from stack. If both values are nonzero, push 1, else 0.
GETVAR_LOGICAL_OR (25) Pop two values from stack. If either value is nonzero, push 1, else 0.
GETVAR_LOGICAL_NOT (26) Unary operator. Pop a value from stack. If the value is 0, push 1, else 0.
GETVAR_NEGATE (27) Unary operator. Pop A from stack. Push 0–A.
GETVAR_INT (28) Function. Pop A from stack. Push Int(A).
GETVAR_FRAC (29) Function. Pop A from stack. Push Fract(A) (A - Int(A)).
GETVAR_INRANGE (30) Function. Pop C, B, A from stack. If A is less than or equal to both B and C, push 1, else 0.
GETVAR_FTOM (31) Function. Pop alt in feet, push alt in meters.
GETVAR_MTOF (32) Function. Pop alt in meters, push alt in feet.
GETVAR_FTOC (33) Function. Pop temp in degrees Fahrenheit, push temp in degrees Celsius.
GETVAR_CTOF (34) Function. Pop temp in degrees Celsius, push temp in degrees Fahrenheit.
GETVAR_MBTOINHG (35) Function. Pop press in millibars, push press in inches of mercury.
GETVAR_INHGTOMB (36) Function. Pop press in inches of mercury, push press in millibars.
GETVAR_KMTONM (37) Function. Pop dist in kilometers, push dist in nmiles.
GETVAR_NMTOKM (38) Function. Pop dist in nmiles, push dist in kilometers.
GETVAR_NMTOSM (39) Function. Pop dist in nmiles, push dist in statute miles.
GETVAR_SMTONM (40) Function. Pop dist in statute miles, push dist in nmiles.
GETVAR_GROUND_ DIST (41) Function. Pop lon, lat, push ground (2-D) distance from plane to lat, lon in nmiles.
GETVAR_AIR_DIST (42) Function. Pop lon, lat, push air (3-D) distance from plane to lat, lon in nmiles.
GETVAR_RADIAL (43) Function. Pop lon, lat, push angle from lat, lon to plane in the horizontal plane in degrees magnetic.
GETVAR_GLIDE_SLOPE (44) Function. Pop lon, lat, push glideslope to lat, lon in degrees.
GETVAR_DEGREES (45) Function. Pop angle, push degrees.
GETVAR_MINUTES (46) Function. Pop angle, push minutes.
GETVAR_SECONDS (47) Function. Pop angle, push seconds.
GETVAR FTF DIST (48) Function. Pop lon2, lat2, lon1, lat1. Push distance in nmiles.
GETVAR INRANGE360 (49) Function. Pop C, B, A. If the angle A is between the angles B and C, push 1 else push 0.

The following table includes Flight Simulator variables and their respective token number values.

Variable Token number value
COM_FREQ 0
NAV1_FREQ 1
VOR_1_DME 2
VOR_1_OBS 3
NAV2_FREQ 4
VOR_2_DME 5
VOR_2_OBS 6
ADF_FREQ 7
TRANS_FREQ 8
OMARK 9
MMARK 10
IMARK 11
KEY 12
RANDOM 13
PLANE_LAT 14
PLANE_LON 15
PLANE_ALT 16
PLANE_PITCH 17
PLANE_BANK 18
PLANE_HEADING 19
SEASON 20
HOUR 21
MINUTE 22
SECOND 23
VOR_1_ACTIVE 24
VOR_1_LAT 25
VOR_1_LON 26
VOR_1_ALT 27
VOR_1_RADIAL 28
VOR_1_DME_AVAIL 29
VOR_1_LOCALIZER_AVAIL 30
VOR_1_GS_AVAIL 31
VOR_1_LOCALIZER 32
VOR_1_GLIDESLOPE 33
VOR_2_ACTIVE 34
VOR_2_LAT 35
VOR_2_LON 36
VOR_2_ALT 37
VOR_2_RADIAL 38
VOR_2_DME_AVAIL 39
ADF_ACTIVE 40
ADF_LAT 41
ADF_LON 42
ADF_ALT 43
ADF_RADIAL 44
CLOUD_LOW_ACTIVE 45
CLOUD_LOW_BASE 46
CLOUD_LOW_TOP 47
CLOUD_LOW_COVERAGE 48
CLOUD_LOW_TYPE 49
CLOUD_LOW_TURB 50
CLOUD_HIGH_ACTIVE 51
CLOUD_HIGH_BASE 52
CLOUD_HIGH_TOP 53
CLOUD_HIGH_COVERAGE 54
CLOUD_HIGH_TYPE 55
CLOUD_HIGH_TURB 56
CLOUD_THUNDER_ACTIVE 57
CLOUD_THUNDER_BASE 58
CLOUD_THUNDER_TOP 59
CLOUD_THUNDER_
COVERAGE 60
CLOUD_THUNDER_TYPE 61
CLOUD_THUNDER_TURB 62
WIND_SURF_DEPTH 63
WIND_SURF_VEL 64
WIND_SURF_DIR 65
WIND_SURF_TURB 66
WIND_SURF_TYPE 67
WIND_LOW_BOT 68
WIND_LOW_TOP 69
WIND_LOW_VEL 70
WIND_LOW_DIR 71
WIND_LOW_TURB 72
WIND_LOW_TYPE 73
WIND_MID_BOT 74
WIND_MID_TOP 75
WIND_MID_VEL 76
WIND_MID_DIR 77
WIND_MID_TURB 78
WIND_MID_TYPE 79
WIND_UP_BOT 80
WIND_UP_TOP 81
WIND_UP_VEL 82
WIND_UP_DIR 83
WIND_UP_TURB 84
WIND_UP_TYPE 85
TEMPERATURE_SURFACE_
ALT 86
TEMPERATURE_SURFACE_
TEMP 87
TEMPERATURE_LOW_ALT 88
TEMPERATURE_LOW_TEMP 89
TEMPERATURE_MID_ALT 90
TEMPERATURE_MID_TEMP 91
TEMPERATURE_HIGH_ALT 92
TEMPERATURE_HIGH_TEMP 93
BAROMETRIC_PRESSURE 94
BAROMETRIC_DRIFT 95
SLEW_SYSTEM_ACTIVE 96
STALL_WARNING 97
OVERSPEED_WARNING 98
PARKING_BRAKES 99
FLAPS_LEFT_POSITION 100
FLAPS_RIGHT_POSITION 101
YOKE_X_POSITION 102
YOKE_Y_POSITION 103
RUDDER_PEDAL_POSITION 104
ELEVATOR_TRIM_POSITION 105
BRAKE_LEFT_POSITION 106
BRAKE_RIGHT_POSITION 107
GEAR_1_POSITION 108
GEAR_2_POSITION 109
GEAR_3_POSITION 110
LEFT_MAIN_FUEL_LEVEL 111
RIGHT_MAIN_FUEL_LEVEL 112
LEFT_AUX_FUEL_LEVEL 113
RIGHT_AUX_FUEL_LEVEL 114
GROUND_ALTITUDE 115
VELOCITY_Y 116
VELOCITY 117
VELOCITY_INDICATED 118
MAGVAR 119
COURSE 120
AUTOPILOT_MASTER 121
AUTOPILOT_HEADING_
HOLD 122
AUTOPILOT_HEADING 123
AUTOPILOT_ALTITUDE_
HOLD 124
AUTOPILOT_ALTITUDE 125
AUTOPILOT_WING_
LEVELER 126
AUTOPILOT_ATTITUDE_
HOLD 127
AUTOPILOT_APPROACH_
HOLD 128
AUTOPILOT_NAV_HOLD 129
AUTOPILOT_LOCALIZER_
HOLD 130
AUTOPILOT_BACK_
COURSE_HOLD 131
EMERGENCY_FAILURE 132
RETRACTABLE_GEAR 133
ENGINE_TYPE 134
SMOKE_SYSTEM_ON 135
CLOUD_LOW_ICING 136
CLOUD_HIGH_ICING 137
CLOUD_THUNDER_ICING 138
ON_GROUND 139
AIRSPEED_INDICATOR_FAIL 140
AIRSPEED_INDICATOR_TAS 141
ALTIMETER_FAIL 142
ANGLE_OF_ATTACK 143
ATTITUDE_INDICATOR_FAIL 144
AUTO_COORDINATION 145
FLAPS_CONTROL 146
G_LOAD 147
GEAR_FAIL 148
GEAR_CONTROL 151
HEADING_INDICATOR_FAIL 152
PANEL_LIGHTS 153
PANEL_LIGHTS_FAIL 154
STROBES 155
STROBES_FAIL 156
TURN_COORDINATOR_FAIL 157
TURN_COORDINATOR_BALL 158
VERTICAL_SPEED_FAIL 159
VOR_1_COURSE_
DEVIATION 160
VOR_1_GS_DEVIATION 161
VOR_2_COURSE_
DEVIATION 162
APL_SOUND 163
APL_MESSAGES 164
INSTRUCTOR_CONTROL 165
THROTTLE_1 166
THROTTLE_2 167
THROTTLE_3 168
THROTTLE_4 169
ELAPSED_TIME 170
VOR_1_TO_FROM 171
VOR_2_TO_FROM 172
ADF_BEARING 173
ENGINE_CONTROL_SELECT 174
EVENT_COUNT 175