Highlighted

Problem with colour assignment

Advocate ,
Jun 12, 2019

Copy link to clipboard

Copied

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

Simple answer:

you assign a new value in line5

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

TOPICS
Scripting

Views

788

Likes

Translate

Translate

Report

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

Problem with colour assignment

Advocate ,
Jun 12, 2019

Copy link to clipboard

Copied

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

Simple answer:

you assign a new value in line5

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

TOPICS
Scripting

Views

789

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 12, 2019 0
Enthusiast ,
Jun 12, 2019

Copy link to clipboard

Copied

Simple answer:

you assign a new value in line5

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 12, 2019 0
Advocate ,
Jun 12, 2019

Copy link to clipboard

Copied

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!!!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 12, 2019 0
Enthusiast ,
Jun 12, 2019

Copy link to clipboard

Copied

Hi Klaus,

Boys our age should take a nap from time to time 😉

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 12, 2019 1