List Info

Thread: Re: Logical OR as mask for changing case




Re: Logical OR as mask for changing case
country flaguser name
United States
2008-03-02 23:43:52

Thanks Tim. John Smiley told me you would have the answer.

So, then when converting to UPPER case we use XOR 20h; but when
converting to lower case, we use char(<LETTER>) OR 20h. Is that so?

John

--- In helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com, "Tim Rupp" <tim.rupp...> wrote:
&gt;
> Ok. I don't know how much explanation is required so I'll give you
the whole
&gt; enchilada.if you don't need it all just take what is required for
you. ;) I
> want to make it 54h using one of our logic functions.
>
>
>
> 0111 0100 = 74h
>
> ???? ????
>;
> 0101 0100 = 54h
>
>
>
> What we want is to make sure that the second bit of the upper four
bit
&gt; nibble is zero instead of one, yet we don't want to change any
other bit.
>; Interestingly enough, 20h is expressed in binary as 0010 000.that's
our
&gt; difference between upper and lower case. So what function can we
use that
>; when applied to 74h and 20h results in 54h. I think after a minute
or two of
> noodling that you will come to the conclusion that the XOR function
> perfectly fits the bill here. The XOR function will ensure that we
have a
> true output if we have only one or the other true. Looking at the
bitwise
> operation below it should be apparent:
>
>
>
> 0111 0100 = 74h="t"
&gt;
> 0010 0000 = 20h= the difference between the two characters.
>
> 0101 0100 = 54h after applying the XOR function to our original
character
> code and the 'difference' mask we come up with "T&quot;
>
>
>
> Hope that helps explain it to you and gives you a glimpse into some
of the
> historical aspects of how we got to here from there!
&gt;
>
>
> /tr
>
>
>
>
>
>
>
>
>
> _____
>
> From: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
[mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On
> Behalf Of Dwight Norris
&gt; Sent: Saturday, February 23, 2008 11:17 PM
> To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
&gt; Subject: Re: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> Hey Tim could we novice types have a little explanation
>
> it looks fool proof but so does my hand held calculator and it
gives me
> wrong answers all the time
>;
> dwight
&gt;
> ----- Original Message -----
>
> From: Tim Rupp <mailto:tim.rupp...>
>
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
>
> Sent: Saturday, February 23, 2008 7:57 PM
>
> Subject: RE: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> To change lower case to upper case XOR the ascii value of the
character with
>; 20h.
>;
>
>
> "a&quot; = 61h = 0110 0001
>;
> Xor 20h = 0010 0000
>;
> "A&quot; = 41h = 0100 0001
>;
>
>
> /tr
>
>
>
>
>
>
>
>
>
>
> _____
>
>
> From: <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com>
helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
&gt; [mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On Behalf Of John Smithman
> Sent: Saturday, February 23, 2008 4:38 PM
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
> Subject: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> Many years ago when I was doing a lot of coding, I used a logical
OR to
> ensure that a character was the right case. I am trying to remember
the
> technique.
>
> Has anyone used this foolproof coding trick for changing case?
&gt;
> John
>;

__._,_.___
.

__,_._,___
RE: Re: Logical OR as mask for changing case
country flaguser name
United States
2008-03-03 05:12:40

That’;s certainly one way you could do it.

 

You could also apply a bit mask of 1101 111, which is DF in hex, and by using the AND function get the same result.

 

Seems there̵7;s always more than one way to get to where we want to go with this stuff!

 

/tr

 

 


From: helpwithvbyahoogroups.com [mailto:helpwithvbyahoogroups.com] On Behalf Of John Smithman
Sent: Monday, March 03, 2008 12:44 AM
To: helpwithvbyahoogroups.com
Subject: [helpwithvb] Re: Logical OR as mask for changing case

 

Thanks Tim. John Smiley told me you would have the answer.

So, then when converting to UPPER case we use XOR 20h; but when
converting to lower case, we use char(<LETTER>) OR 20h. Is that so?

John

--- In helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com, &quot;Tim Rupp" <tim.rupp...> wrote:
&gt;
> Ok. I don't know how much explanation is required so I'll give you
the whole
&gt; enchilada.if you don't need it all just take what is required for
you. ;) I
> want to make it 54h using one of our logic functions.
>
>
>
> 0111 0100 = 74h
>
> ???? ????
>;
> 0101 0100 = 54h
>
>
>
> What we want is to make sure that the second bit of the upper four
bit
&gt; nibble is zero instead of one, yet we don't want to change any
other bit.
>; Interestingly enough, 20h is expressed in binary as 0010 000.that's
our
&gt; difference between upper and lower case. So what function can we
use that
>; when applied to 74h and 20h results in 54h. I think after a minute
or two of
> noodling that you will come to the conclusion that the XOR function
> perfectly fits the bill here. The XOR function will ensure that we
have a
> true output if we have only one or the other true. Looking at the
bitwise
> operation below it should be apparent:
>
>
>
> 0111 0100 = 74h="t"
&gt;
> 0010 0000 = 20h= the difference between the two characters.
>
> 0101 0100 = 54h after applying the XOR function to our original
character
> code and the 'difference' mask we come up with "T&quot;
>
>
>
> Hope that helps explain it to you and gives you a glimpse into some
of the
> historical aspects of how we got to here from there!
&gt;
>
>
> /tr
>
>
>
>
>
>
>
>
>
> _____
>
> From: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
[mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On
> Behalf Of Dwight Norris
&gt; Sent: Saturday, February 23, 2008 11:17 PM
> To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
&gt; Subject: Re: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> Hey Tim could we novice types have a little explanation
>
> it looks fool proof but so does my hand held calculator and it
gives me
> wrong answers all the time
>;
> dwight
&gt;
> ----- Original Message -----
>
> From: Tim Rupp <mailto:tim.rupp...>
>
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
>
> Sent: Saturday, February 23, 2008 7:57 PM
>
> Subject: RE: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> To change lower case to upper case XOR the ascii value of the
character with
>; 20h.
>;
>
>
> "a&quot; = 61h = 0110 0001
>;
> Xor 20h = 0010 0000
>;
> "A&quot; = 41h = 0100 0001
>;
>
>
> /tr
>
>
>
>
>
>
>
>
>
>
> _____
>
>
> From: <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com>
helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
&gt; [mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On Behalf Of John Smithman
> Sent: Saturday, February 23, 2008 4:38 PM
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
> Subject: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> Many years ago when I was doing a lot of coding, I used a logical
OR to
> ensure that a character was the right case. I am trying to remember
the
> technique.
>
> Has anyone used this foolproof coding trick for changing case?
&gt;
> John
>;

__._,_.___
.

__,_._,___
Re: Re: Logical OR as mask for changing case
country flaguser name
United States
2008-03-03 12:28:54

Theres been a bit of interest lately in old-time programming and associated nostalgia, and now Im glancing through this stuff, and while not understanding it (or really wanting to understand it), it all rings a bit of a bell, and my attention was particularly caught by logical OR and XOR, etc. OK, Ill get to the point.

 

In the mid-1980s, I had a state-of-the art Amstrad CPC 464 (Memory 64K !) It had superb graphics, and I wrote an aerial combat game on it with each side moving in turn, like Chess. The heading of the aircraft was indicated by its vapour trail, so each move involved the erasure of the previous moves vapour trail. This was done by, I think, an EOR or some other graphics command. Can anything like that be done in VB, particularly VB5 ? If so, can anyone point me to where Ill find that sort of graphics coding.

 

Brian

----- Original Message -----
Sent: Monday, March 03, 2008 5:43 AM
Subject: [helpwithvb] Re: Logical OR as mask for changing case

Thanks Tim. John Smiley told me you would have the answer.

So, then when converting to UPPER case we use XOR 20h; but when
converting to lower case, we use char(<LETTER>) OR 20h. Is that so?

John

--- In helpwithvb@yahoogroups.com">helpwithvbyahoogroups.com, "Tim Rupp" <tim.rupp...> wrote:
>;
> Ok. I don't know how much explanation is required so I'll give you
the whole
> enchilada.if you don't need it all just take what is required for
you. ;) I
> want to make it 54h using one of our logic functions.
>
>
>
> 0111 0100 = 74h
>
> ???? ????
>
> 0101 0100 = 54h
>
>
>
> What we want is to make sure that the second bit of the upper four
bit
> nibble is zero instead of one, yet we don't want to change any
other bit.
> Interestingly enough, 20h is expressed in binary as 0010 000.that's
our
> difference between upper and lower case. So what function can we
use that
> when applied to 74h and 20h results in 54h. I think after a minute
or two of
> noodling that you will come to the conclusion that the XOR function
&gt; perfectly fits the bill here. The XOR function will ensure that we
have a
> true output if we have only one or the other true. Looking at the
bitwise
&gt; operation below it should be apparent:
>
>
>
> 0111 0100 = 74h="t"
&gt;
> 0010 0000 = 20h= the difference between the two characters.
>
> 0101 0100 = 54h after applying the XOR function to our original
character
> code and the 'difference' mask we come up with "T"
>
>
>
> Hope that helps explain it to you and gives you a glimpse into some
of the
> historical aspects of how we got to here from there!
>;
>
>
> /tr
>
>
>
>
>
>
>
>
>
> _____
>
> From: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
[mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On
> Behalf Of Dwight Norris
>; Sent: Saturday, February 23, 2008 11:17 PM
> To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
>; Subject: Re: [helpwithvb] Logical OR as mask for changing case
>
>
>
> Hey Tim could we novice types have a little explanation
>
> it looks fool proof but so does my hand held calculator and it
gives me
> wrong answers all the time
>
> dwight
>;
> ----- Original Message -----
>
> From: Tim Rupp <mailto:tim.rupp...>
>
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
>
> Sent: Saturday, February 23, 2008 7:57 PM
>
> Subject: RE: [helpwithvb] Logical OR as mask for changing case
>
>
>
> To change lower case to upper case XOR the ascii value of the
character with
> 20h.
>
>
>
> "a" = 61h = 0110 0001
>
> Xor 20h = 0010 0000
>
> "A" = 41h = 0100 0001
>
>
>
> /tr
>
>
>
>
>
>
>
>
>
>
> _____
>
>
> From: <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com>
helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
>; [mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On Behalf Of John Smithman
&gt; Sent: Saturday, February 23, 2008 4:38 PM
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
&gt; Subject: [helpwithvb] Logical OR as mask for changing case
>
>
>
> Many years ago when I was doing a lot of coding, I used a logical
OR to
> ensure that a character was the right case. I am trying to remember
the
> technique.
>
> Has anyone used this foolproof coding trick for changing case?
>
> John
>

__._,_.___
.

__,_._,___
RE: Re: Logical OR as mask for changing case
country flaguser name
United States
2008-03-03 11:50:11

When you say VB and Graphics Programming in the same sentence, there automatically pops up the name Rod Stephens. Perhaps he is the most accomplished at what you may be looking to do and he’s a pretty darn fine author too.

 

Please visit his website at http://www.vb-helper.com/books_by_rod.html

 

/tr

 

 


From: helpwithvbyahoogroups.com [mailto:helpwithvbyahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Monday, March 03, 2008 1:29 PM
To: helpwithvbyahoogroups.com
Subject: Re: [helpwithvb] Re: Logical OR as mask for changing case

 

There̵7;s been a bit of interest lately in old-time programming and associated nostalgia, and now I’m glancing through this stuff, and while not understanding it (or really wanting to understand it), it all rings a bit of a bell, and my attention was particularly caught by logical OR and XOR, etc. OK, I’ll get to the point.

 

In the mid-1980s, I had a state-of-the art Amstrad CPC 464 (Memory 64K !) It had superb graphics, and I wrote an aerial combat game on it with each side R16;moving&#8217; in turn, like Chess. The heading of the aircraft was indicated by its vapour trail, so each move involved the erasure of the previous move’;s vapour trail. This was done by, I think, an EOR or some other graphics command. Can anything like that be done in VB, particularly VB5 ? If so, can anyone point me to where I’ll find that sort of graphics coding.

 

Brian

----- Original Message -----

From: smithmanchampions.ca" title="smithmanchampions.ca">John Smithman

To: helpwithvb@yahoogroups.com" title="helpwithvb@yahoogroups.com">helpwithvbyahoogroups.com

Sent: Monday, March 03, 2008 5:43 AM

Subject: [helpwithvb] Re: Logical OR as mask for changing case

 

Thanks Tim. John Smiley told me you would have the answer.

So, then when converting to UPPER case we use XOR 20h; but when
converting to lower case, we use char(<LETTER>) OR 20h. Is that so?

John

--- In helpwithvb@yahoogroups.com">helpwithvbyahoogroups.com, &quot;Tim Rupp" <tim.rupp...> wrote:
&gt;
> Ok. I don't know how much explanation is required so I'll give you
the whole
&gt; enchilada.if you don't need it all just take what is required for
you. ;) I
> want to make it 54h using one of our logic functions.
>
>
>
> 0111 0100 = 74h
>
> ???? ????
>;
> 0101 0100 = 54h
>
>
>
> What we want is to make sure that the second bit of the upper four
bit
&gt; nibble is zero instead of one, yet we don't want to change any
other bit.
>; Interestingly enough, 20h is expressed in binary as 0010 000.that's
our
&gt; difference between upper and lower case. So what function can we
use that
>; when applied to 74h and 20h results in 54h. I think after a minute
or two of
> noodling that you will come to the conclusion that the XOR function
> perfectly fits the bill here. The XOR function will ensure that we
have a
> true output if we have only one or the other true. Looking at the
bitwise
> operation below it should be apparent:
>
>
>
> 0111 0100 = 74h="t"
&gt;
> 0010 0000 = 20h= the difference between the two characters.
>
> 0101 0100 = 54h after applying the XOR function to our original
character
> code and the 'difference' mask we come up with "T&quot;
>
>
>
> Hope that helps explain it to you and gives you a glimpse into some
of the
> historical aspects of how we got to here from there!
&gt;
>
>
> /tr
>
>
>
>
>
>
>
>
>
> _____
>
> From: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
[mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On
> Behalf Of Dwight Norris
&gt; Sent: Saturday, February 23, 2008 11:17 PM
> To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
&gt; Subject: Re: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> Hey Tim could we novice types have a little explanation
>
> it looks fool proof but so does my hand held calculator and it
gives me
> wrong answers all the time
>;
> dwight
&gt;
> ----- Original Message -----
>
> From: Tim Rupp <mailto:tim.rupp...>
>
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
>
> Sent: Saturday, February 23, 2008 7:57 PM
>
> Subject: RE: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> To change lower case to upper case XOR the ascii value of the
character with
>; 20h.
>;
>
>
> "a&quot; = 61h = 0110 0001
>;
> Xor 20h = 0010 0000
>;
> "A&quot; = 41h = 0100 0001
>;
>
>
> /tr
>
>
>
>
>
>
>
>
>
>
> _____
>
>
> From: <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com>
helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
&gt; [mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On Behalf Of John Smithman
> Sent: Saturday, February 23, 2008 4:38 PM
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
> Subject: [helpwithvb] Logical OR as mask for changing case
>;
>
>
> Many years ago when I was doing a lot of coding, I used a logical
OR to
> ensure that a character was the right case. I am trying to remember
the
> technique.
>
> Has anyone used this foolproof coding trick for changing case?
&gt;
> John
>;

__._,_.___
.

__,_._,___
Re: Re: Logical OR as mask for changing case
country flaguser name
United States
2008-03-03 14:56:56

Many thanks,
 
Brian
----- Original Message -----
Sent: Monday, March 03, 2008 5:50 PM
Subject: RE: [helpwithvb] Re: Logical OR as mask for changing case

When you say VB and Graphics Programming in the same sentence, there automatically pops up the name Rod Stephens. Perhaps he is the most accomplished at what you may be looking to do and hes a pretty darn fine author too.

Please visit his website at http://www.vb-helper.com/books_by_rod.html

/tr


From: helpwithvb@yahoogroups.com">helpwithvbyahoogroups.com [mailto:helpwithvbyahoogroups.com] On Behalf Of Brian Shieldhouse
Sent: Monday, March 03, 2008 1:29 PM
To: helpwithvbyahoogroups.com
Subject: Re: [helpwithvb] Re: Logical OR as mask for changing case

Theres been a bit of interest lately in old-time programming and associated nostalgia, and now Im glancing through this stuff, and while not understanding it (or really wanting to understand it), it all rings a bit of a bell, and my attention was particularly caught by logical OR and XOR, etc. OK, Ill get to the point.

In the mid-1980s, I had a state-of-the art Amstrad CPC 464 (Memory 64K !) It had superb graphics, and I wrote an aerial combat game on it with each side moving in turn, like Chess. The heading of the aircraft was indicated by its vapour trail, so each move involved the erasure of the previous moves vapour trail. This was done by, I think, an EOR or some other graphics command. Can anything like that be done in VB, particularly VB5 ? If so, can anyone point me to where Ill find that sort of graphics coding.

Brian

----- Original Message -----

Sent: Monday, March 03, 2008 5:43 AM

Subject: [helpwithvb] Re: Logical OR as mask for changing case

Thanks Tim. John Smiley told me you would have the answer.

So, then when converting to UPPER case we use XOR 20h; but when
converting to lower case, we use char(<LETTER>) OR 20h. Is that so?

John

--- In helpwithvb@yahoogroups.com">helpwithvbyahoogroups.com, "Tim Rupp" <tim.rupp...> wrote:
>;
> Ok. I don't know how much explanation is required so I'll give you
the whole
> enchilada.if you don't need it all just take what is required for
you. ;) I
> want to make it 54h using one of our logic functions.
>
>
>
> 0111 0100 = 74h
>
> ???? ????
>
> 0101 0100 = 54h
>
>
>
> What we want is to make sure that the second bit of the upper four
bit
> nibble is zero instead of one, yet we don't want to change any
other bit.
> Interestingly enough, 20h is expressed in binary as 0010 000.that's
our
> difference between upper and lower case. So what function can we
use that
> when applied to 74h and 20h results in 54h. I think after a minute
or two of
> noodling that you will come to the conclusion that the XOR function
&gt; perfectly fits the bill here. The XOR function will ensure that we
have a
> true output if we have only one or the other true. Looking at the
bitwise
&gt; operation below it should be apparent:
>
>
>
> 0111 0100 = 74h="t"
&gt;
> 0010 0000 = 20h= the difference between the two characters.
>
> 0101 0100 = 54h after applying the XOR function to our original
character
> code and the 'difference' mask we come up with "T"
>
>
>
> Hope that helps explain it to you and gives you a glimpse into some
of the
> historical aspects of how we got to here from there!
>;
>
>
> /tr
>
>
>
>
>
>
>
>
>
> _____
>
> From: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
[mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On
> Behalf Of Dwight Norris
>; Sent: Saturday, February 23, 2008 11:17 PM
> To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
>; Subject: Re: [helpwithvb] Logical OR as mask for changing case
>
>
>
> Hey Tim could we novice types have a little explanation
>
> it looks fool proof but so does my hand held calculator and it
gives me
> wrong answers all the time
>
> dwight
>;
> ----- Original Message -----
>
> From: Tim Rupp <mailto:tim.rupp...>
>
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
>
> Sent: Saturday, February 23, 2008 7:57 PM
>
> Subject: RE: [helpwithvb] Logical OR as mask for changing case
>
>
>
> To change lower case to upper case XOR the ascii value of the
character with
> 20h.
>
>
>
> "a" = 61h = 0110 0001
>
> Xor 20h = 0010 0000
>
> "A" = 41h = 0100 0001
>
>
>
> /tr
>
>
>
>
>
>
>
>
>
>
> _____
>
>
> From: <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com>
helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
>; [mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com] On Behalf Of John Smithman
&gt; Sent: Saturday, February 23, 2008 4:38 PM
> To: helpwithvbyahoogro <mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com> ups.com
&gt; Subject: [helpwithvb] Logical OR as mask for changing case
>
>
>
> Many years ago when I was doing a lot of coding, I used a logical
OR to
> ensure that a character was the right case. I am trying to remember
the
> technique.
>
> Has anyone used this foolproof coding trick for changing case?
>
> John
>

__._,_.___
.

__,_._,___
Re: Re: Logical OR as mask for changing case
country flaguser name
Australia
2008-03-04 00:31:07

ON MON, 2008-03-03 AT 18:28 +0000, BRIAN SHIELDHOUSE WROTE:

> IN THE MID-1980S, I HAD A STATE-OF-THE ART AMSTRAD CPC 464 (MEMORY
> 64K !) IT HAD SUPERB GRAPHICS, AND I WROTE AN AERIAL COMBAT GAME ON IT
> WITH EACH SIDE MOVING IN TURN, LIKE CHESS. THE HEADING OF THE
> AIRCRAFT WAS INDICATED BY ITS VAPOUR TRAIL, SO EACH MOVE INVOLVED THE
> ERASURE OF THE PREVIOUS MOVES VAPOUR TRAIL. THIS WAS DONE BY, I
> THINK, AN EOR OR SOME OTHER GRAPHICS COMMAND. CAN ANYTHING LIKE THAT
>; BE DONE IN VB, PARTICULARLY VB5 ? IF SO, CAN ANYONE POINT ME TO WHERE
&GT; ILL FIND THAT SORT OF GRAPHICS CODING.

THE SEARCH TERM YOU ARE LOOKING FOR IS "SETROP2", BUT I WOULDN'T USE
THAT TECHNIQUE FOR SOMETHING TURN BASED.

I CUT MY TEETH ON THE OLD AMSTRAD CPC 464 (THAT, AND THE BBC MICRO), AND
I WROTE A FEW TURN-BASED GAMES.

THE WAY I REMEMBER IT, THE SCREEN WAS 40 CHARACTERS ACROSS AND 25
CHARACTERS DOWN.

ALLOWING FOR 3 LINES OF TEXT AT THE BOTTOM OF THE SCREEN (FOR DISPLAYING
INSTRUCTIONS & OPTIONS), I USUALLY REPRESENTED THE PLAYING SURFACE AS A
2 DIMENSIONAL ARRAY OF 40X22 CHARACTERS (STRINGS, ACTUALLY).

THE CHARACTER IN ANY ELEMENT OF THE ARRAY REPRESENTED THE TYPE OF PIECE
IN THAT SQUARE.

IN RETROSPECT, I SHOULD HAVE USED AN ARRAY OF INTEGERS, SINCE THE
AMSTRAD HAD AN ANNOYING GARBAGE COLLECTION SYSTEM FOR STRINGS THAT MADE
THE GAME FREEZE UP PERIODICALLY (LIKE DOTNET 1.0), BUT STRINGS EASILY
ALLOWED FOR THE POSSIBILITY OF THERE BEING MORE THAN ONE PLAYING PIECE
ON A SQUARE.*

FOR VAPOUR TRAILS, YOU COULD USE TWO SEPARATE PLAYING PIECE TYPES: ONE
TO REPRESENT A "FRESH" VAPOUR TRAIL, AND ONE TO REPRESENT A "STALE"
VAPOUR TRAIL.

ON EACH TURN, LOOP THROUGH EACH ELEMENT OF THE ARRAY, AND CLEAR ANY
STALE VAPOUR TRAIL PIECES, AND TURN ANY FRESH VAPOUR TRAIL PIECES INTO
STALE VAPOUR TRAIL.

ADELLE.

* STRING ALLOCATION ON THE BBC MICRO WAS MUCH MORE SENSIBLE, BUT HAD
DRAWBACKS OF ITS OWN. IF YOU REASSIGNED THE VALUE OF A STRING VARIABLE,
AND THE NEW VALUE WAS THE SAME OR SHORTER THAN THE ORIGINAL VALUE, THE
NEW VALUE WOULD BE STORED IN THE SAME MEMORY AS THE ORIGINAL VALUE
WITHOUT A REALLOCATION. IF YOU OVERWROTE A STRING VARIABLE WITH A
LONGER VALUE, A REALLOCATION WOULD BE REQUIRED, EXCEPT STRINGS WERE
ALWAYS PREALLOCATED WITH AN ADDITIONAL ALLOWANCE TO ALLOW THE FOR THE
STRING TO BE LENGTHENED BY A FEW CHARACTERS WITHOUT REQUIRING A
REALLACTION. THE DRAWBACK WAS THAT IF YOU HAD AN ARRAY OF VERY SHORT
STRINGS (40X22 WAS A LOT OF STRINGS IN THOSE DAYS), THE ARRAY WOULD TAKE
UP A LOT MORE SPACE IN MEMORY THAN ON PAPER IT LOOKED LIKE IT SHOULD.

__._,_.___
.

__,_._,___
Re: Re: Logical OR as mask for changing case
country flaguser name
United States
2008-03-05 12:33:20

?

THANKS ADELLE BUT I CANT SEE ANY OF THIS IN VB5. HOWEVER I FOUND THE FOLLOWING PASSAGE ON THE NET: THE BOX IS DRAWN WITH A TECHNIQUE THAT USES THE XOR GRAPHICS FUNCTION. AS THE BOX IS DRAWN, THE UNDERLYING PIXELS ARE ESSENTIALLY "FLIPPED" TO THEIR OPPOSITE COLOR. DRAWING THE BOX A SECOND TIME "FLIPS" THE PIXELS TO THEIR ORIGINAL COLOR, THEREBY ERASING THE BOX. EVEN IN VB5 I CAN DRAW A LINE AND CHOOSE ITS COLOUR, SO THE SAME TECHNIQUE MIGHT WORK IF I COULD ESTABLISH WHAT THE OPPOSITE COLOUR IS. ANY IDEAS ? OR AM I CHASING RAINBOWS ?

&NBSP;

----- ORIGINAL MESSAGE -----
SENT: TUESDAY, MARCH 04, 2008 6:31 AM
SUBJECT: RE: [HELPWITHVB] RE: LOGICAL OR AS MASK FOR CHANGING CASE

ON MON, 2008-03-03 AT 18:28 +0000, BRIAN SHIELDHOUSE WROTE:

&GT; IN THE MID-1980S, I HAD A STATE-OF-THE ART AMSTRAD CPC 464 (MEMORY
&GT; 64K !) IT HAD SUPERB GRAPHICS, AND I WROTE AN AERIAL COMBAT GAME ON IT
> WITH EACH SIDE MOVING IN TURN, LIKE CHESS. THE HEADING OF THE
> AIRCRAFT WAS INDICATED BY ITS VAPOUR TRAIL, SO EACH MOVE INVOLVED THE
> ERASURE OF THE PREVIOUS MOVES VAPOUR TRAIL. THIS WAS DONE BY, I
> THINK, AN EOR OR SOME OTHER GRAPHICS COMMAND. CAN ANYTHING LIKE THAT
> BE DONE IN VB, PARTICULARLY VB5 ? IF SO, CAN ANYONE POINT ME TO WHERE
> ILL FIND THAT SORT OF GRAPHICS CODING.

THE SEARCH TERM YOU ARE LOOKING FOR IS "SETROP2", BUT I WOULDN'T USE
THAT TECHNIQUE FOR SOMETHING TURN BASED.

I CUT MY TEETH ON THE OLD AMSTRAD CPC 464 (THAT, AND THE BBC MICRO), AND
I WROTE A FEW TURN-BASED GAMES.

THE WAY I REMEMBER IT, THE SCREEN WAS 40 CHARACTERS ACROSS AND 25
CHARACTERS DOWN.

ALLOWING FOR 3 LINES OF TEXT AT THE BOTTOM OF THE SCREEN (FOR DISPLAYING
INSTRUCTIONS & OPTIONS), I USUALLY REPRESENTED THE PLAYING SURFACE AS A
2 DIMENSIONAL ARRAY OF 40X22 CHARACTERS (STRINGS, ACTUALLY).

THE CHARACTER IN ANY ELEMENT OF THE ARRAY REPRESENTED THE TYPE OF PIECE
IN THAT SQUARE.

IN RETROSPECT, I SHOULD HAVE USED AN ARRAY OF INTEGERS, SINCE THE
AMSTRAD HAD AN ANNOYING GARBAGE COLLECTION SYSTEM FOR STRINGS THAT MADE
THE GAME FREEZE UP PERIODICALLY (LIKE DOTNET 1.0), BUT STRINGS EASILY
ALLOWED FOR THE POSSIBILITY OF THERE BEING MORE THAN ONE PLAYING PIECE
ON A SQUARE.*

FOR VAPOUR TRAILS, YOU COULD USE TWO SEPARATE PLAYING PIECE TYPES: ONE
TO REPRESENT A "FRESH" VAPOUR TRAIL, AND ONE TO REPRESENT A "STALE"
VAPOUR TRAIL.

ON EACH TURN, LOOP THROUGH EACH ELEMENT OF THE ARRAY, AND CLEAR ANY
STALE VAPOUR TRAIL PIECES, AND TURN ANY FRESH VAPOUR TRAIL PIECES INTO
STALE VAPOUR TRAIL.

ADELLE.

* STRING ALLOCATION ON THE BBC MICRO WAS MUCH MORE SENSIBLE, BUT HAD
DRAWBACKS OF ITS OWN. IF YOU REASSIGNED THE VALUE OF A STRING VARIABLE,
AND THE NEW VALUE WAS THE SAME OR SHORTER THAN THE ORIGINAL VALUE, THE
NEW VALUE WOULD BE STORED IN THE SAME MEMORY AS THE ORIGINAL VALUE
WITHOUT A REALLOCATION. IF YOU OVERWROTE A STRING VARIABLE WITH A
LONGER VALUE, A REALLOCATION WOULD BE REQUIRED, EXCEPT STRINGS WERE
ALWAYS PREALLOCATED WITH AN ADDITIONAL ALLOWANCE TO ALLOW THE FOR THE
STRING TO BE LENGTHENED BY A FEW CHARACTERS WITHOUT REQUIRING A
REALLACTION. THE DRAWBACK WAS THAT IF YOU HAD AN ARRAY OF VERY SHORT
STRINGS (40X22 WAS A LOT OF STRINGS IN THOSE DAYS), THE ARRAY WOULD TAKE
UP A LOT MORE SPACE IN MEMORY THAN ON PAPER IT LOOKED LIKE IT SHOULD.

__._,_.___
.

__,_._,___
Re: Re: Logical OR as mask for changing case
country flaguser name
Australia
2008-03-05 19:35:21
Brian Shieldhouse wrote:
> 
> Thanks Adelle but I cant see any of this in VB5.
However I found the 
> following passage on the net: the box is drawn with a
technique that 
> uses the XOR graphics function. As the box is drawn,
the underlying 
> pixels are essentially "flipped" to their
opposite color. Drawing the 
> box a second time "flips" the pixels to their
original color, thereby 
> erasing the box. Even in VB5 I can draw a line and
choose its colour, 
> so the same technique might work if I could establish
what the 
> opposite colour is. Any ideas ? Or am I chasing
rainbows ?

This example uses GDI - the subsystem in Windows which is
responsible 
for graphics.

It's air code.  You need to declare the api functions used.

The basic pattern for using GDI is
   1. Create the pen and or brush or other object that you
need.
   2. Select the pen and or brush or other object into a
device context 
(represented by a "device context handle" aka
"hdc").
   3. Do some drawing.
   4. Select the "original" pen/brush/whatever
that was/were current 
before you started. (SelectObject returns a handle to the
current 
pen/brush/whatever).
   5. Delete the objects you created.
   6. Restore any other state that you changed along the
way.

         Dim hOldRop As Long
         Dim hOldPen As Long

         ' 0. Change the current raster operation for the
dc.
         hOldRop = SetROP2(hdc, R2_NOTXORPEN)

         ' 1. Create the pen that we need.
         hPen = CreatePen(PS_DOT, Width, &H101010)

         ' 2. Select the newly created pen into the dc.
         hOldPen = SelectObject(hdc, hPen)

         ' 3. Do some drawing.  Coordinates is an array of
POINT 
structures (a structure known to the VB6 API viewer as
POINTAPI).
         Polyline hdc, Coordinates(0),
UBound(Coordinates)+1

         ' 4. Select the original pen.
         SelectObject hdc, hOldPen

         ' 5. Delete the objects that we created.
         DeleteObject hPen

         ' 6. Restore any other state that we changed.
         SetROP2 hdc, hOldRop

The magic is in step 0.

Adelle.


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://grou
ps.yahoo.com/group/helpwithvb/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://
groups.yahoo.com/group/helpwithvb/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:helpwithvb-digest@yahoogroups.com 
    mailto:helpwithvb-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    helpwithvb-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 

Win32 GDI APIs Where They Be Hiding
country flaguser name
United States
2008-03-06 10:49:25


>&gt; It's air code.
>>; You need to declare the API functions used.

Didn't appreciate, when I started this list, that I needed
some mindless 'Veg-Out' time, so this little list became
some what larger than I had intended at the start < g >

Maybe it will be of use to some.
-----

This might be all you need.
There is a bit more at the bottom of this e-mail
http://allapi.mentalis.org/agnet/apiguide.shtml

-----
Some basics for VB-6
http://www.bitwisemag.com/copy/vb/vb_graphics1.html

-----
-----
This next group might help with the API declares, especially since
I seem to recall that the short 'More Information' blurbs only
tended to expose the tip of the iceberg:
-----

More information:
GDI32Bas.bas contains all of the Types, Constants, and declares,
(that are) available for using GDI32.dll in your applications.

http://www.freevbcode.com/ShowCode.Asp?ID=1458

-----
More information:
This demo application illustrates usages of a number of different
GDI API functions, such as CreateCompatibleDC, BitBlt,
SelectObject, SetPixelV, and (many) more.

http://www.freevbcode.com/ShowCode.Asp?ID=2691

-----
More information:
One of the easier ways to draw a line using pixels,
in this case SetPixel of the GDI, this program demonstrates how
to draw a line with X1, Y1, X2, Y2 parameters the code is very well
quoted (commented), if you have a decent mathematical background,
you may easily catch-up with the idea.

http://www.freevbcode.com/ShowCode.Asp?ID=6365

-----
More information:
This is a .dll that implements a sizable rectangle.
Use for drawing borders, among other things, and
(it is) an excellent example of advanced GDI programming.

http://www.freevbcode.com/ShowCode.Asp?ID=2504

-----
Over at Google using VB6 GDI as the search term
brings up a wealth of resources, most notably
the ones that explain how much easier all of this
work becomes when we use VB dot Net.
-----

http://www.vbaccelerator.com/home/index.asp

Steve McMahon has a great deal of information
at his web site, about many things, but
GDI and GDI Plus items are also available:

http://www.vbaccelerator.com/home/VB/Tips/index.asp?page=2

This next item has .bas code/declares that can be copied...

Creating a new GDI Bitmap from a VB Picture or DC:
If you're creating some code which works with VB but draws with
the more powerful GDI functions, it's often very handy to be
able to create a new bitmap handle from a VB StdPicture object or
from an area of a DC. This article demonstrates how to do this
with a few lines of GDI code.

http://www.vbaccelerator.com/home/VB/Tips/Creating_a_new_GDI_Bitmap_from_a_V
B_Picture_or_DC/article.asp

or
http://tinyurl.com/32hm56

-----
Of course, this list would not be worthwhile if we failed
to mention our friends over at the KPD Team...

http://allapi.mentalis.org/vbtutor/tutmain.shtml

API-Guide
(current version: 3.7.854, released on 2002/03/31)

API-Guide has over 900 functions, all documented, and explained
with an example. Several functions also have a dotNET equivalent
and dotNET example code.

http://allapi.mentalis.org/agnet/apiguide.shtml

Also available is the On-Line APIs listing:
http://allapi.mentalis.org/apilist/apilist.php

-----
Karl E. Peterson - http://vb.mvps.org
OMG ! The new look is 3 or 4 years old < g >
This site is totally devoted to Classic Visual Basic,
as millions once knew and loved it.
This is a certifiably .NET-Free zone.
-----

Randy Birch:
http://vbnet.mvps.org/code/forms/gradientfill.htm

http://vbnet.mvps.org/code/forms/gradientfilltriangle.htm

-----

Bryan Stafford
http://www.mvps.org/vbvision/

-----

Take care,
Steve
.
Sent out around
1150: EST on Thursday, March 06, 2008
.

-----Original Message-----
From: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com [mailto: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com]
On Behalf Of Adelle Hartley
Sent: Wednesday, March 05, 2008 8:35 PM
To: helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com
Subject: Re: [helpwithvb] Re: Logical OR as mask for changing case

Brian Shieldhouse wrote:
&gt;
> Thanks Adelle but I can't see any of this in VB5. However I found the
> following passage on the net: "the box is drawn with a technique that
> uses the XOR graphics function. As the box is drawn, the underlying
> pixels are essentially "flipped" to their opposite color. Drawing the
> box a second time "flips" the pixels to their original color, thereby
> erasing the box." Even in VB5 I can draw a line and choose its colour,
> so the same technique might work if I could establish what the
> "opposite" colour is. Any ideas ? Or am I chasing rainbows ?

This example uses GDI -
the subsystem in Windows which is responsible for graphics.
( Win 2000 and Win XP or above only, but MS has a d/l for earlier OSes)

It's air code. You need to declare the api functions used.

The basic pattern for using GDI is
1. Create the pen and or brush or other object that you need.
2. Select the pen and or brush or other object into a device context
(represented by a "device context handle&quot; aka "hdc&quot;).
3. Do some drawing.
4. Select the "original" pen/brush/whatever that
was/were current before you started.
(SelectObject returns a handle to the current pen/brush/whatever).
5. Delete the objects you created.
6. Restore any other state that you changed along the way.

Dim hOldRop As Long
Dim hOldPen As Long

' 0. Change the current raster operation for the dc.
hOldRop = SetROP2(hdc, R2_NOTXORPEN)

' 1. Create the pen that we need.
hPen = CreatePen(PS_DOT, Width, &H101010)

' 2. Select the newly created pen into the dc.
hOldPen = SelectObject(hdc, hPen)

' 3. Do some drawing.
' Coordinates is an array of POINT structures
' (a structure known to the VB6 API viewer as POINTAPI).
Polyline hdc, Coordinates(0), UBound(Coordinates)&#43;1

' 4. Select the original pen.
SelectObject hdc, hOldPen

' 5. Delete the objects that we created.
DeleteObject hPen

' 6. Restore any other state that we changed.
SetROP2 hdc, hOldRop

The magic is in step 0.

Adelle.
.
.

__._,_.___
.

__,_._,___
RE: Win32 GDI APIs Where They Be Hiding
country flaguser name
United States
2008-03-06 12:18:49

>> It's air code.
>>; You need to declare the API functions used.

>>&gt;Didn't appreciate, when I started this list, that I needed
>>&gt;some mindless 'Veg-Out' time, so this little list became
>>&gt;some what larger than I had intended at the start < g >

Win32 GDI API’s are veg-out for you?

Whewww!! You either must either be working on high velocity particle physics or the IRS Tax code all day long to consider the subject of APIs vegging-out.

Each to his own…  ;)

/tr

 

 

 




__._,_.___
.

__,_._,___
[1-10] [11-15]

about | contact  Other archives ( Real Estate discussion Medical topics )