# 스크립트 제어 문

Qlik Sense 스크립트는 여러 문으로 구성됩니다. 문은 일반 스크립트 문이거나 스크립트 제어 문일 수 있습니다.

제어 문은 일반적으로 스크립트 실행 흐름을 제어하는 데 사용됩니다. 제어 문의 각 절은 하나의 스크립트 줄 안에 유지되어야 하며 세미콜론이나 줄 끝으로 종료될 수 있습니다.

접두사는 제어 문에 적용되지 않지만, 몇 가지 특정 제어 문과 함께 사용할 수 있는 when 및 unless 접두사는 예외입니다.

모든 스크립트 키워드는 대문자와 소문자의 조합으로 입력할 수 있습니다.

각 함수에 대한 간단한 설명과 구문을 보려면 각 함수에서 드롭다운을 사용하십시오. 자세한 내용은 구문 설명에서 해당 함수 이름을 클릭하십시오.

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### Call

call 제어 문은 앞에 sub 문으로 정의된 서브루틴을 호출합니다.

[**Call**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/Call.htm) name ( [ paramlist ])

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### Do..loop

do..loop 제어 문은 논리 조건이 충족될 때까지 하나 또는 여러 문을 실행하는 스크립트 반복 구조입니다.

[**do**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/do.htm) [ ( while | until ) condition ] [statements]  
[exit do [ ( when | unless ) condition ] [statements]  
loop [ ( while | until ) condition ]

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### Exit script

이 제어 문은 스크립트 실행을 중지합니다. 스크립트 어느 곳에나 삽입할 수 있습니다.

[**exit script**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/exit%20script.htm)[ (when | unless) condition ]

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### Exit error

Exit error 문은 스크립트 실행을 종료하고 사용자 정의 스크립트 오류를 발생시킵니다.

[**exit error**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/exit%20error.htm) expression [ (when | unless) condition ]

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### For each ..next

for each..next 제어 문은 쉼표로 구분된 목록의 각 값을 대상으로 하나 또는 여러 문을 실행하는 스크립트 반복 구조입니다. 목록의 각 값에 대해 for와 next로 묶인 루프 내의 문이 실행됩니다.

[**For Each**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/For%20Each.htm) var in list

[statements]

[exit for [ ( when | unless ) condition ]

[statements]

next [var]

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### For..next

for..next 제어 문은 카운터를 사용하는 스크립트 반복 구조입니다. 지정된 하한 및 상한 사이의 각 카운터 변수 값에 대해 for와 next로 묶인 루프 내의 문이 실행됩니다.

[**For**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/For.htm)counter = expr1 to expr2 [ stepexpr3 ]

[statements]

[exit for [ ( when | unless ) condition ]

[statements]

Next [counter]

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### If..then

if..then 제어 문은 하나 또는 여러 논리 조건에 따라 스크립트 실행을 다른 경로로 전환하는 스크립트 선택 구조입니다.

정보 메모if..then 문은 제어 문이므로 세미콜론이나 줄 끝으로 끝나야 하므로, 4개의 가능한 절(if..then, elseif..then, else 및 end if) 각각은 줄 경계를 넘지 않아야 합니다.

[**If**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/If.htm) condition then

[ statements ]

{ elseif condition then

[ statements ] }

[ else

[ statements ] ]

end if

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### Sub

sub..end sub 제어 문은 call 문에서 호출할 수 있는 서브루틴을 정의합니다.

[**Sub**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/Sub.htm) name [ ( paramlist )] statements end sub

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/script-control-statements.htm)

#### Switch

switch 제어 문은 표현식의 값에 따라 스크립트 실행을 다른 경로로 전환하는 스크립트 선택 구조입니다.

[**Switch**](https://help.qlik.com/ko-KR/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/Switch.htm) expression {case valuelist [ statements ]} [default statements] end switch