• Global community
• Language:
• Deutsch
• English
• EspaÃ±ol
• FranÃ§ais
• PortuguÃªs
• æ—¥æœ¬èªžã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£
Dedicated community for Japanese speakers
• í•œêµ­ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Exit
• Textline property not set within function, but ava...

# Textline property not set within function, but available outside

Community Expert ,
May 09, 2019 May 09, 2019

Copied

Dear all.

Let's see whether I can explain my current problem:

I have a function DrawTextLine which - at it's end - decides whether the text is just placed at the coordinates x0/y0 or it shall be centered within a given length (or right adjusted within this space) - line 20.

`// ---------------------------------------------- Centre/right adjust within tLength  boundLeft = 0.;  if (tLength == (undefined || null)) {    oTextLine.BasePointX = x0 * goFgr.CM;         // .Width, .Height set by text contents !    oTextLine.BasePointY = y0 * goFgr.CM;         //    oTextLine.Angle = angle * goFgr.DEGREE;    return oTextLine;  } else {    textLen = oTextLine.Width/goFgr.CM;           // cm    if (tLength > 0){      boundLeft = (Math.abs(tLength) - textLen)/2;    } else {      boundLeft = (Math.abs(tLength) - textLen);    }  }// ---------------------------------------------- Place and rotate text  dY = dX = 0.;  dX = boundLeft * angSin;  dY = boundLeft * angCos;  oTextLine.BasePointX = (x0 + dX) * goFgr.CM;    // units  oTextLine.BasePointY = (y0 + dY) * goFgr.CM;  oTextLine.Angle = angle * goFgr.DEGREE;  return oTextLine;} //--- end DrawTextLine`

In all tests this routine works fine, as the following diagram demonstrates (watch the numbers within the 1cm grid):

Now, when using this function within in another function DrawAxisCal to center the month name between the adjacent scale tics - it does not behave!

When stepping through the code the text properties show that it should be placed correctly, but it is not.

- Still within DrawTextLine the property oTextLine.Width is 0

- After DrawTextLine ahs been left the Width is set correctly.

Hence in  DrawAxisCal I again set the proper value for oTextLine.BasePointX

`xLabel  = xTic;monthLen = (monStart[j+1] - monStart)*vUnit;if (xLabel + monthLen > progressEnd) {break Cycles; } // no space for month annotationaText.length = 0;                       // clear prophylacticallyaText[0] = sMonShort[langMonth];if (monthLen > 1.35) {aText[0] = sMonNames[langMonth];} // 1.35 determined by trialoObject = DrawTextLine (xLabel, yLabel, aText, aFormat, angle, monthLen); // centred// for unknown reason centring does not work inside of DrawTextLine!oObject.BasePointX =  xLabel* goFgr.CM + (monthLen*goFgr.CM - oObject.Width)/2; // units`

I have carefully checked the scope of the variables. My only guess is that ESTK may become tired and skip certain statements. Yes, I have observed this in other circumstances already. Only after restarting FM and ESTK it worked correctly again...

â€¦ And while I'm writing this - after taking a screenshot from the open FM-document - FM-15.0.603 quits with Internal Error â€¦

TOPICS
Scripting

Views

263

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Community Expert , May 10, 2019 May 10, 2019

Well, checking oTextLine.Width at nearly every code line revealed:

At entry to line 20 (first code snipped) the Width is 0

After line 20 has been executed, the Width is set!

Hence I insert before the line 9 a "teasing code":

`oTextLine.BasePointX = x0*goFgr.CM  ;        // required to get the Width!`

Et voilÃ  - things are correct!

Community Expert ,
May 10, 2019 May 10, 2019

Copied

LATEST

Well, checking oTextLine.Width at nearly every code line revealed:

At entry to line 20 (first code snipped) the Width is 0

After line 20 has been executed, the Width is set!

Hence I insert before the line 9 a "teasing code":

`oTextLine.BasePointX = x0*goFgr.CM  ;        // required to get the Width!`

Et voilÃ  - things are correct!