Replace A Range Of Lines (LCC.web_file.set_range_lines)
Signature
ok, replaced_or_err = LCC.web_file.set_range_lines(path, start_line, lines, timeout?)
Parameters
- path
String. File path. - start_line
Number. Starting line index; positive numbers start at1, negative values count from the end (-1is the last line), and0means after the end. - lines
Table. Array of new line strings. - timeout
Number, optional. Request timeout in seconds, default60.
Returns
- ok
Boolean.trueon success,falseon failure. - replaced_or_err
Table or string. Replaced original lines on success, or the error description on failure.
Notes
Overwrites multiple lines at once starting from the given position.
See the parameter description above for line-number rules.
When the target position is beyond the current end, blank lines are padded automatically.
Returns{}when no existing lines were replaced.
The returned old content is useful for auditing or undo flows.
Example
local ok, old_lines_or_err = LCC.web_file.set_range_lines("/config/list.txt", 2, {"Beta", "Gamma"})
if ok then
print("Original:", table.concat(old_lines_or_err, ","))
end