Copy link to clipboard
Copied
Hi.
Does anybody know how to harden variables in ExtendScript ?
My guess would be that 'harden' means de-reference (convert) to text.
If so, since FM has a button for that in the Variables pod, which pops a dialog with further options, I'd be surprised if it can't be scripted.
I am still not sure what you mean by "Harden". If you want to programmatically convert variables to text, you can do something like this:
var doc, varFmt;
doc = app.ActiveDoc;
varFmt = doc.GetNamedVarFmt ("Test");
varFmt.Delete ();
This will convert any "Test" variables to text. Note that you can't delete System Variable formats; only User Variable formats.
Copy link to clipboard
Copied
What do you mean by "harden variables"?
Copy link to clipboard
Copied
My guess would be that 'harden' means de-reference (convert) to text.
If so, since FM has a button for that in the Variables pod, which pops a dialog with further options, I'd be surprised if it can't be scripted.
Copy link to clipboard
Copied
Thanks, Bob. I didn't think of that. Yes, that can be scripted.
Copy link to clipboard
Copied
🙂
I have this function and not able to go forward. do you have any suggestion ?
function HardenVariables(doc)
{
var varObj = doc.FirstVarInDoc;
while (varObj.id != 0) {
oNextVar = varObj.NextVarInDoc
// Harden Variables --------
varObj = oNextVar;
}
}
Copy link to clipboard
Copied
I am still not sure what you mean by "Harden". If you want to programmatically convert variables to text, you can do something like this:
var doc, varFmt;
doc = app.ActiveDoc;
varFmt = doc.GetNamedVarFmt ("Test");
varFmt.Delete ();
This will convert any "Test" variables to text. Note that you can't delete System Variable formats; only User Variable formats.
Copy link to clipboard
Copied
seems, it does what i need. still testing. thanks.