Author Topic: SetColor  (Read 1033 times)

bdeck

  • Hero Member
  • *****
  • Posts: 785
SetColor
« on: January 31, 2016, 03:55:45 PM »
>SetColor{} appears to no longer be supported. Causes a fatal error in recent versions.

Alternative is to set sys(300), sys(301), and sys(302)

Here's the snippet that failed:
>SetColor  ' reset color
{
   <Color [red0, green0, blue0]
}
bd

DrollTroll

  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4121
Re: SetColor
« Reply #1 on: February 01, 2016, 10:43:38 AM »
Works ok for me in dumb simple tests.
Can you provide the full macro, and possibly the drawing, that's crashing on you?

Interesting side note - looks like if "Color by Layer" is on, it'll actually change the assigned layer color...
2016 marks my 24th year in DesignCAD-Land!

bdeck

  • Hero Member
  • *****
  • Posts: 785
Re: SetColor
« Reply #2 on: February 01, 2016, 06:00:59 PM »
Hi DT,

Here's a demo that crashes DC 25 on my 64 bit satellite (running win7 system32)

bd

Code: [Select]

' Macro to test setcolor command

red0=sys(300)
green0=sys(301)
blue0=sys(302)

sys(300)=0
sys(301)=255
sys(302)=0

>line
{
<pointxyz 0, 60, 0
<pointxyz 200, 60, 0
}

gosub scolor0     ' this crashes version 25
' gosub scolor1     ' this works in all versions

>line
{
<pointxyz 0, 20, 0
<pointxyz 200, 20, 0
}

>FitToWindow
{
}
end

scolor0:
>SetColor  ' reset color
{
<Color [red0, green0, blue0]
}
return

scolor1:
sys(300)=red0
sys(301)=green0
sys(302)=blue0
return


PS:  (3/2/2016) The setcolor command in this macro also crashes DC 23 on my old xp desktop.
« Last Edit: March 02, 2016, 06:35:09 AM by bdeck »

bdeck

  • Hero Member
  • *****
  • Posts: 785
Re: SetColor
« Reply #3 on: March 02, 2016, 06:53:33 AM »
Aha,

Set color crashes only when variables [properly enclosed in brackets] are used as parameters.

This works:
>SetColor  ' reset color
   {
      <Color 150, 10, 50
   }

and, surprisingly, this works: this does not crash DC (but the variables are not recognized ) (EDIT)
>SetColor  ' reset color
   {
      <Color red0, green0, blue0
   }

But these crash:
>SetColor  ' reset color
   {
      <Color [red0, green0, blue0]
   }

>SetColor  ' reset color
   {
      <Color [red0], [green0], [blue0]
   }

Go Figure
« Last Edit: March 02, 2016, 01:06:32 PM by bdeck »

Lar

  • Hero Member
  • *****
  • Posts: 2484
Re: SetColor
« Reply #4 on: March 02, 2016, 09:43:16 AM »
bdeck,

Your full macro doesn't crash my dc25/64. Also, when I took out the square brackets it still did not crash but sys(300, 301 and 302) were all assigned zeros as opposed to the color that was active when the macro started (so if black was the active color you would not notice the difference).

Lar

DrollTroll

  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4121
Re: SetColor
« Reply #5 on: March 02, 2016, 10:19:57 AM »
I can reproduce the crash on the 32-bit build of Dcad25, but not on the 64-bit build, under Windows 7 64-bit.
2016 marks my 24th year in DesignCAD-Land!

bdeck

  • Hero Member
  • *****
  • Posts: 785
Re: SetColor
« Reply #6 on: March 02, 2016, 01:02:41 PM »

Quote
sys(300, 301 and 302) were all assigned zeros
Lar,
Oops, I should have said that removing the brackets did not crash the program. 
I had not checked the color.
Failing to use square brackets has the same result as always.

DT,
My laptop is 64-bit, but the system is 32-bit. So I' using the 32-bit build of DC.
Well, that explains our differing results.

Thanks,
BD

Lar

  • Hero Member
  • *****
  • Posts: 2484
Re: SetColor
« Reply #7 on: March 03, 2016, 07:45:59 AM »

Quote
sys(300, 301 and 302) were all assigned zeros
Lar,
Oops, I should have said that removing the brackets did not crash the program. 
Sorry, BD, I just notice I typed that leaving out the square brackets "crashed" dcad. I should have said it didn't cause an error while running the macro (but it did assign zeros to the 3 variables).

Lar

bdeck

  • Hero Member
  • *****
  • Posts: 785
Re: SetColor
« Reply #8 on: March 10, 2016, 08:00:42 PM »
Lar,

No need to apologize. Your comments were correct. When DC did not crash, I was so elated that I did not stop to consider that the variables had been simply ignored, as always happens when brackets are omitted.  I had faithfully followed DT's edict "Don't forget the square brackets!" for so long, that I had forgotten what the result would be if I left them out.

I edited my prior post to reflect reality after your comments.

Thanks,

bd
« Last Edit: March 22, 2016, 09:04:31 PM by bdeck »