Skip to main content
K.Daube
Community Expert
Community Expert
June 12, 2019
Answered

Problem with colour assignment

  • June 12, 2019
  • 2 replies
  • 1043 views

Friends and experts,

I have this short piece of code (within function Fgr_BtnAssign) which I try to debug, because results are really odd:

  // only either of these two is set (localised colour names)

  sColour = wPalP.g0.pLine.g3.ddlColourStd.selection.text +

            wPalP.g0.pLine.g3.ddlColourUser.selection.text;

alert ("«" + sColour + "» " + typeof sColour);

  if (sColour = "") { return;}                    // mis-selection

//sColour = "Pale Green";

  oColour = oDoc.GetNamedColor(sColour);          // try to assign

alert ("«" + sColour + "»");

  if (oColour.ObjectValid()) {

    oObject.Color = oDoc.GetNamedColor(sColour);

  } else {

    msgText = "Can not set colour «" + sColour + "»";

  }

Alert in line 04 says «Pale Green» string

Alert in line 08 says «» which is an empty string.

Hence GetNamedColor has destroyed it's argument what I have never seen before. Of course no colour is assigned and I get an error indication.

When directly assign a colour string in line 06, there is no problem...

ESTK mingled up? ➔ reboot ➔ nothing changed.

Well, it's time to perpare lunch anyway...

Klaus

This topic has been closed for replies.
Correct answer Klaus Göbel

Simple answer:

you assign a new value in line5

Change it from if (sColour = "") to if (sColour == "")

2 replies

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
June 12, 2019

Well, it would not help to bang my head until becaming flat. This is simply the type of error I can not spot anymore - hence pauses are the only cure to get a fresh look - and friends like You who do not hesitate to look at such stupid code...

Thank You!!!!

Klaus Göbel
Legend
June 12, 2019

Hi Klaus,

Boys our age should take a nap from time to time ;-)

That's just what I'm gonna do right now.

Klaus Göbel
Klaus GöbelCorrect answer
Legend
June 12, 2019

Simple answer:

you assign a new value in line5

Change it from if (sColour = "") to if (sColour == "")