Forums › Adobe After Effects Expressions › Script Settings File
-
Kevin Snyder
January 21, 2022 at 4:41 pmIs it possible for a script to access variables from a .txt file? I want to create a settings file that will allow the user to change the name of the text that is applied to layers when a script is run.
-
Andrei Popa
January 22, 2022 at 7:42 amIt is.
Create your javascript object holding the settings. Then to save it to a file you need to serialize it. You can do that with .toSource(). This creates a string that you can later use with eval(). So save the string created by myVar.toSource() in a txt file and when you need that variable again, read the content of the file and pass it to eval(), like this:
var mySettings = eval(contentOfFile);
-
Tomas Bumbulevičius
January 24, 2022 at 6:19 pmAlternatively, have a .json settings file – not sure whether toSource is formattable option Andrei, is it? Like adding “tidy” tabulators and at least a bit of visual sense.
Log in to reply.