Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Nested IF Problem

Author
Message
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 8th Sep 2005 23:57
Hi there,

I've got a problem with a nested IF statement I'm trying to run in one of my programs and can't seem to make sense of the problem.

[/code]
if n(6,3)=0
if n(5,3)=0
if n(6,2)=1
if n(6,1)=1
n(6,1)=2
n(6,2)=2
endif
endif
endif
endif
[code]

What the code is supposed to do is check whether only values (6,1) and (6,2) are =1 and if they are then make them both =2. If (6,3) or (5,3) =1 then it should leave the (6,1) and (6,2) values as they are

The problem I'm getting is that if all of the values are generated as zero then its assigning both (6,1) and (6,2) as =2

Hopefully this isn't too confusing to read!

Any help / comments would be appreciated.

Thanks.
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 8th Sep 2005 23:59
Also, any idea how to put the code in snippets? Lost all my fancy tab formatting in the example above!
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 9th Sep 2005 00:24
Sorted it!

Not a problem with the nested if - changing (6,1) and (6,2) was influencing the code in the main loop and reporting a false result.

Cheers.
Silent Knight
19
Years of Service
User Offline
Joined: 25th Jan 2005
Location: In Your Mind
Posted: 9th Sep 2005 00:39 Edited at: 9th Sep 2005 00:40
like this code?

blah


you start with the code in brackets not /code in brackets
you did this
[/code]
blah
[code]

remember the / means to close something, so it goes at the end.

Version--DB Classic
900 mhz AMD Athlon, 128 MB RAM,
16 MB NVidia Vanta gfx card, Windows ME System software
StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 9th Sep 2005 00:44
Thanks for the reply.

StevetS
20
Years of Service
User Offline
Joined: 19th May 2004
Location:
Posted: 9th Sep 2005 00:45
Thanks M8!

It works!

Cheers.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Sep 2005 02:18
Always line up the if and the endif. That way it's a lot easier to debug. Do the same for do/loop, for/next, and all other loops.

Login to post a reply

Server time is: 2024-09-24 03:25:06
Your offset time is: 2024-09-24 03:25:06