duplicate variable error

Posted by Admin on 24-Feb-2009 23:26

hi..im using 9.1d....im very new to progress development...i am having this error messages, which i can't figure out why..

i have a importtable.w with a simple case statement

CASE lc-filename:

WHEN "cp-bldmas" THEN DO:

{ut/utimportall.i "cp-bldmas" "tt-bldmas"

"cp-bldmas.cpm-bldno = tt-bldmas.cpm-bldno"}


WHEN "cp-floor" THEN DO:

{ut/utimportall.i "cp-floor" "tt-floor"

"cp-floor.cpf-bldno = tt-floor.cpf-bldno and ~

cp-floor.cpf-level = tt-floor.cpf-level"}


but on complie it throws an error stating that 'duplicate variable name li-i...plz not that li-i has been declared in the definitions section as:


def var li-i as int no-undo.

and the include file is accessing this li-i variable for various purposes....please note that if i comment out the 2nd when..then statement in the case statement then the program runs without error, but when i put the 2 when..then statement together then the error is thrown...any suggestion where am i getting it wrong??

All Replies

Posted by Thomas Mercer-Hursh on 25-Feb-2009 00:58

Sure sounds like there is a variable declaration in that include. How about listing the include for us. If there is any variable declaration in that include, the error is expected and correct.

FWIW, includes are questionable design elements in modern ABL,

Posted by Admin on 25-Feb-2009 00:59

It's hard to suggest anything knowing more about the code or the include file utimportall.i.

Some general thoughts on issues like this:

Unlike other languages like C# or Java a DO block does not scope variable declarations. The only blocks scoping variable declarations are routine-level blocks: .p file, .w file, class block, internal procedures/functions and methods/getters/setters. None of the loop blocks scopes variable declarations. Even the CATCH block does not scope a variable/input parameter declaration which was a bit confusing in the beginning to me.

The easiest way to track down compile errors where you don't see the cause directly is to generate a preprocessor listing:

Then open that file in the procedure editor and press SHIFT-F2 for a syntax check. The file will contain all include files embedded with their parameters translated into a single file.

That should help you find the duplicate definition. Usually the SHIFT-F2 should jump to the line causing the error.

Posted by Admin on 26-Feb-2009 00:15

cool...thanks for the tips to all...i found the bug in the include file...there was a variable definition in there..somehow...

This thread is closed