BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Continue ?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Walker
Guest





PostPosted: Wed Dec 10, 2003 2:06 pm    Post subject: Continue ? Reply with quote



In an application I have now for the first time tried using the Continue
statement.

It seems, however, I get some backwards results.

for LoopPar:=1 to 100 do
begin
<something>

if LoopPar and 1>1 then
Continue;

<something else>
end;

When is <something else> supposed to be processed ?
If LoopPar is odd or if it is even ?

Back to top
René Larsen
Guest





PostPosted: Wed Dec 10, 2003 6:55 pm    Post subject: Re: Continue ? Reply with quote



In article <3FD72849.F886A36C (AT) sol (DOT) dk>, Walker wrote:
Quote:

In an application I have now for the first time tried using the Continue
statement.

It seems, however, I get some backwards results.

for LoopPar:=1 to 100 do
begin
something

if LoopPar and 1>1 then
Continue;

"LoopPar and 1>1" is the same as "(LoopPar and 1)>1". The expression
"LoopPar and 1" returns 0 or 1, neither of which can ever be >1.

It should be replaced with:
if (LoopPar and 1) = 1 then // odd?
or:
if (LoopPar and 1) = 0 then // even?

You could also use the Mod() function:
if (LoopPar mod 2) = 1 then // odd?
if (LoopPar mod 2) = 0 then // even?

Hope this helps.

Regards, René


Back to top
Jud McCranie
Guest





PostPosted: Wed Dec 10, 2003 6:56 pm    Post subject: Re: Continue ? Reply with quote



On Wed, 10 Dec 2003 19:55:06 +0100, René Larsen
<rene.larsen (AT) spamfilter (DOT) dk> wrote:

Quote:
"LoopPar and 1>1" is the same as "(LoopPar and 1)>1". The expression
"LoopPar and 1" returns 0 or 1, neither of which can ever be >1.

It should be replaced with:
if (LoopPar and 1) = 1 then // odd?
or:
if (LoopPar and 1) = 0 then // even?

You could also use the Mod() function:
if (LoopPar mod 2) = 1 then // odd?
if (LoopPar mod 2) = 0 then // even?

or better:
if odd( LoopPar) then ...
or
if not odd( LoopPar) then ...


Back to top
Rob Kennedy
Guest





PostPosted: Wed Dec 10, 2003 7:52 pm    Post subject: Re: Continue ? Reply with quote

Jamie wrote:
Quote:
if Boolean(LoopPar and 1) then...

Please do not type cast numeric expressions to Boolean. It doesn't
always work as you might expect. It relies on the knowledge -- it
assumes -- that the Boolean values of True and False are stored
internally with byte values of $01 and $00, respectively.

--
Rob

Back to top
Jamie
Guest





PostPosted: Wed Dec 10, 2003 10:38 pm    Post subject: Re: Continue ? Reply with quote

u r not correctly setting the loop for the AND section.
there are a couple of ways.
if loopPar and 1 <> 0 then.
or
if Boolean(LoopPar and 1) then...


Walker wrote:

Quote:
In an application I have now for the first time tried using the Continue
statement.

It seems, however, I get some backwards results.

for LoopPar:=1 to 100 do
begin
something

if LoopPar and 1>1 then
Continue;

something else
end;

When is <something else> supposed to be processed ?
If LoopPar is odd or if it is even ?



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.