Answered
How do I create a user variable in Extendscript.
I think the below info is correct. Let's say my user variable is named "_DocType". I can read and write and check the existence of the variable like this:
var doc = app.ActiveDoc;
// Check Exists
var varFmt = doc.GetNamedObject (Constants.FO_VarFmt, "_DocType");
if(varFmt.ObjectValid()){
alert("Variable _DocType exists!")
}
// Write Variable - as "User Guide":
var varFmt = doc.GetNamedVarFmt ("_DocType");
varFmt.Fmt = "User Guide";
// Read Variable
var varFmt = doc.GetNamedObject (Constants.FO_VarFmt, "_DocType");
alert (varFmt.Fmt);However, I'm not sure how to create the variable if it doesn't exist yet.
Thanks in advance!
