[comp.databases] dBASE IF/ENDIF

awd@dbase.UUCP (Alastair Dallas) (07/13/89)

In article <8178@bsu-cs.bsu.edu>, mithomas@bsu-cs.bsu.edu (Michael Thomas Niehaus) writes:
> I have a question that maybe some dBase IV person can answer.  Let's say that
> I have the following chunk of dBase code:
> 
> T="this is a test"
> IF T="this is not a test" THEN	&& <-- THEN is a syntax error [ad]
>     @10,10 say "Inside the if"
> ENIF  && Notice the misspelling
> @11,10 SAY "Outside the if"
> RETURN
> 
> Now, with dBase III+, this will assign "this is a test" to T, check the
> condition, find that it doesn't hold true, and look for a corresponding
> ENDIF.  Now, if it doesn't find one, it just quits.  No error messages
> or anything.  This same problem arises when you have not nested blocks
> (anything with an END) correctly.
> 
> Can anyone tell me what dBase IV does with this?  If it returns an error
> message, I would switch instantly.  The number of headaches would be instantly
> reduced.  There is only one good thing that dBase III+ forces you to do:
> indent properly.  If you don't do that, you're going to be spending a lot
> of time trying to line up ENDs.
> 
> -Michael

Welcome to dBASE IV--you don't have to switch instantly; anytime this week
will be fine.  Yes, dBASE IV checks all flow of control statements at
compile time and issues appropriate errors, rather than "falling off the
end" the way dBASE III PLUS does.

After removing the extraneous THEN, your code produces:

ENIF
Error on line 4: *** Unrecognized command verb

Error on line 8: Missing ENDIF for previous IF command

Hope that helps make your purchase decision easier :-)

/alastair/