[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Nested Ifs (was Procedures)
- Subject: Re: Nested Ifs (was Procedures)
- From: "Dombrowski, Dave F" <David_Dombrowski@LORD.COM>
- Date: Fri, 14 Jul 2000 08:02:17 -0400
IMHO Evaluates are best suited to situations involving a single variable
with 3 or more branches based on it's value. The nested If Jason used
evaluates 3 variables (x, y and z) with only 2 branches for each. Trying to
make this situation understandable through an Evaluate would be tough.
Which brings me to maybe _the_ most important point - readability! Sure,
'modern' programmers frown upon GoTo statements... but sometimes the
simplest way to maintain something is with that! Visual Basic - one of the
more 'modern' event-driven languages - still requires GoTo statement for
error handling (unless you can count on a RaiseEvent to be recognized by the
client). I understand VB7 will change this, but for today, one of the most
prevalent procedure-based languages uses it all the time.
GoTo has it's own purpose: directing flow _out_ of an area. I'd never use it
to jump to a routine, but to jump out of one I certainly do (like error
handling). So why not also use it to exit out of a group of non-nested
unrelated If statements?
JMHO.
-----Original Message-----
From: Jason Gill [mailto:Jason.Gill@WELLPOINT.COM]
Sent: Thursday, July 13, 2000 4:45 PM
To: SQR-USERS@list.iex.net
Subject: Re: Nested Ifs (was Procedures)
> Anyone want to make an argument for that vs. GOTO vs. nested IFs?
Sure. If it is not the same variable being evaluated. I've had this
situation but can't remember the actual variables involved. Below is a
simplified example. But I agree that most times if it is just reacting to
various values of #x, an evaluate is the easiest.
begin-procedure nested-ifs
If #x = 1
!do something only if x = 1 that means you don't care about Y or Z
anymore
goto ENDPROC
else
If #y = 2
!do x=1 and y=2 thing, which means you don't care about Z
anymore
goto ENDPROC
else
!do x=1 but y <> 2 thing, but you still care about Z
end-if
if #z = 3
!do x <> 1 and z = 3 thing
else
!do x <> 1 and z <> 3 thing
end-if
el
end-if
ENDPROC:
end-procedure