Coding Requirements for Writing EQUEL Programs
The following sections describe coding requirements for writing EQUEL programs.
Comments Embedded in Ada Output
Each EQUEL statement generates one comment and a few lines of ADA code. You may find that the preprocessor translates 50 lines of EQUEL into 200 lines of Ada. This may result in confusion about line numbers when you are debugging the original source code. To facilitate debugging, each group of Ada statements associated with a particular statement is preceded by a comment corresponding to the original EQUEL source. (Note that only executable EQUEL statements are preceded by a comment.) Each comment is one line long and informs the reader of the file name, line number, and type of statement in the original source file.
Ada Blocks Generated by EQUEL
EQUEL statements that are associated with a block of code delimited by the braces { and }, or begin and end, are called block-structured statements. All the EQUEL block-structured statements generate Ada blocks. If there is no code contained in the block, EQUEL may need to generate the Ada null statement, depending on the type of Ada block generated. Consequently, if you do want an empty block, do not place just an Ada comment inside it (without the ## to delimit the comment), because the preprocessor would consider the comment to be Ada host code and would treat the block as a block containing Ada code.
For example, to disable the scrolling down of a table field, you might mistakenly code the following activate block:
## activate scrolldown employee -- this example contains
-- an error
##
-- Disable scrolling of table field
##
The Ada comment in the block is considered Ada host code, and therefore, the null statement is not generated. This would later cause an Ada compiler syntax error. To resolve this situation, you must either let EQUEL know that the statement is only a comment, so that it will generate the null statement, or else code the null statement explicitly. The above example should be written as:
## activate scrolldown employee
##
## -- Disable scrolling of table field
##
or
## activate scrolldown employee
##
-- Disable scrolling of table field
null;
##
An EQUEL Statement that Does Not Generate Code
The declare cursor statement does not generate any Ada code. This statement should not be coded as the only statement in Ada constructs that does not allow null statements. For example, coding a declare cursor statement as the only statement in an Ada if statement not bounded by left and right braces would cause compiler errors:
if (using_database)
## declare cursor empcsr for retrieve (employee.ename)
else
put-line("You have not accessed the database");
end if;
The code generated by the preprocessor would be:
if (using_database)
else
put_line("You have not accessed the database");
end if;
which is an illegal use of the Ada if-then-else statement.
Last modified date: 08/28/2024