> For the complete documentation index, see [llms.txt](https://bob-mcd-team.gitbook.io/uefi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bob-mcd-team.gitbook.io/uefi/uefi-development/vfr/71.vfr-string-func.md).

# 71. 기본 VFR 내장 문자열용 함수

## stringref

\[<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.4.7-stringref>\\

<br>]\(<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.4.7-stringref&#xD;&#xA;&#xD;&#xA;>)`stringref` 를 이용하여 VFR code에 문자열 데이터를 가져올 수 있다.

```
EFI_IFR_STRING_REF1

Summary:
Push a string on the expression stack.

Prototype:

#define EFI_IFR_STRING_REF1_OP 0x4e

typedef struct _EFI_IFR_STRING_REF1 {
 EFI_IFR_OP_HEADER Header;
 EFI_STRING_ID StringId;
} EFI_IFR_STRING_REF1;

Members:
Header 		The byte sequence that defines the type of opcode as well as the length of the opcode being defined.
		Header.OpCode = EFI_IFR_STRING_REF1_OP.
StringId 	The string’s identifier, which must be unique within the package list.

Description:
Push the string specified by StringId on to the expression stack. If the string does not exist, then push an empty string.
```

아래 예시는 `suppressif` 를 이용한 조건문에서 문자열 요소에 특정 데이터가 있는 경우에만 TRUE(참) 이라는 의미이다.

```
string
  name = StringQuestion,
  ...
endstring;

suppressif questionref(StringQuestion) == stringref(STRING_TOKEN(TEST_STRING));
  ...
endif;
```

당연하게도 위 조건문 비교를 위해서는 새 토큰을 정의해야 한다.

```
#string TEST_STRING            #language en-US  "EDKII"
```

또 다른 `stringref` 의 예이다.

```
string
  varid = FormData.StringValue,
  prompt = STRING_TOKEN(STRING_PROMPT),
  help = STRING_TOKEN(STRING_HELP),
  minsize = 5,
  maxsize = 10,
  warningif
    prompt = STRING_TOKEN(WARNING_IF_PROMPT),
    pushthis == stringref(STRING_TOKEN(TEST_STRING))
  endif;
endstring;
```

이 코드에서는 입력 문자열이 "EDKII" 인 경우에만 경고 메세지를 출력한다.

## toupper/tolower

[https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2\_vfr\_description\_in\_bnf/212\_vfr\_expression\_statement\_definition#2.12.11.6.8-toupper](<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.8-toupper&#xD;&#xA;&#xD;&#xA;https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.9-tolower>)

[https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2\_vfr\_description\_in\_bnf/212\_vfr\_expression\_statement\_definition#2.12.11.6.9-tolower](<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.8-toupper&#xD;&#xA;&#xD;&#xA;https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.9-tolower>)

`toupper` 과 `tolower` 내장 함수는 각각 `EFI_IFR_TO_UPPER` (=0x21)과 `EFI_IFR_TO_LOWER` (=0x20) opcode로 인코딩되며, 문자열 데이터의 대/소문자 변경 기능을 수행할 수 있다.

예로 아래 코드는 "EDKII" 입력과 "Edkii", "EDkii", "EDKii", "eDKii" 등의 입력에 대해 경고 메세지를 출력한다.

```
string
  varid = FormData.StringValue,
  prompt = STRING_TOKEN(STRING_PROMPT),
  help = STRING_TOKEN(STRING_HELP),
  minsize = 5,
  maxsize = 10,
  warningif
    prompt = STRING_TOKEN(WARNING_IF_PROMPT),
    toupper(pushthis) == stringref(STRING_TOKEN(TEST_STRING))
  endif;
endstring;
```

반대로 "edkii"가 입력되었을 때만 경고 메세지를 출력한다.

```
string
  name = StringQuestion,
  varid = FormData.StringValue,
  prompt = STRING_TOKEN(STRING_PROMPT),
  help = STRING_TOKEN(STRING_HELP),
  minsize = 5,
  maxsize = 10,
  warningif
    prompt = STRING_TOKEN(WARNING_IF_PROMPT),
    pushthis == tolower(stringref(STRING_TOKEN(TEST_STRING)))
  endif;
endstring;
```

length[](<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.8-toupper&#xD;&#xA;&#xD;&#xA;https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.9-tolower>)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.1-length>

`length` 키워드로 버퍼 또는 문자열의 길이를 얻을 수 있다. `EFI_IFR_LENGTH_OP` (=0x56) opcode로 인코딩된다.

아래는 문자열 Question 데이터의 길이가 7일 경우에 `suppressif` 조건문이 TRUE가 되는 예이다.

```
suppressif length(questionref(StringQuestion)) == 7;
  ...
endif;
```

## 추가적인 내장 문자열용 함수

| keyword    | IFR opcode         | link                                                                                                                                        |
| ---------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `catenate` | `EFI_IFR_CATENATE` | <https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.1-catenate> |
| `match`    | `EFI_IFR_MATCH`    | <https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.2-match>    |
| `match2`   | `EFI_IFR_MATCH2`   | <https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.9-match2>   |
| `find`     | `EFI_IFR_FIND`     | <https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.7.2-find>   |
| `mid`      | `EFI_IFR_MID`      | <https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.7.3-mid>    |
| `token`    | `EFI_IFR_TOKEN`    | <https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.7.4-tok>    |
| `span`     | `EFI_IFR_SPAN`     | <https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.7.5-span>   |
