Date 1 - 2 of 2
Strange behaviour with VFR read and cond statements
|1 - 2 of 2|
Can someone explain what is wrong with this code?
The intention is this:
- if option3 is selected, numeric value is always equal 20 and user
can't change it
- if option1 or option2 is selected, user can change numeric value
But in fact I see the opposite behaviour:
- if option1 or option2 is selected, numeric value is 20 and it is not
possible to change it
- if option3 is selected user can change numeric value
varid = FormData.OneOfValue,
prompt = STRING_TOKEN(ONEOF_PROMPT),
help = STRING_TOKEN(ONEOF_HELP),
option text = STRING_TOKEN(ONEOF_OPTION1), value = 0x00, flags = DEFAULT;
option text = STRING_TOKEN(ONEOF_OPTION2), value = 0x33, flags = 0;
option text = STRING_TOKEN(ONEOF_OPTION3), value = 0x55, flags = 0;
varid = FormData.NumericValue,
prompt = STRING_TOKEN(NUMERIC_PROMPT),
help = STRING_TOKEN(NUMERIC_HELP),
flags = NUMERIC_SIZE_2,
minimum = 0x0,
maximum = 0xffff,
step = 1,
read cond((get(FormData.OneOfValue) == 0x55) ? 20 : pushthis);
What am I missing?
Ok, it looks like I've found the source of error.
According to the UEFI specification:
This opcode performs the following actions:
1. Pop three values from the expression stack. The first value popped
is the right value. The
second expression popped is the middle value. The last expression
popped is the left value.
2. If the left value cannot be evaluated as a boolean, push Undefined.
3. If the left expression evaluates to TRUE, push the right value.
4. Otherwise, push the middle value.
So "cond( A? B: C)" is not equal to "A? B: C" ternary operator in
standard programming languages, but it gives quite the opposite
behaviour "A? C: B"
Why is it done this way? It looks very misleading to me.
On Fri, Jul 1, 2022 at 6:12 PM Konstantin Aladyshev
|1 - 2 of 2|