Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to organise IF statements on a long page.

Status
Not open for further replies.

timtom

Programmer
Jul 12, 2001
78
GB
While writing a flexitime system for employees, I god-knows-how-managed to get through a submit_clock_in page, but now am suffering existentially over submit_clock_out.

Basically, there are lots of IFS and ELSES.
Is the password right?
Are they clocking out early?
Have they given a reason for clocking out early?
Are they definitely clocked in?

All this is easy to ascertain with Ssql statements, but the page is making me blind and it's doing the wrong things.

Is there ANY way to NUMBER an if statement so you can definitely match it up with the right END IF?

IF not THEN (hmm) is there a recommended standard for organising it all. I do all that indenting code stuff, but it doesn't help me much.
Thanks
Sarah




User_timtom.jpg
WASN'T FIT ENOUGH FOR THE POLICE FORCE
 
Yes, that's a solution for me thanks Lobstah, but I'm wondering more if there's a way to number the statements for the Computer... I've never been taught, or I've never learnt what the protocol is when you have one IF statement inside another. How does it know which END is which?

I have the vague sinking feeling that I sound very stupid here.
User_timtom.jpg
WASN'T FIT ENOUGH FOR THE POLICE FORCE
 
It looks for the end if.

If blah = blah then
blah blah blah
If var = var then
blah blah blah
else
blah blah blah
end if
end if

Whenever you have an if statement you need to close it with an end if in VBscript. In other languages this is done with the {}, such as:

If blah = blah
{
blah blah;
}
else
{
blah blah;
}

No end if for the example above. The {} takes care of that.
 
when you have nested if statements, it just takes the next end statement to end that if....

If then '1
If then '2
If then '3
End If '3
If then '4
End If '4
End If '2
End If '1

I don't know of any way to number the code aside from comments though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top