Include "MapBasic.def"
OR
Use the integer value defined in the definitions file:
dim b_fillstyle = ObjectInfo(Selection.obj,3)
HTH,
Tom Bacon
Graduate GIS Engineer
Asset Management South
Tel: 01444 472380
www.mouchel.com
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. Mouchel Limited, Registered in England at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX Registered No : 1686040
This gives you the individual colors (should you need them).
Then your next step is to convert decimal numbers to hexadecimal alphanumeric. The basic technique is to first build a function to convert a number in the 0 - 255 range into hex, step through the number column by column, converting each power of 256 into it's hexadecimal exquivalent. And believe it or not, it's easier to work in hexadecimal notation that decimal.
Function toHexByte( byval decByte as smallint ) as string
Dim hexByte as string, nybble(2) as smallint
If decByte > &h100 then
Print "value out of range 0 - 255"
Exit function
End if
nybble(2) = decByte \ &h10
nybble(1) = decByte mod &h10
For i = 1 to 2
hexByte = hexByte
+ mid$( "0123456789ABCDEF", nybble(i) , 1 )
Next
toHexByte = hexByte
End function
' Now split the color value into byte-size chunks (as shown above ) and stick them together.
nRed = nColor \ &H10000
nGreen = nColor \ &H100 mod &H100
nBlue = nColor mod &H100
sHex = toHexByte( nRed )
+ toHexByte( nGreen )
+ toHexByte( nBlue )
That should do it! (However, I'm not able to check it where I am just now, so if something doesn't work, please let me know and I'll fix it.) if you want to tighten up that last loop, use an array for nRed, nGreen and nBlue, then you can loop through the color bands and output all in one step.
Integer divide '\' and 'Mod' are pretty useful operators in some situations, because all we're really doing here is shifting and masking bits, which is what they do ( or at least when you use them only with powers of two. )
Regards,
Bill Thoen
GISnet
http://gisnet.com
303-786-9961
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
Just as the decimal number 16777215 is really 1*10^7 + 6*10^6 + 7*10^5 +7*10^4 +7*10^3 + 2*10^2 + 1*10^1 + 5*10^0, the same rules apply in other bases, even binary, e.g. b0110 = 0*2^3 + 1*2^2 + 1*2^1 + 0*2^0 = 6
It's not an easy topic to understand, but once you do get it, a lot "computer math" makes a lot more sense, and it's much easier to work in hexadecimal notation! But just as you did when you were learning numbers in the first grade, you have memorize the notation and the order of the digits and just start thinkingrqa in chunks of 256 or when you really get it, chunks of &H100.
Bill Thoen
GISnet
http://gisnet.com
303-786-9961
On Jan 19, 2012, at 5:27 AM, Thoern <turbo...@hotmail.com>*wrote
Include "mapbasic.def"
dim b as brush
dim ipat as integer
dim ifclr as integer
dim ibclr as integer
dim ired as smallint
dim iblue as smallint
dim igreen as smallint
b = ObjectInfo(Selection.obj,3)
' BRUSH_PATTERN is 2, meaning SOLID
ipat = StyleAttr (b, BRUSH_PATTERN)
' BRUSH_FORECOLOR is 255
ifclr = StyleAttr (b, BRUSH_FORECOLOR)
' BRUSH_BACKCOLOR is 16777215, but it's meaningless because of the solid
pattern
ibclr = StyleAttr (b, BRUSH_BACKCOLOR)
ired = ifclr \ &H10000 ' value is 0
igreen = ifclr \ &H100 mod &H100 ' value is also 0
iblue = ifclr mod &H100 ' value is 255
Spencer
ObjectInfo(Selection.obj,3)
Then the function toHexByte
SUB MAIN
--
dim sHex as string
there's probably some sort of silent conversion going on.
Spencer
-----Original Message-----
From: Thoern [mailto:turbo...@hotmail.com]
Sent: Friday, February 10, 2012 8:15 AM
To: MapInfo-L
Subject: [MI-L] Re: polygon color to field
> hexByte = hexByte + mid$( "123456789ABCDEF", nybble(i) , 1)
It was wrong to begin with:
> hexByte = hexByte + mid$( "0123456789ABCDEF", nybble(i) , 1 )
but you changed the wrong thing. It should be this instead:
hexByte = hexByte + mid$( "0123456789ABCDEF", nybble(i)+1 , 1)
Nybble () element values range from 0 through 15. That's 16 different
values and your string has only 15 characters.
String indices start at 1, so for a 16 character string they range from 1
through 16.
This means you need to add 1 to get the correct string element. Otherwise,
MapBasic will silently return an empty string when a nibble value is 0.
With the right formula, there's absolutely no reason to append zeroes to
each primary color's code.
Spencer
-----Original Message-----
From: Thoern [mailto:turbo...@hotmail.com]
Sent: Monday, February 13, 2012 5:17 AM
To: MapInfo-L
Subject: [MI-L] Re: polygon color to field