"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[2131],{1927:(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_line","title":"Insert A Single Line (LCC.web_file.insert_line)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/insert_line.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/insert_line","permalink":"/docs/en/XXTLanControl.lua/web-file/insert_line","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":220,"frontMatter":{"sidebar_position":220},"sidebar":"tutorialSidebar","previous":{"title":"Insert Multiple Lines (LCC.web_file.insert_lines)","permalink":"/docs/en/XXTLanControl.lua/web-file/insert_lines"},"next":{"title":"Remove A Range Of Lines (LCC.web_file.remove_lines)","permalink":"/docs/en/XXTLanControl.lua/web-file/remove_lines"}}');var s=i(4848),t=i(8453);const l={sidebar_position:220},o="Insert A Single Line (LCC.web_file.insert_line)",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-a-single-line-lccweb_fileinsert_line",children:"Insert A Single Line (LCC.web_file.insert_line)"})}),"\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_line(path, line_number, line, 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:["line_number",(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:["line",(0,s.jsx)(n.br,{}),"\n","String. Text to insert."]}),"\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:["Convenience wrapper around ",(0,s.jsx)(n.code,{children:"insert_lines"})," for a single entry.",(0,s.jsx)(n.br,{}),"\n","Inserts one line before the specified line index; see the parameter description above for line-number rules.",(0,s.jsx)(n.br,{}),"\n","Useful for adding headers or log entries at specific spots."]}),"\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_line("/config/list.txt", 1, "Header")\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)}}}]);