"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[7903],{8453:(e,n,i)=>{i.d(n,{R:()=>s,x:()=>a});var t=i(6540);const l={},r=t.createContext(l);function s(e){const n=t.useContext(r);return t.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(l):e.components||l:s(e.components),t.createElement(r.Provider,{value:n},e.children)}},9079:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>o,contentTitle:()=>a,default:()=>u,frontMatter:()=>s,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"XXTLanControl.lua/web-file/get_line","title":"Read A Single Line (LCC.web_file.get_line)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/get_line.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/get_line","permalink":"/docs/en/XXTLanControl.lua/web-file/get_line","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":180,"frontMatter":{"sidebar_position":180},"sidebar":"tutorialSidebar","previous":{"title":"Read A Range Of Lines (LCC.web_file.get_range_lines)","permalink":"/docs/en/XXTLanControl.lua/web-file/get_range_lines"},"next":{"title":"Replace A Range Of Lines (LCC.web_file.set_range_lines)","permalink":"/docs/en/XXTLanControl.lua/web-file/set_range_lines"}}');var l=i(4848),r=i(8453);const s={sidebar_position:180},a="Read A Single Line (LCC.web_file.get_line)",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,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"read-a-single-line-lccweb_fileget_line",children:"Read A Single Line (LCC.web_file.get_line)"})}),"\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:"line, err = LCC.web_file.get_line(path, line_number, 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:["line_number",(0,l.jsx)(n.br,{}),"\n","Number. Line index to read; 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:["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:["line",(0,l.jsx)(n.br,{}),"\n","String or ",(0,l.jsx)(n.code,{children:"nil"}),". Text of the requested line; returns an empty string when the line is not found, and ",(0,l.jsx)(n.code,{children:"nil"})," only 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"}),". Only set when the call 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:["Built on top of ",(0,l.jsx)(n.code,{children:"get_range_lines"})," to fetch a single line.",(0,l.jsx)(n.br,{}),"\n","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); ",(0,l.jsx)(n.code,{children:"0"})," means after the last line.",(0,l.jsx)(n.br,{}),"\n","Returns an empty string when the specified line is not found."]}),"\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 line, err = LCC.web_file.get_line("/config/list.txt", 3)\nif line then\n    print("Line 3: " .. line)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(d,{...e})}):d(e)}}}]);