"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[8203],{1414:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>u,frontMatter:()=>t,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"XXTLanControl.lua/web-file/get_lines","title":"Read File As Lines (LCC.web_file.get_lines)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/get_lines.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/get_lines","permalink":"/docs/en/XXTLanControl.lua/web-file/get_lines","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":140,"frontMatter":{"sidebar_position":140},"sidebar":"tutorialSidebar","previous":{"title":"Upload Device File To Controller (LCC.web_file.upload_file)","permalink":"/docs/en/XXTLanControl.lua/web-file/upload_file"},"next":{"title":"Count Lines (LCC.web_file.line_count)","permalink":"/docs/en/XXTLanControl.lua/web-file/line_count"}}');var s=i(4848),r=i(8453);const t={sidebar_position:140},o="Read File As Lines (LCC.web_file.get_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,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"read-file-as-lines-lccweb_fileget_lines",children:"Read File As Lines (LCC.web_file.get_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:"lines, err = LCC.web_file.get_lines(path, 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 to read."]}),"\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:["lines",(0,s.jsx)(n.br,{}),"\n","Table. Array of lines with normalised ",(0,s.jsx)(n.code,{children:"\\n"})," endings; ",(0,s.jsx)(n.code,{children:"nil"})," 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 call 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:["Reads the entire file and splits it into a line array.",(0,s.jsx)(n.br,{}),"\n",(0,s.jsx)(n.code,{children:"\\r\\n"})," is normalised to ",(0,s.jsx)(n.code,{children:"\\n"})," before splitting."]}),"\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 lines, err = LCC.web_file.get_lines("/config/list.txt")\nif not lines then\n    error(err)\nend\nprint("Lines:", #lines)\n'})})]})}function u(e={}){const{wrapper:n}={...(0,r.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:()=>t,x:()=>o});var l=i(6540);const s={},r=l.createContext(s);function t(e){const n=l.useContext(r);return l.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:t(e.components),l.createElement(r.Provider,{value:n},e.children)}}}]);