hex & bitwise functions

Posted by jmls on 05-Oct-2008 03:32

are there any new functions / statements in 10.2 that help with hex and bitwise functions ? I have this code to convert:

value = "0xffffff";

do

{

colors.Add( Color.FromArgb(255, Color.FromArgb(value)) );

if ( value == 0 )

break;

if ( (value & 0xff) == 0 )

{

if ( (value & 0x00ff00) > 0 )

{

value -= 0x003300;

value += 0x0000ff;

}

else

{

value -= 0x330000;

value += 0x00ffff;

}

}

else

value -= 0x000033;

} while ( value >= 0 );

which I would attempt as:

ASSIGN value = 16777215.

DO WHILE value GT 0 :

colors:Add( Color:FromArgb(255, Color:FromArgb(value)) ).

if ( value EQ 0 ) THEN LEAVE.

if ( (value MOD 255 ) EQ 0 ) THEN

DO:

if ( (value MOD 65280) GT 0 ) THEN

ASSIGN value = value - 13056

value = value + 255.

else ASSIGN value = value - 3342336

value = value + 65535.

END.

else ASSIGN value = value - 51.

END.

what I am not sure about is the whole "&" thing, and I would prefer to keep the code as hex if posible.

All Replies

Posted by Simon de Kraa on 05-Oct-2008 09:58

not sure about is the whole "&" thing,

x mod 2n eq x & (2n - 1)

Posted by jmls on 05-Oct-2008 10:15

I've found that using the EnumHelper:AND EnumHelper:XOR EnumHelper:OR commands help

Posted by Admin on 05-Oct-2008 10:21

So good, that almost everything is an object on the .NET side of the bridge are objects and operations meant to support the operator everload on enums work with these colors as well.

Message was edited by:

Mike Fechner

Posted by Thomas Mercer-Hursh on 05-Oct-2008 11:20

Julian, next time you post code, try bracketing it with and (without the spaces. That will preserve your indentation and make it easier to read ... unless you normally write unindented code, of course!

Posted by Simon de Kraa on 05-Oct-2008 12:13

I've found that using the EnumHelper:AND

EnumHelper:XOR EnumHelper:OR commands help

And what about the hex values that you have to convert to decimals? Found a solution for that?

Posted by Simon de Kraa on 05-Oct-2008 12:53

BTW.

This works in the 4GL as well... (not available in V9)

DEFINE VARIABLE i AS INTEGER NO-UNDO.

i = 0x00FF00.

MESSAGE i VIEW-AS ALERT-BOX INFO BUTTONS OK.

Posted by jmls on 05-Oct-2008 12:53

And what about the hex values that you have to

convert to decimals? Found a solution for that?

yup.

Posted by jmls on 05-Oct-2008 12:54

BTW.

This works in the 4GL as well... (not available in

V9)

DEFINE VARIABLE i AS INTEGER NO-UNDO.

i = 0x00FF00.

MESSAGE i VIEW-AS ALERT-BOX INFO BUTTONS OK.

Holy cow. that is good

This thread is closed