# AddArrayItem

#### int AddArrayItem(int lMsgId, string strDataType, int nDataCount, string strData)

SECS 메시지 작성시 동일한 포맷의 배열 데이터를 구분자로 연결한 문자열(U1형식의 데이터 7개 = “1,2,3,4,5,6,7”) 형식으로 메시지에 추가할 수 있도록 해주는 함수입니다.

Parameters

<table data-header-hidden><thead><tr><th width="160" valign="top"></th><th width="121" 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><tr><td valign="top">strDataType</td><td valign="top">string</td><td valign="top">추가할 데이터의 형식(e.g. “U1”, “U2”,”F4”, …)</td></tr><tr><td valign="top">nDataCount</td><td valign="top">int</td><td valign="top">추가할 데이터의 수량</td></tr><tr><td valign="top">strData</td><td valign="top">string</td><td valign="top">추가할 데이터(구분자로 구분된 문자열)</td></tr></tbody></table>

```csharp
 // 메시지에 다수의 배열 데이터를 추가하는 예제
 public void SendArrayData()
 {
     // 예시 1: U1(1바이트 부호 없는 정수) 형식의 데이터 7개를 추가할 경우
     // 데이터 문자열 내의 각 값은 구분자(예: 콤마)로 연결되어 있어야 합니다.
     string strU1Data = "1,2,3,4,5,6,7";
     int nResult1 = 0;
     int lMsgId = m_gem.CreateMsg(6, 11, 1);
     m_gem.OpenListItem(lMsgId);
     {
         nResult1= m_gem.AddArrayItem(lMsgId, "U1", 7, strU1Data);
     }
     m_gem.CloseListItem(lMsgId);
     m_gem.SendMsg(lMsgId);

     if (nResult1 == 0)
     {
         Console.WriteLine("U1 배열 데이터 추가 성공");
     }
//===========================================================================
     // 예시 2: F4(4바이트 실수) 형식의 데이터 3개를 추가할 경우
     string strF4Data = "10.5, 20.7, 30.1";
     int nResult2 = m_gem.AddArrayItem(lMsgId, "F4", 3, strF4Data);

     if (nResult2 < 0)
     {
         // 실패 시 반환된 에러 코드를 확인합니다.
         Console.WriteLine($"데이터 추가 실패. 에러 코드: {nResult2}");
     }
 }
```


---

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