"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[4605],{201:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>a,default:()=>u,frontMatter:()=>t,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"XXTLanControl.lua/web-file/set_range_lines","title":"Replace A Range Of Lines (LCC.web_file.set_range_lines)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/set_range_lines.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/set_range_lines","permalink":"/docs/en/XXTLanControl.lua/web-file/set_range_lines","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":190,"frontMatter":{"sidebar_position":190},"sidebar":"tutorialSidebar","previous":{"title":"Read A Single Line (LCC.web_file.get_line)","permalink":"/docs/en/XXTLanControl.lua/web-file/get_line"},"next":{"title":"Replace A Single Line (LCC.web_file.set_line)","permalink":"/docs/en/XXTLanControl.lua/web-file/set_line"}}');var i=r(4848),l=r(8453);const t={sidebar_position:190},a="Replace A Range Of Lines (LCC.web_file.set_range_lines)",o={},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,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"replace-a-range-of-lines-lccweb_fileset_range_lines",children:"Replace A Range Of Lines (LCC.web_file.set_range_lines)"})}),"\n",(0,i.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-lua",children:"ok, replaced_or_err = LCC.web_file.set_range_lines(path, start_line, lines, timeout?)\n"})}),"\n",(0,i.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["path",(0,i.jsx)(n.br,{}),"\n","String. File path."]}),"\n",(0,i.jsxs)(n.li,{children:["start_line",(0,i.jsx)(n.br,{}),"\n","Number. Starting line index; positive numbers start at ",(0,i.jsx)(n.code,{children:"1"}),", negative values count from the end (",(0,i.jsx)(n.code,{children:"-1"})," is the last line), and ",(0,i.jsx)(n.code,{children:"0"})," means after the end."]}),"\n",(0,i.jsxs)(n.li,{children:["lines",(0,i.jsx)(n.br,{}),"\n","Table. Array of new line strings."]}),"\n",(0,i.jsxs)(n.li,{children:["timeout",(0,i.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,i.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["ok",(0,i.jsx)(n.br,{}),"\n","Boolean. ",(0,i.jsx)(n.code,{children:"true"})," on success, ",(0,i.jsx)(n.code,{children:"false"})," on failure."]}),"\n",(0,i.jsxs)(n.li,{children:["replaced_or_err",(0,i.jsx)(n.br,{}),"\n","Table or string. Replaced original lines on success, or the error description on failure."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsxs)(n.p,{children:["Overwrites multiple lines at once starting from the given position.",(0,i.jsx)(n.br,{}),"\n","See the parameter description above for line-number rules.",(0,i.jsx)(n.br,{}),"\n","When the target position is beyond the current end, blank lines are padded automatically.",(0,i.jsx)(n.br,{}),"\n","Returns ",(0,i.jsx)(n.code,{children:"{}"})," when no existing lines were replaced.",(0,i.jsx)(n.br,{}),"\n","The returned old content is useful for auditing or undo flows."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-lua",children:'local ok, old_lines_or_err = LCC.web_file.set_range_lines("/config/list.txt", 2, {"Beta", "Gamma"})\nif ok then\n    print("Original:", table.concat(old_lines_or_err, ","))\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}},8453:(e,n,r)=>{r.d(n,{R:()=>t,x:()=>a});var s=r(6540);const i={},l=s.createContext(i);function t(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:t(e.components),s.createElement(l.Provider,{value:n},e.children)}}}]);