# 시험법 계산식 if 문 사용법

## Q 문의&#x20;

* 계산식에 있는 함수 중에 if 문은 어떻게 쓰는지 방법을 알려주셨으면 합니다.

## A 답변&#x20;

### if 문 사용의 기본 모양

```csharp
if 조건1 then 
실행문1
실행문2
...
elseif 조건2 then
실행문
else // 조건1, 조건2 둘 다 아닐 때
실행문
end if
```

{% hint style="info" %}

* 실행문1, 실행문2처럼 줄을 바꾸어가며 여러 개의 실행문을 넣을 수 있습니다.&#x20;
* elseif의 경우 if문의 조건과 다른 조건을 적용할 때만 사용하시면 됩니다.&#x20;
* 또한, 여러 개의 조건이 필요할 때는 elseif 조건문을 추가하여 사용합니다.
  {% endhint %}

| 문법         | 설명                                                                                              |
| ---------- | ----------------------------------------------------------------------------------------------- |
| if 조건1     | 조건1에 해당되는 내용만 실행                                                                                |
| elseif 조건2 | if 조건1과 다른 조건을 실행해야 하는 경우 사용                                                                    |
| else       | <p>if조건1만 있는 경우 조건1을 제외한 모든 경우를 실행</p><p>if조건1 또는 elseif 조건2가 있는 경우 조건1, 조건2를 제외한 모든 경우를 실행</p> |
| end if     | 기본적인 문법으로 if문을 작성한 뒤에 반드시 end if를 기재합니다.                                                        |

{% tabs %}
{% tab title="예시1" %}
**V1** 변수 이름의 값이 10보다 크다면 최종 결괏값을 **V1**으로, 아니라면 최종 결괏값을 V2의 값으로 결괏값 적용&#x20;

{% code title="예시1" %}

```csharp
if V1 > 10 then
Result = V1
else
Result = V2
end if
```

{% endcode %}

{% hint style="info" %}
여기서 **Result**란 [검사결과등록3.0](https://help.ilabs.co.kr/05/3053) 화면의 시험결과 값을 의미합니다.
{% endhint %}
{% endtab %}

{% tab title="예시2" %}
**V1** 변숫값이 30 이상일 때 최종결과는 **V1**, 20 이상일 때는 **V2**, 10 이상일 때는 **V3**, 모두 아니라면 **V4** 값으로 결괏값 적용&#x20;

{% code title="예시2" %}

```csharp
if V1 >= 30 then 
Result = V1 
elseif V1 >= 20 then 
Result = V2 
elseif V1 >= 10 then 
Result = V3 
else 
Result = V4 
end if
```

{% endcode %}

{% hint style="info" %}
해당 예시는 `V1` 변수의 값이 입력될 경우 바로 계산이 진행되어 시험결과 값이 입력됩니다.
{% endhint %}
{% endtab %}
{% endtabs %}


---

# 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://help.ilabs.co.kr/faq/05/05-005.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.
