<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
Could someone help me work through an example? Say setting the mode parameter for a button.
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
Here is small program showing all the math:
main() {
int mode,type, frame, group, align;
type = 2; //check box type
frame = 0; //standard
group = 5; //button belongs to group 5
align = 1; //left align
mode = (type) + (frame<<4) + (group<<8) + (align<<16);
puts("Button mode=" + hex(mode) + "\n");
}
The result will be 0x1502 for the above parameters.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
In the documentation is a chart with "bits" and "values" referred to for the Button Types, Frame Styles, Grouping and Alignment. For example, the bits for the button type is 3:0. And the value for a Push Button specifically is 1. What does that mean? How do I use the bits and the value for the button type I want, to come up with a hexideciaml number for the mode parameter?
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
Every integer in PocketC has 32 bits. 3:0 means that four of these bits, ranging from bit 0 to bit 3 are used to determine the some feature. See the above program.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
I already have created a couple of buttons using 0x10 for the mode parameter, by a trial and error approach, but I really don't understand how this value defines the mode.
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
The bit sequence for 0x10 is as follows:
0000,0000,0000,0000, 0000,0000,0001,0000
The right most bit is #31, the leftmost is #0. You are setting the 5th bit on the left. Since the bit count starts at zero, you are setting bit #4, or more specifically bits 7:4 were 0001, which translates to a 0x1 hexedecimal. Given that bits 3:0 are set to 0000 (standard button) or rather 0x0 hex, the final number with frame and type is 0x10.
Joe
The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm