API Basic Continue ko - LIHACHTETAN/ClassicUO-BadNewbie-BasicIDE GitHub Wiki
Continue For / Do / While
ClassicUO โข Basic
Continue๋ ์ง์ ํ ์ข ๋ฅ์ ๊ฐ์ฅ ๊ฐ๊น์ด ๋ฐ๊นฅ ๋ฐ๋ณต๋ฌธ์์ ๋จ์ ๋ณธ๋ฌธ์ ๊ฑด๋๋๋๋ค. Continue For๋ ์ซ์ For์ For Each, Continue Do๋ Do/Loop์ Repeat/Until, Continue While๋ While/Wend์ ์๋๋ค.
์ ํํ ๊ตฌ๋ฌธ
Continue For
Continue Do
Continue While
๋งค๊ฐ๋ณ์
kindโ kind: Continue ๋ค์ For, Do, While ์ค ํ๋๊ฐ ํ์์ด๋ฉฐ ๊ดํธ๋ ์์ต๋๋ค. ๊ฐ์ ํ๋ก์์ ์์ ํด๋น ๋ฐ๋ณต๋ฌธ์ด ๋ฌธ์ฅ์ ๊ฐ์ธ์ผ ํฉ๋๋ค. ๋ค๋ฅธ ์ข ๋ฅ์ ์์ชฝ ๋ฐ๋ณต๋ฌธ์ ์ด๋์ ๊ฐ๋ก์ฑ์ง ์์ต๋๋ค.
๋ฐํ๊ฐ
Continue๋ ๋ฐํ๊ฐ์ด ์์ผ๋ฉฐ ์์ ์ธ ์ ์์ต๋๋ค. TRUE/FALSE๋ ์๋๊ณ ํ๋ก์์ ๋ฅผ ๋ค์ ์์ํ์ง๋ ์์ต๋๋ค. ํจ์๋ ๋์ค์ RETURN์ผ๋ก ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ ์ ์์ผ๋ฉฐ ์์ ๋ Integer 10, 3, 34๋ฅผ ๋ฐํํฉ๋๋ค.
๋์
- For๋ NEXT์์ STEP์ ์ ์ฉํ๊ณ ๋ค์ ๊ฐ์ ๋ฒ์์ ๋น๊ตํฉ๋๋ค. For Each๋ ๋ค์ ์์๋ฅผ ๊ฐ์ ธ์ค๋ฉฐ ๋๋๋ฉด ์ข ๋ฃํฉ๋๋ค. ์นด์ดํฐ ์ด๊ธฐํ๋ ์ปฌ๋ ์ ์ ํ๊ฐ๋ ๋ฐ๋ณตํ์ง ์์ต๋๋ค.
- Do์ ์์ ์กฐ๊ฑด์ ์์์์, Loop์ ๋ ์กฐ๊ฑด์ ๋์์ ๋ค์ ํ์ธํฉ๋๋ค. Repeat/Until์ UNTIL์ ์ฌ์ฉํฉ๋๋ค. ๋ฌด์กฐ๊ฑด Do/Loop๋ ๋ช ์์ ์ข ๋ฃ๋ ์ค์ง๊น์ง ๊ณ์๋ฉ๋๋ค. While๋ WHILE์ ์ฌ๊ฒ์ฌํ๋ฉฐ Continue Do๋ While/Wend๋ฅผ ์ ํํ์ง ์์ต๋๋ค.
- ์ค๋นํ ๋ ๊ฐ์ฅ ๊ฐ๊น์ด ํด๋น ๋ฐ๋ณต๋ฌธ์ ์ฃผ์๋ฅผ ์ฐพ์ต๋๋ค. ์์ผ๋ฉด Option Explicit ์์ด๋ ์ด๊ธฐํ ์ ์ SC020์ ๋ ๋๋ค. NEXT ์ด๋ฆ๊ณผ ๋๋ ๊ฒ์ฌํ๋ฉฐ IF ๊ฒฝ๊ณ๋ฅผ ๋๋ ๊ธฐ์กด FOR/NEXT ํธํ์ฑ์ ์ ์งํฉ๋๋ค.
- TRY/CATCH๋ฅผ ๋ฒ์ด๋ ๋ ๊ฑฐ์น๋ FINALLY๋ฅผ ์์์ ๋ฐ์ผ๋ก ๊ฐ๊ฐ ํ ๋ฒ ์คํํฉ๋๋ค. ๋ฐ๋ณต๋ฌธ ์ ์ฒด๊ฐ TRY ์์ ์์ผ๋ฉด ๊ทธ FINALLY๋ ๋งคํ ์คํํ์ง ์์ต๋๋ค. FINALLY์ RETURN์ด๋ ์ค๋ฅ๋ ๋ณด๋ฅ๋ ์ด๋์ ๋์ฒดํฉ๋๋ค.
- Continue๋ ๊ธฐ๋ค๋ฆฌ์ง ์์ต๋๋ค. ์กฐํ ๋ฐ๋ณต์์๋ ์กฐ๊ฑด์ ๊ฐฑ์ ํ๊ฑฐ๋ ์๋ง์ ๋๊ธฐ๋ฅผ ๋ฃ์ด ๋ฌดํ ๋ฐ๋ณต์ ํผํด์ผ ํฉ๋๋ค. ์ผ์ ์ ์งยท์ค์ง ํ์ธ์ ์ ์ง๋ฉ๋๋ค. ๋ฒ์ด๋ ๋ค์ดํฐ๋ธ ์ด๊ฑฐ์๋ ํด์ ๋๋ฉฐ ์คํ์ ์๋ก ๋ ๋ฆฝ์ ์ ๋๋ค. Exit For/Do/While๋ ๋ค์ ๋ฐ๋ณต ๋์ ์ข ๋ฃํฉ๋๋ค.
์์
1. ์์ ๊ฑด๋๋ฐ๊ธฐ
# values๋ -2, 4, 0, 6์
๋๋ค. item<=0์ด๋ฉด -2์ 0์์ Continue For๋ฅผ ์คํํด total+=item์ ๊ฑด๋๋๋๋ค. For Each๋ ๊ฐ์ ํ์์
๋๋ค. SumPositive์ Main์ 4+6์ธ Integer 10์ ๋ฐํํฉ๋๋ค.
Option Explicit On
Function SumPositive(values)
Var total = 0
For Each item In values
If item <= 0 Then
Continue For
End If
total += item
Next
Return total
End Function
Sub Main()
Dim values[3]
values[0] = -2
values[1] = 4
values[2] = 0
values[3] = 6
Return SumPositive(values)
End Sub
๋งค๊ฐ๋ณ์ ๋ฐ ์คํ ์ค๋ช :
values๋ -2, 4, 0, 6์ ๋๋ค. item<=0์ด๋ฉด -2์ 0์์ Continue For๋ฅผ ์คํํด total+=item์ ๊ฑด๋๋๋๋ค. For Each๋ ๊ฐ์ ํ์์ ๋๋ค. SumPositive์ Main์ 4+6์ธ Integer 10์ ๋ฐํํฉ๋๋ค.
2. ์ข ๋ฅ๋ก ๋ฐ๊นฅ ๋ฐ๋ณต ์ ํ
# AdvanceTo๋ limit=3์ ๋ฐ์ผ๋ฉฐ count๋ 0์์ ์์ํฉ๋๋ค. While True ์์์ count๋ฅผ ๋๋ฆฐ ๋ค Continue Do๋ก ๋ฐ๊นฅ Do์ ์ด๋ํฉ๋๋ค. ์กฐ๊ฑด์ ์ฌ๊ฒ์ฌํ๋ฉฐ count=3์์ ๋๋ Integer 3์ ๋ฐํํฉ๋๋ค.
Option Explicit On
Function AdvanceTo(limit)
Var count = 0
Do While count < limit
While True
count += 1
Continue Do
Wend
Loop
Return count
End Function
Sub Main()
Return AdvanceTo(3)
End Sub
๋งค๊ฐ๋ณ์ ๋ฐ ์คํ ์ค๋ช :
AdvanceTo๋ limit=3์ ๋ฐ์ผ๋ฉฐ count๋ 0์์ ์์ํฉ๋๋ค. While True ์์์ count๋ฅผ ๋๋ฆฐ ๋ค Continue Do๋ก ๋ฐ๊นฅ Do์ ์ด๋ํฉ๋๋ค. ์กฐ๊ฑด์ ์ฌ๊ฒ์ฌํ๋ฉฐ count=3์์ ๋๋ Integer 3์ ๋ฐํํฉ๋๋ค.
3. ๊ฑด๋๋ด ๋ฐ๋ณต๋ ์ ๋ฆฌ
# Process๋ limit=3, skip=2๋ฅผ ๋ฐ์ต๋๋ค. i๋ 1, 2, 3์
๋๋ค. ๋ ๋ฒ์งธ๋ total+=i๋ฅผ ๊ฑด๋๋ฐ์ง๋ง Finally๋ cleanup์ ์ธ ๋ฒ ๋๋ฆฝ๋๋ค. total=4, cleanup=3์ด๋ฏ๋ก RETURN cleanup*10+total์ Integer 34์
๋๋ค.
Option Explicit On
Function Process(limit, skip)
Var total = 0
Var cleanup = 0
For Var i = 1 To limit
Try
If i = skip Then
Continue For
End If
total += i
Finally
cleanup += 1
End Try
Next i
Return cleanup * 10 + total
End Function
Sub Main()
Return Process(3, 2)
End Sub
๋งค๊ฐ๋ณ์ ๋ฐ ์คํ ์ค๋ช :
Process๋ limit=3, skip=2๋ฅผ ๋ฐ์ต๋๋ค. i๋ 1, 2, 3์ ๋๋ค. ๋ ๋ฒ์งธ๋ total+=i๋ฅผ ๊ฑด๋๋ฐ์ง๋ง Finally๋ cleanup์ ์ธ ๋ฒ ๋๋ฆฝ๋๋ค. total=4, cleanup=3์ด๋ฏ๋ก RETURN cleanup*10+total์ Integer 34์ ๋๋ค.