> 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/getterminalmsg.md).

# GetTerminalMsg

### int GetTerminalMsg(int lMsgId, ref int pnTID, ref string pstrMsg)

호스트(Host)로부터 수신한 S10F3 (Single Terminal Message) 또는 S10F5 (Multi-line Terminal Message) 메시지에서 \*\*TID(Terminal ID)\*\*와 \*\*메시지 내용(Text)\*\*을 추출합니다. 특히 멀티 라인 메시지의 경우, 이 함수를 반복 호출하여 모든 줄의 텍스트를 순차적으로 읽어올 수 있습니다.

Parameters

<table data-header-hidden><thead><tr><th width="168" valign="top"></th><th width="110" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">lMsgId</td><td valign="top">int</td><td valign="top">수신한 Message의 ID</td></tr><tr><td valign="top">pnTID</td><td valign="top">ref int</td><td valign="top">수신한 Terminal Message의 TID</td></tr><tr><td valign="top">pstrMsg</td><td valign="top">ref string</td><td valign="top">수신한 Terminal Message의 TEXT</td></tr></tbody></table>

Return Value

<table data-header-hidden><thead><tr><th width="165" 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">함수 호출 후 남은 Terminal Message의 수량</td></tr><tr><td valign="top">&#x3C;0</td><td valign="top">더 이상 Terminal Message가 없음</td></tr></tbody></table>

```csharp
    int nTID = 0;
    string strMsg = "";
    
    try
    {
        // 멀티 라인 메시지(S10F5)일 수 있으므로 반복문을 사용해 모두 읽습니다.
        while (true)
        {
            // GetTerminalMsg 호출 시 nTID와 strMsg에 데이터가 채워집니다.
            int nRemainCount = m_gem.GetTerminalMsg(lMsgId, ref nTID, ref strMsg);

            if (nRemainCount >= 0)
            {
                // 성공적으로 한 줄을 읽음. 필요시 장비 UI 팝업.
                Console.WriteLine($"[Terminal] TID: {nTID}, Message: {strMsg}");

                // 남은 메시지가 0이라면 모든 라인을 다 읽은 것이므로 종료
                if (nRemainCount == 0) break;
            }
            else
            {
                // nRemainCount가 음수면 더 이상 읽을 메시지가 없거나 에러
                break;
            }
        }

      //터미널 메시지의 응답은 불필요.
    }
    catch (Exception ex)
    {
        Console.WriteLine("Terminal Message 처리 중 예외: " + ex.Message);
    }
```


---

# 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/getterminalmsg.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.
