"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[8130],{518:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>u,frontMatter:()=>t,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"XXTLanControl.lua/web-file/remove_lines","title":"Remove A Range Of Lines (LCC.web_file.remove_lines)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/remove_lines.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/remove_lines","permalink":"/docs/en/XXTLanControl.lua/web-file/remove_lines","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":230,"frontMatter":{"sidebar_position":230},"sidebar":"tutorialSidebar","previous":{"title":"Insert A Single Line (LCC.web_file.insert_line)","permalink":"/docs/en/XXTLanControl.lua/web-file/insert_line"},"next":{"title":"Remove A Single Line (LCC.web_file.remove_line)","permalink":"/docs/en/XXTLanControl.lua/web-file/remove_line"}}');var l=r(4848),s=r(8453);const t={sidebar_position:230},o="Remove A Range Of Lines (LCC.web_file.remove_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,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"remove-a-range-of-lines-lccweb_fileremove_lines",children:"Remove A Range Of Lines (LCC.web_file.remove_lines)"})}),"\n",(0,l.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-lua",children:"removed, err = LCC.web_file.remove_lines(path, start_line, count?, timeout?)\n"})}),"\n",(0,l.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["path",(0,l.jsx)(n.br,{}),"\n","String. File path."]}),"\n",(0,l.jsxs)(n.li,{children:["start_line",(0,l.jsx)(n.br,{}),"\n","Number. Starting line index; positive numbers start at ",(0,l.jsx)(n.code,{children:"1"}),", negative values count from the end (",(0,l.jsx)(n.code,{children:"-1"})," is the last line), and ",(0,l.jsx)(n.code,{children:"0"})," means after the last line."]}),"\n",(0,l.jsxs)(n.li,{children:["count",(0,l.jsx)(n.br,{}),"\n","Number, optional. Number of lines to remove, default ",(0,l.jsx)(n.code,{children:"1"}),"."]}),"\n",(0,l.jsxs)(n.li,{children:["timeout",(0,l.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,l.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["removed",(0,l.jsx)(n.br,{}),"\n","Table. Array of removed lines; returns ",(0,l.jsx)(n.code,{children:"{}"})," when the request succeeds but nothing is removed, and ",(0,l.jsx)(n.code,{children:"nil"})," on failure."]}),"\n",(0,l.jsxs)(n.li,{children:["err",(0,l.jsx)(n.br,{}),"\n","String or ",(0,l.jsx)(n.code,{children:"nil"}),". Error description when the operation fails."]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["Removes several lines at once from the file.",(0,l.jsx)(n.br,{}),"\n","See the parameter description above for line-number rules.",(0,l.jsx)(n.br,{}),"\n","Missing files, out-of-range selections, or ",(0,l.jsx)(n.code,{children:"count = 0"})," all return ",(0,l.jsx)(n.code,{children:"{}"}),".",(0,l.jsx)(n.br,{}),"\n","The returned lines can be logged or used to build an undo stack."]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-lua",children:'local removed, err = LCC.web_file.remove_lines("/config/list.txt", 2, 3)\nif removed then\n    LCC.log(2, "Removed lines", table.concat(removed, ","))\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(d,{...e})}):d(e)}},8453:(e,n,r)=>{r.d(n,{R:()=>t,x:()=>o});var i=r(6540);const l={},s=i.createContext(l);function t(e){const n=i.useContext(s);return i.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(l):e.components||l:t(e.components),i.createElement(s.Provider,{value:n},e.children)}}}]);