> For the complete documentation index, see [llms.txt](https://nviasoft.gitbook.io/nviasoft-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nviasoft.gitbook.io/nviasoft-docs/api-reference/item-parsing/getnextitemcount.md).

# GetNextItemCount

### int GetNextItemCount(int lMsgId)

GetNextItemCount 함수는 SECS 메시지 내의 특정 리스트(List) 구조가 포함하고 있는 하위 아이템(Item)의 개수를 미리 확인하고 싶을 때 사용합니다.

데이터를 실제로 꺼내기 전에 리스트의 크기를 파악하여, 반복문(for/while)의 루프 횟수를 결정하거나 메모리를 할당하는 용도로 필수적인 함수입니다.

Return Value

<table data-header-hidden><thead><tr><th width="195" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Value</td><td valign="top">Description</td></tr><tr><td valign="top">>=0</td><td valign="top">성공 (현재 Item의 뒤로 남은 Sibling(형제) Item의 수)</td></tr><tr><td valign="top">&#x3C;0</td><td valign="top">실패 (Error Code 반환) Error Code는 Error Code List를 참조</td></tr></tbody></table>

```csharp
// 1. 다음 아이템이 리스트인 경우, 그 안에 몇 개의 데이터가 있는지 확인
    int nItemCount = m_gem.GetNextItemCount(lMsgId);

    if (nItemCount > 0)
    {
        Console.WriteLine($"총 {nItemCount}개의 아이템이 리스트에 포함되어 있습니다.");

        // 2. 확인된 개수만큼 반복하여 데이터 읽기
        for (int i = 0; i < nItemCount; i++)
        {
            // 여기서 GetItem 등을 호출하여 개별 데이터를 처리합니다.
            // string val = "";
            // m_gem.GetItem(lMsgId, ref val);
        }
    }
    else if (nItemCount == 0)
    {
        Console.WriteLine("리스트가 비어 있거나 리스트 구조가 아닙니다.");
    }
    else
    {
        Console.WriteLine($"오류 발생. 에러 코드: {nItemCount}");
    }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://nviasoft.gitbook.io/nviasoft-docs/api-reference/item-parsing/getnextitemcount.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.
