# CreateReplyMsg

### int CreateReplyMsg(int lMsgId)

호스트로부터 수신한 메시지(`lMsgId`)에 대응하는 응답(Reply) 메시지 객체를 생성합니다. SECS-II 표준의 응답 규칙을 자동으로 적용하여 개발자의 실수를 방지합니다.

1. Stream 번호: 수신한 메시지와 동일하게 유지 (예: S1 → S1)
2. Function 번호: 수신한 번호에 +1을 하여 짝수로 자동 생성 (예: F1 → F2, F3 → F4)
3. System Byte: 수신한 메시지의 고유 번호(System Byte)를 그대로 복사하여, 호스트가 "내 질문에 대한 답장이 맞구나"라고 인식하게 함

Parameters

<table data-header-hidden><thead><tr><th width="165" valign="top"></th><th width="90" 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">수신한 메시지에 할당된 고유 ID</td></tr></tbody></table>

{% hint style="info" %}
S1F2는 GEM에서 자동응답이 가능합니다. 하기는 이해를 돕기 위한 예시입니다.
{% endhint %}

```csharp
// 호스트로부터 S1F1 (Are You There?)을 받았을 때의 처리(DisableAutoReply시에만)
void OnS1F1(int lMsgId)
{
    // 1. 답장용 S1F2 메시지 객체 생성
    int replyMsgId = m_gem.CreateReplyMsg(lMsgId);

    if (replyMsgId > 0)
    {
        // 2. 응답 내용 채우기
        m_gem.AddListItem(replyMsgId, 2);
        m_gem.AddASCIIItem(replyMsgId, "MY_EQUIP_01");
        m_gem.AddASCIIItem(replyMsgId, "V1.0.0");

        // 3. 메시지 전송
        m_gem.SendMsg(replyMsgId);
    }
}
```


---

# 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/undefined-5/createreplymsg.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.
