How To | Writing a .txt File To a Core Using Lua
If you are not finding the results you need and still have questions, submit a request using the form below and our Tech Docs team will get right on it. Our goal is to provide the content you need!
Your engagement helps us create the content you need. Click here to review this article.
Table of Contents
Writing a .txt file to a Core using Lua can be used for any number of applications involving regular changes to text information within a design without needing to change the overall architecture The following steps describe how to create the reference needed to utilize a .txt file for these purposes.
- Open Core Manager and go to the Files Menu.
- Add a directory. ("My Files" is used in the example below)
- Open Q-SYS Designer, then drag in a a script component.
- Insert the code below in the script component, then Save to Core and Run
This will write a file named "Test File.txt" to the Core's media directory in the My Files sub-directory. This will also print the contents of the file to the debug output.
file = io.open("media/My Files/Test File.txt", "w") file:write("Line1\n","Line2\n","Line3\n") file:close() --Read from a file file = io.open("media/My Files/Test File.txt", "r") for c in file:lines() do print(c) end file:close()