[Framers] Special characters not displayed correctly in variable if inserted via script

Klaus Daube klaus at daube.ch
Wed Oct 24 10:00:41 PDT 2018


Dear all

I came across a nasty bug: Special characters not displayed correctly in variable if 
inserted via script. Please vote on https://tracker.adobe.com/#/view/FRMAKER-5522

Script InsertVariable.jsx creates a variable with this content:
 \+9\st007\st199\st254\st740\st991

However, what is displayed, even after screen refresh:
+9st007st199st254st740st991

A screen refresh has no influence. 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 a 
variable into this text.

This happens with any FM since version 10 and ESTK 4.0.0.1 (CC).

#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   = "--- Anything I want to see in my variable ---";
    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, oNewVar;

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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Klaus Daube             Phone:  +41-44-381 37 77
Schäracher 11           Mail:   klaus at daube.ch
CH-8053 Zürich          Web:    www.daube.ch




More information about the Framers mailing list