Dear all
I came across a nasty bug: https://tracker.adobe.com/#/view/FRMAKER-5522 (please vote on it).
Script InsertVariable.jsx creates a variable with this content:
\+9\st007\st199\st254\st740\st991
However, what is displayed, even after screen refresh:
+9st007st199st254st740st991
This happens with any FM since version 10 and ESTK 4.0.0.1 (CC).
However after editing (replacing with itself) of any character in the variable definition the display becomes correct. There is no problem creating this variable manully via UI.
Using the corresponding Unicode characters is not an option, because this depends on the font - which mostly do not contain these characters (U2009
THIN SPACE, U+2212 MINUS SIGN or U+2011 NON-BREAKING HYPHEN).
The test script inserts some text at the top of an open document. It then inserts the variable into this text.
#target framemaker
TestInsertVariable (); //
=======================================================
function TestInsertVariable () {
var paraText = "Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. " var oDoc = app.ActiveDoc, sValue, sVarName, oTextLoc, oPgf, oTR; if(oDoc.ObjectValid()) { oPgf = oDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf; oTextLoc = new TextLoc(oPgf, 0); oDoc.AddText(oTextLoc, paraText); // create a paragraph oTextLoc = new TextLoc(oPgf, 17); // arbitrary place sVarName = "GugusVariable"; sValue = "\\+9\\st007\\st199\\st254\\st740\\st991"; // \ to be doubled in string! InsertVariable (oDoc, oTextLoc, sVarName, sValue); } else { alert ("Document does not exist or is invalid"); }
} //--- end TestInsertVariable
function InsertVariable (oDoc, oTextLoc, sVarName, sValue) {
// Arguments oDoc: current document
// oTextLoc: where to insert the variable
// sVarName: name of the variable, it may already be in the catalgoue
// sValue: contents of the variable
var oVar, NewVar;
if (!oDoc.GetNamedVarFmt(sVarName).ObjectValid()) { // needs to be defined first
oNewVar = oDoc.NewNamedVarFmt(sVarName); oNewVar.Fmt = sValue; oVar = oDoc.NewAnchoredFormattedVar (oNewVar.Name, oTextLoc); // insert at location } else { oVar = oDoc.NewAnchoredFormattedVar (sVarName, oTextLoc); // already defined, just insert }
} //--- end InsertVariable