"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[7939],{567:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>u,frontMatter:()=>l,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"XXTLanControl.lua/web-file/insert_lines","title":"Insert Multiple Lines (LCC.web_file.insert_lines)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/insert_lines.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/insert_lines","permalink":"/docs/en/XXTLanControl.lua/web-file/insert_lines","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":210,"frontMatter":{"sidebar_position":210},"sidebar":"tutorialSidebar","previous":{"title":"Replace A Single Line (LCC.web_file.set_line)","permalink":"/docs/en/XXTLanControl.lua/web-file/set_line"},"next":{"title":"Insert A Single Line (LCC.web_file.insert_line)","permalink":"/docs/en/XXTLanControl.lua/web-file/insert_line"}}');var s=i(4848),t=i(8453);const l={sidebar_position:210},o="Insert Multiple Lines (LCC.web_file.insert_lines)",a={},c=[{value:"Signature",id:"signature",level:2},{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"Notes",id:"notes",level:2},{value:"Example",id:"example",level:2}];function d(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"insert-multiple-lines-lccweb_fileinsert_lines",children:"Insert Multiple Lines (LCC.web_file.insert_lines)"})}),"\n",(0,s.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-lua",children:"ok, err = LCC.web_file.insert_lines(path, start_line, lines, timeout?)\n"})}),"\n",(0,s.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["path",(0,s.jsx)(n.br,{}),"\n","String. File path."]}),"\n",(0,s.jsxs)(n.li,{children:["start_line",(0,s.jsx)(n.br,{}),"\n","Number. Reference line index for insertion. Positive numbers start at ",(0,s.jsx)(n.code,{children:"1"})," and insert before that line; negative values count from the end, ",(0,s.jsx)(n.code,{children:"0"})," appends after the last line, and ",(0,s.jsx)(n.code,{children:"-1"})," inserts before the last line."]}),"\n",(0,s.jsxs)(n.li,{children:["lines",(0,s.jsx)(n.br,{}),"\n","Table. Array of line strings to insert in order."]}),"\n",(0,s.jsxs)(n.li,{children:["timeout",(0,s.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,s.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["ok",(0,s.jsx)(n.br,{}),"\n","Boolean. ",(0,s.jsx)(n.code,{children:"true"})," on success, ",(0,s.jsx)(n.code,{children:"false"})," on failure."]}),"\n",(0,s.jsxs)(n.li,{children:["err",(0,s.jsx)(n.br,{}),"\n","String or ",(0,s.jsx)(n.code,{children:"nil"}),". Error description when the operation fails."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["Inserts lines before the specified line index; see the parameter description above for line-number rules.",(0,s.jsx)(n.br,{}),"\n","When the target position is beyond the current end, blank lines are padded automatically.",(0,s.jsx)(n.br,{}),"\n","Newline structure is automatically preserved for the inserted content."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-lua",children:'local ok, err = LCC.web_file.insert_lines("/config/list.txt", 2, {"New 1", "New 2"})\nif not ok then\n    error(err)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},8453:(e,n,i)=>{i.d(n,{R:()=>l,x:()=>o});var r=i(6540);const s={},t=r.createContext(s);function l(e){const n=r.useContext(t);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),r.createElement(t.Provider,{value:n},e.children)}}}]);