"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[9069],{8453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>a});var l=i(6540);const t={},s=l.createContext(t);function r(e){const n=l.useContext(s);return l.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(t):e.components||t:r(e.components),l.createElement(s.Provider,{value:n},e.children)}},8581:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>o,contentTitle:()=>a,default:()=>u,frontMatter:()=>r,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"XXTLanControl.lua/web-file/get_range_lines","title":"Read A Range Of Lines (LCC.web_file.get_range_lines)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/get_range_lines.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/get_range_lines","permalink":"/docs/en/XXTLanControl.lua/web-file/get_range_lines","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":170,"frontMatter":{"sidebar_position":170},"sidebar":"tutorialSidebar","previous":{"title":"Overwrite With Multiple Lines (LCC.web_file.set_lines)","permalink":"/docs/en/XXTLanControl.lua/web-file/set_lines"},"next":{"title":"Read A Single Line (LCC.web_file.get_line)","permalink":"/docs/en/XXTLanControl.lua/web-file/get_line"}}');var t=i(4848),s=i(8453);const r={sidebar_position:170},a="Read A Range Of Lines (LCC.web_file.get_range_lines)",o={},d=[{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 c(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,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"read-a-range-of-lines-lccweb_fileget_range_lines",children:"Read A Range Of Lines (LCC.web_file.get_range_lines)"})}),"\n",(0,t.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-lua",children:"lines, err = LCC.web_file.get_range_lines(path, start_line?, count?, timeout?)\n"})}),"\n",(0,t.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["path",(0,t.jsx)(n.br,{}),"\n","String. File to read."]}),"\n",(0,t.jsxs)(n.li,{children:["start_line",(0,t.jsx)(n.br,{}),"\n","Number, optional. Starting line index, default ",(0,t.jsx)(n.code,{children:"1"}),"; positive numbers start at ",(0,t.jsx)(n.code,{children:"1"}),", negative values count from the end (",(0,t.jsx)(n.code,{children:"-1"})," is the last line), and ",(0,t.jsx)(n.code,{children:"0"})," means after the last line."]}),"\n",(0,t.jsxs)(n.li,{children:["count",(0,t.jsx)(n.br,{}),"\n","Number, optional. Number of lines to fetch; default ",(0,t.jsx)(n.code,{children:"-1"})," for the rest of the file."]}),"\n",(0,t.jsxs)(n.li,{children:["timeout",(0,t.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,t.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["lines",(0,t.jsx)(n.br,{}),"\n","Table. Array of strings with normalised ",(0,t.jsx)(n.code,{children:"\\n"}),"; ",(0,t.jsx)(n.code,{children:"nil"})," on failure."]}),"\n",(0,t.jsxs)(n.li,{children:["err",(0,t.jsx)(n.br,{}),"\n","String or ",(0,t.jsx)(n.code,{children:"nil"}),". Error description when the call fails."]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["Reads a range of lines from the file, useful for paginating large logs.",(0,t.jsx)(n.br,{}),"\n","Positive numbers start at ",(0,t.jsx)(n.code,{children:"1"}),"; negative values count from the end (",(0,t.jsx)(n.code,{children:"-1"})," is the last line, ",(0,t.jsx)(n.code,{children:"-2"})," the second-to-last); ",(0,t.jsx)(n.code,{children:"0"})," means after the last line.",(0,t.jsx)(n.br,{}),"\n","Returns ",(0,t.jsx)(n.code,{children:"nil"})," when the selected range has no content."]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-lua",children:'local lines, err = LCC.web_file.get_range_lines("/logs/task.log", 101, 20)\nif lines then\n    for _, line in ipairs(lines) do\n        print(line)\n    end\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}}}]);