# 69. VFR의 조건부 키워드

이번 장에서는 여러 내장된 VFR 조건을 살펴보겠다.\
해당 새 키워드에 대해 자세히 알아보기 전에 양식을 한 번 더 살펴보겠다.

<figure><img src="/files/xJjSI8mz64A2gjoZDYV7" alt=""><figcaption></figcaption></figure>

이번 챕터에서 양식의 모양을 변경할 것이기 때문에 참조용으로 기억하는 것이 좋다.\
또한 챕터에서 사용되는 각 내장 함수는 조건문과 함께 작동한다. 그러나 우리는 요소가 어떻게 작동하는지 보여주고 싶기 때문에 조건문 대신 상수 `TRUE`를 사용할 것이다.

## suppressif

suppress 태그는 첫 번째 중첩 객체로 나타나는 표현식이 TRUE로 평가되는 경우 중첩 객체가 사용자에게 숨겨지도록 한다.

opcode는 아래와 같이 사용한다.

```
#define EFI_IFR_SUPPRESS_IF_OP 0x0a
```

VFR 토큰 정의는 아래의 링크에서 찾을 수 있다.\
(<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.7.3-vfr-statement-suppressif-definition>)

예를 들어 `orderedlist`를 억제해 보겠다.

```
suppressif TRUE;
    orderedlist
      ...
    endlist;
endif;
```

확인을 하면 아래와 같이 나타난다.

<figure><img src="/files/eyMROBIFib677uw4p4Gi" alt=""><figcaption></figcaption></figure>

요소는 단순히 사용자에게 보이지 않게 되었다.\
또 하나의 `suppressif` 사용은 질문 안에 옵션을 숨길 수 있다는 사실이 있다.\
예를 들면 현재 `oneof` 는 아래와 같다.

<figure><img src="/files/QOF2dgCByGKwcIDZEdqG" alt=""><figcaption></figcaption></figure>

하지만 `suppressif`를 옵션3에 추가해보자.

```
oneof
  varid = FormData.OneOfValue,
  prompt = STRING_TOKEN(ONEOF_PROMPT),
  help = STRING_TOKEN(ONEOF_HELP),
  option text = STRING_TOKEN(ONEOF_OPTION1), value = 0x00, flags = 0;
  option text = STRING_TOKEN(ONEOF_OPTION2), value = 0x33, flags = 0;
  suppressif TRUE;
  option text = STRING_TOKEN(ONEOF_OPTION3), value = 0x55, flags = 0;
  endif;
endoneof;
```

결과를 보면 아래와 같이 옵션이 사라지는 것을 볼 수 있다.

<figure><img src="/files/JzHfrIZBLfdIBqbwQn4l" alt=""><figcaption></figcaption></figure>

## grayoutif

첫 번째 중첩 개체로 나타나는 표현식이 TRUE로 평가되면 모든 중첩된 문장 또는 질문이 회색으로 표시된다(선택할  수 없고 시각적으로 구별된다).

opcode는 다음과 같다.

```
#define EFI_IFR_GRAY_OUT_IF_OP 0x19
```

VFR 토큰 정의는 아래의 링크에서 찾을 수 있다.\
<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.7.4-vfr-statement-grayoutif-definition>

예를 들어 orderedlist 요소를 회색으로 표시해보겠다.

```
grayoutif TRUE;
    orderedlist
      ...
    endlist;
endif;
```

결과적으로 요소는 아래와 같이 선택할 수 없다.

<figure><img src="/files/4AZpuBjKCK09rhzAVBMr" alt=""><figcaption></figcaption></figure>

## disableif

첫 번째 중첩 개체로 나타나는 표현식이 TRUE로 평가되면 모든 중첩된 문, 질문, 옵션 또는 표현식이 처리되지 않는다.

opcode는 다음과 같다.

```
#define EFI_IFR_DISABLE_IF_OP 0x1E
```

VFR 토큰 정의는 아래의 링크에서 찾을 수 있다.\
(<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.7.2-vfr-statement-disalbeif-definition>)

예시로 `orederedlist` 요소를 비활성화해 보겠다.

```
disableif TRUE;
    orderedlist
      ...
    endlist;
endif
```

이 조건에서 우리의 형태는 `suppressif` 예에서 단순히 요소가 뷰에 존재하지 않는 것처럼 보인다.

<figure><img src="/files/tEdZDGOvuNH5gVbXdZjz" alt=""><figcaption></figcaption></figure>

## warningif

질문에 대한 유효성 검사 표현식 및 경고 메시지를 생성한다.

opcode는 아래와 같다.

```
#define EFI_IFR_WARNING_IF_OP 0x63
```

VFR 토큰 정의는 다음의 링크에서 찾을 수 있다.\
(<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.6.1.7-vfr-question-tag-warningif-definition-vfrstatement>)

이번에는 `orderedlist`에 추가해 보겠다.

```
orderedlist
  varid = FormData.OrderedListValue,
  prompt = STRING_TOKEN(ORDERED_LIST_PROMPT),
  help = STRING_TOKEN(ORDERED_LIST_HELP),
  option text = STRING_TOKEN(ORDERED_LIST_OPTION1), value = 0x0A, flags = 0;
  option text = STRING_TOKEN(ORDERED_LIST_OPTION2), value = 0x0B, flags = 0;
  option text = STRING_TOKEN(ORDERED_LIST_OPTION3), value = 0x0C, flags = 0;
  warningif
    prompt = STRING_TOKEN(WARNING_IF_PROMPT),
    TRUE
  endif;
endlist;
```

`Strings.uni`에도 새 문자열을 추가하겠다.

```
#string WARNING_IF_PROMPT      #language en-US  "WarningIf prompt"
```

변수를 변경하고 `Enter` 키를 누르면 경고 메시지가 나타난다.

<figure><img src="/files/L8LTHYtYAiqs7JYkWRE9" alt=""><figcaption></figcaption></figure>

그러나 경고를 무시하고 `F10` 키를 눌러 업데이트된 데이터를 계속 저장할 수 있다는 점에 유의해야 한다.\
`warningif`를 사용하면 경고 메시지에 대한 시간 초과 값을 설정할 수 있다.

```
warningif
  prompt = STRING_TOKEN(WARNING_IF_PROMPT),
  timeout = 5,
  TRUE
endif;
```

해당 경우에 경고는 5초 후에 사라진다(또는 사용자가 키를 입력하는 경우 더 빨리 사라진다).

<figure><img src="/files/orH3FVTgRY2erWc9eysa" alt=""><figcaption></figcaption></figure>

## nosubmitif

양식이 제출될 때 평가될 조건식을 만든다. 조건이 TRUE로 평가되면 오류 메시지 Error가 사용자에게 표시되고 사용자는 양식을 제출할 수 없다.

opcode는 다음과 같다.

```
#define EFI_IFR_NO_SUBMIT_IF_OP 0x10
```

VFR 토큰 정의는 아래와 같다\
(<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.6.1.2-vfr-question-tag-nosubmitif-definition>).

이번에는 `orderedlist`에 추가해 보겠다.

```
orderedlist
  varid = FormData.OrderedListValue,
  prompt = STRING_TOKEN(ORDERED_LIST_PROMPT),
  help = STRING_TOKEN(ORDERED_LIST_HELP),
  option text = STRING_TOKEN(ORDERED_LIST_OPTION1), value = 0x0A, flags = 0;
  option text = STRING_TOKEN(ORDERED_LIST_OPTION2), value = 0x0B, flags = 0;
  option text = STRING_TOKEN(ORDERED_LIST_OPTION3), value = 0x0C, flags = 0;
  nosubmitif
    prompt = STRING_TOKEN(NOSUBMIT_IF_PROMPT),
    TRUE
  endif;
endlist;
```

Strings.uni에도 문자열을 추가하겠다.

```
#string NOSUBMIT_IF_PROMPT     #language en-US  "NoSubmitIf prompt"
```

이 코드를 사용하여 여전히 변수를 변경하고 `Enter` 키를 누르면 `Configuration changed` 메시지와 함께 업데이트된 값이 양식에 표시된다. 그러나 양식 제출(`F10`)은 실패된다. `nosubmitif` 조건이 TRUE로 평가되면 변수를 저장할 수 없다.

<figure><img src="/files/kpQZP8dLpuUkJ26R9d6Y" alt=""><figcaption></figcaption></figure>

## inconsistentif

VFR 토큰 정의는 아래와 같다\
(<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.6.1.1-vfr-question-tag-inconsistentif-definition>).

opcode는 다음과 같다.

```
#define EFI_IFR_INCONSISTENT_IF_OP 0x011
```

이번에는 `orderedlist`에 추가해 보겠다.

```
orderedlist
  varid = FormData.OrderedListValue,
  prompt = STRING_TOKEN(ORDERED_LIST_PROMPT),
  help = STRING_TOKEN(ORDERED_LIST_HELP),
  option text = STRING_TOKEN(ORDERED_LIST_OPTION1), value = 0x0A, flags = 0;
  option text = STRING_TOKEN(ORDERED_LIST_OPTION2), value = 0x0B, flags = 0;
  option text = STRING_TOKEN(ORDERED_LIST_OPTION3), value = 0x0C, flags = 0;
  inconsistentif
    prompt = STRING_TOKEN(INCONSISTENT_IF_PROMPT),
    TRUE
  endif;
endlist;
```

Strings.uni에 문자열을 추가하겠다.

```
#string INCONSISTENT_IF_PROMPT #language en-US  "InconsistentIf prompt"
```

이 코드는 inconsistentif가 TRUE로 평가될 때 변수를 값으로 변경할 수 없다. 양식은 단순히 팝업 메시지를 표시하고 값을 변경하지 않는다.

<figure><img src="/files/dPeu0ns3ts0HED9sk3yd" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bob-mcd-team.gitbook.io/uefi/uefi-development/vfr/69.vfr-if.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
