Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - PToolbox Lib query
Page 1 of 1

PostPosted: Thu Oct 03, 2002 6:17 am
by deeegeee
Greetings

I am a total newcomer to this Library.

Can anyone please tell me what is meant by the 'bits being set' in PToolboxLib. What I mean is that in some commands there are various modes that can be set in the command according to which bits are set. What does this mean and how does one 'set a bit'. Words of one syllable would be appreciated.

Many thanks

David

PostPosted: Thu Oct 03, 2002 1:14 pm
by jstadolnik
Here's how it works...

Every integer in PocketC is 32 bits long and thus contains one of 2^32 possible numerical values. Each of these 32 bits is either on (1) or off (0). Depending on what the various bits setting are, you get different numbers.

Many of the PToolbox functions check for individual bits to enable certain features. I use this technique in part because PocketC functions are limited to 10 parameters, but also to reduce the slowdown incured by pushing and popping values to/from the PocketC stack.

Given these 32 bits, the rightmost bit is 31 and the leftmost is bit 0.

It's easist to deal with bit manipulations when the numbers are in hexadecimal format. Each hex character is 4 bits wide, thus a 32 bit number will have 8 hex characters.

The hex magic decoder ring is as follows:
Bit Value Hex Value
--------- ---------
0000 0 (no bits set)
0001 1 (rightmost bit is 1)
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8 (leftmost bit is 1)
1001 9
1010 a
1011 b
1100 c
1101 d
1110 e
1111 f (all bits set)


All hex formatted numbers should be prefixed with "0x".

To set bits 0, 1, and 3 use hex value 0x0000000b (hex b is 1011 binary). You can also just do 0xb, the upper bits are automatically treated as zeroed if unspecified.

Note that this is equivalent to doing: 1<<3 + 1<<1 + 1<<0 = 0x8 + 0x2 + 0x1 = 0xb. Note the << operator is the "shift bits left" operator.

If you want to set bits 4, 8, and 16 through 19, use 0xf0110.

So this is really: 0xf<<16 + 1<<8 + 1<<4 = 0xf0000 + 0x00100 + 0x00010 = 0xf0110.

Finally, you may see ranges of bits specified in an X:Y format in much of the PToolbox docs, for example 7:4 or 3:0. This is refering to bits X through Y. So 7:4 means "bits 7 through 4", and 3:0 means "bits 3 through 0", etc.

It's pretty easy once you get the hang of it.

Joe


The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Thu Oct 03, 2002 3:15 pm
by deeegeee
Thank you Joe.

I need to study it a bit.

David

PostPosted: Fri Jan 31, 2003 12:25 am
by md_lasalle
But how do you get to wrap lines in the fiel...i tried \n in my string but it doesn't work! I use pilot-DB to create my strings

PostPosted: Fri Jan 31, 2003 12:35 am
by jstadolnik
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"> But how do you get to wrap lines in the fiel...i tried \n in my string but it doesn't work! I use pilot-DB to create my strings<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

I don't understand your question. Fields wrap text automaticly provided that you don't have "single line" mode enabled.

Pilot-DB databases have absolutely nothing to do with field wrapping.

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Fri Mar 07, 2003 5:19 am
by olmy
Geez, I'm dumb! I just can't wrap my brain around how you take the bits referred to in the Ptoolbox overview and turn them into a hexidecimal number to use as a parameter in a function.

Could someone help me work through an example? Say setting the mode parameter for a button.

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?

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.

Thanks,

Ron

PostPosted: Fri Mar 07, 2003 1:00 pm
by jstadolnik
<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

PostPosted: Sat Mar 08, 2003 5:16 pm
by olmy
Thank you so much. I think I finnally got it. I've been trying to figure that out for the last couple weeks!

Ron

PostPosted: Tue Nov 08, 2005 9:52 pm
by antix
WOW! I didnt understand a thing that he said. I wonder why people that know stuff always talk in a way that is always confusing to the person he or she is talking to... maybe a....nevermind.

PostPosted: Wed Nov 09, 2005 12:19 am
by jstadolnik
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
I wonder why people that know stuff always talk in a way that is always confusing to the person he or she is talking to... maybe a....nevermind.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

If you don't know french and you hear someone speaking french, sure it sounds pretty confusing at first. Programming and mathematics are simply "other" languages which require study to pick up.

-Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm