Cannot compare two colors.

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
zolysoftsolutions
Posts: 139
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

Cannot compare two colors.

Post by zolysoftsolutions »

Hi my friends.
I have a simple question.
How you solve the problem to compare backcolor of two labels?

by example the following code will return argument error:

if this.backcolor=main.colorsample.backcolor
msginfo('You found it.')
else
msginfo('Does not match.')
endif

this also not work: if this.backcolor={255,255,0} ..argument error too.

If I'm using == operator (compare arrays) will not result error but the result is wrong:
Example:

setproperty('topping',buton,'backcolor',{128,255,128})
if getproperty('topping',buton,'backcolor')=={128,255,128}
msginfo('Yes the color is matching')
else
msginfo('False')
endif
WILL RETURN FALSE!

Thank you.
Best regards,
Zoli b.
_______________________________
Open eyes for you!
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Cannot compare two colors.

Post by serge_girard »

Zoli,

Try this:

Code: Select all

FOR A = 1 TO LEN(aColors)
   IF	VAL(aColors [a] [2]) == zCOLOR [1] .AND. VAL(aColors [a] [3]) == zCOLOR [2] .AND. VAL(aColors [a] [4]) == zCOLOR [3]
      // found
      EXIT
   ENDIF
NEXT  
Serge
There's nothing you can do that can't be done...
User avatar
zolysoftsolutions
Posts: 139
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

Re: Cannot compare two colors.

Post by zolysoftsolutions »

Hi Serge,

Thank you very much for your quick answer.
Unfortunatelly your code, as is, does not work in my case, but YOUR ideea to split the array on elements SOLVED the problem.

function comparrays(acolors,zColor)
IF aColors[1]==zColor[1] .AND. aColors[2]==zColor[2] .AND. aColors[3]==zColor[3]
return .t.
ELSE
return .f.
ENDIF
return

Thank you again.
Regards,
Zoli B.
_______________________________
Open eyes for you!
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Cannot compare two colors.

Post by serge_girard »

Great !

Serge
There's nothing you can do that can't be done...
Post Reply