Operating System - OpenVMS
1752782 Members
6318 Online
108789 Solutions
New Discussion юеВ

Re: %DCL-E-INVIFNEST, invalid IF-THEN-ELSE nesting structure or data inconsistency

 
John Gillings
Honored Contributor

Re: %DCL-E-INVIFNEST, invalid IF-THEN-ELSE nesting structure or data inconsistency

More than likely this is due to a mismatched nesting structure somewhere between your GOTO and the target label.

A simple check for consistency in your IF-THEN-ELSE-ENDIF structures is to use SEARCH:

$ SEARCH your-procedure "IF","THEN","ELSE","ENDIF"

If you're disciplined with indentation, a mismatched block should be fairly easy to spot.

Something to watch out for is the absence of a leading "$" in the lines containing your structure verbs. For example:

$ IF condition
$ THEN
$ command
$ ENDIF

is correct, but

$ IF condition
THEN
$ command
$ ENDIF

(note missing "$" on the "THEN" verb) will fail with INVIFNEST.
A crucible of informative mistakes
John McL
Trusted Contributor

Re: %DCL-E-INVIFNEST, invalid IF-THEN-ELSE nesting structure or data inconsistency

It might also be that there's a faulty construct somewhere between your IF statement and the label that you are going to.

I can't recall what the DCL parser does in the way of skipping over subroutines and I only vaguely recall that it searches forward for a statement label and then if not found, it wraps back to the start - or has this changed??

Do you, for example, have a SUBROUTINE statement without an ENDSUBROUTINE?

The DCL_CHECK.COM utility mentioned by someone else above should be able to identify these problems. (Their name has disappeared so I can't identify them without some effort.)

By the way, how is your code going to LOOP_DISK: when it has an error condition rather than a warning ? Have you said ON ERROR THEN CONTINUE ?
Debasis Bhar
Occasional Advisor

Re: %DCL-E-INVIFNEST, invalid IF-THEN-ELSE nesting structure or data inconsistency

Thanks for all suggestions. These was an extra endif in between GOTO and LOOP_DISK. I removed it and now script is working fine.