HP 3000 Manuals

Virtuoso Code Generator Enhancements [ COMMUNICATOR 3000/XL - REL. 2.0 (A.30.00) ] MPE/iX Communicators


COMMUNICATOR 3000/XL - REL. 2.0 (A.30.00)

Virtuoso Code Generator Enhancements 

by Trude Ko 
Data and Languages Division 

The A.02.02 version of the Virtuoso Code Generator introduces the
following enhancements:

WHILE CONSTRUCT 

This new WHILE construct allows users to loop over a series of statements
while a conditional expression is true.  The conditional expression
should eventually evaluate as false, otherwise the Virtuoso Code
Generator will be in an endless loop.  Note that the WHILE construct does
not introduce a new scope.

Example 

     #LET a = 1
     #WHILE a < 5
        #LET a = a + 1
     #ENDWHILE

                          << The loop would be performed 4 times as it >>
                          << evaluates false the fifth time and hence  >>
                          << will not be performed.                    >>

RETURN CONSTRUCT 

This new construct allows users to exit from a FOR or WHILE loop.  It
also allows users to exit an INCLUDE file or MACRO. If the FOR, WHILE,
INCLUDE or MACRO is nested, then control will return to the next
outermost level.

Example 

       #LET a = 1
       #WHILE a < 5
         #LET a = a +1
         #If a = 3
        #RETURN
         #ENDIF
       #ENDWHILE

                         << The second time thru the loop the IF  >>
                         << statement evaluates true and it would >>
                         << exit from the WHILE loop.             >>

     #FOR image-dataset="MAILDS" record="?" relclass="contains"
        #FOR record="!record" element="?" relclass="contains"
           #IF element="NAME"
               #RETURN
           #ENDIF
        #ENDFOR
        Display !record.
     #ENDFOR

                         << The exit from the inner FOR loop      >>
                         << would only occur if an element NAME   >>
                         << was retrieved. The process will then  >>
                         << continue with the outer FOR loop.     >>

FOR CONSTRUCT ENHANCEMENT 

The enhancement to the FOR construct allows the retrieval of all
relationships of a given relationship type, or all entities of a given
entity type.  The present FOR construct retrieves all relationship
occurrences of a specified relationship type from the system dictionary.
It is required that at least one entity name be specified.  The enhanced
FOR construct now provides the following additional functionality:

 *  It allows the flexibility of specifying a "?" for all entity names.
    Now it is possible to retrieve all relationship occurrences of a
    specified relationship type.

 *  It is also possible to retrieve all entities of a given entity type.
    The keyword NUMENTS will contain the number of entities retrieved
    during the FOR loop.

Example 

     #FOR image-database=? image-dataset=? relclass="contains"
     ......

     #ENDFOR
                       << This retrieves all relationships of   >>
                       << the specified relationship type which >>
                       << are owned by the current scope.       >>

     #FOR element=?   attr=(byte-length)
     ......

     #ENDFOR
                       << This retrieves all elements in the    >>
                       << dictionary and their byte-length      >>
                       << attribute. After the completion of    >>
                       << the loop, the keyword NUMENTS         >>
                       << contains the number of entities       >>
                       << retrieved.                            >>

     #FOR element="address"   attr=(byte-length)
     ......

     #ENDFOR
                       <<  This retrieves the byte-length       >>
                       <<  attribute for ADDRESS.               >>

GETENT CONSTRUCT ENHANCEMENT 

The GETENT construct has been enhanced to include a new keyword NUMENTS.
It does not return an error when the entity does not exist.  Instead it
sets NUMENTS to zero which can be checked to see if the entity exists or
not.  When an entity has been retrieved successfully, it is kept in the
internal symbol table.

LET CONSTRUCT ENHANCEMENT 

The enhancement to the LET construct allows arithmetic operations.  The
present LET construct only allows the assignment of a value to a keyword.
The enhanced LET construct allows the integer arithmetic operations.  The
order in which the various operands are applied in evaluating the
expression is determined in the following manner:

 *  Parentheses are executed first.

 *  Following the execution of the parentheses, any multiplication
    or division in the expression is executed.  If consecutive
    multiplications and/or divisions are specified, each operation is
    performed from left to right.

 *  Next, if addition or subtraction is specified, the addition or
    subtraction is executed.  As with multiplication and division, if any
    consecutive combination of these operators is used, the order of
    execution is from left to right.

IF CONSTRUCT ENHANCEMENT 

The present IF construct only allows the relational operators like "=",
"<>", ">", "<", ">=", and "<=".  The enhanced IF construct adds the
ability to connect relations with the logical connector AND or OR. The
AND connector will be evaluated first before the OR connector.  If equal
precedence, the whole statement will be evaluated from left to right.

Example 

     #LET A=1
     #IF (A>5) or (A=1)
         print "correct"
     #ELSE
         print "wrong"
     #ENDIF

                      << Checks for certain values            >>

     #LET A=1
     #WHILE (A<5)
        #IF (A>2) and (A<4)
           print A
        #ENDIF
        #LET A=A+1
     #ENDWHILE
                      << Inside a WHILE loop, take actions     >>
                      << based upon A being in a certain range >>

     #LET desired-city="Cupertino"
     #FOR state="California" city=? relclass="contains"
        #IF (city=desired-city) or (city="unknown")
            print state
        #ENDIF
     #ENDFOR

                      << Can compare strings                   >>

OPTION CONSTRUCT AND INFO STRING ENHANCEMENTS 

The OPTION construct and INFO string have been enhanced to allow the
construct character to be changed from the default of "#" through the new
keyword CONSTRUCTCHAR. The construct character can be changed to "@" by
specifying CONSTRUCTCHAR="@" in the OPTION construct of the GENTEXT or
"CONSTRUCTCHAR='@'" in the INFO string of the RUN command.  After any of
the statements specified above, the generator will recognize the
beginning of a Virtuoso construct by looking for the specified construct
character.  Only one character at a time can be used for the construct
character.

Example 

     #OPTION constructchar="$"
     #LET A=5
     $LET A=6
     #LET A=5

                        << A will have value 6, since any         >>
                        << statement not beginning with $ will    >>
                        << not be treated as a Virtuoso statement >>

PRINTKEYWORDS ENHANCEMENT 

The PRINTKEYWORDS construct has been enhanced to provide the following
features:

 *  It is now sensitive to the #if construct

 *  It provides the option to print keywords from the current or previous
    scope, or print only certain keywords specified by the users.  Note
    that the three options cannot be used in combination.  Only one at a
    time may be used.

If a keyword is not found in the current scope, its value will come from
the closest previous scope in which it is defined.

Example 

     #IF switch   = "DEBUG"
     #PRINTKEYWORDS
     #ENDIF
                      << Keywords will be printed only if switch >>
                      << equals "DEBUG".                         >>

     #PRINTKEYWORDS keyword=(A,B,C)

                   << Only the keywords A,B, and C will be printed   >>

     #PRINTKEYWORDS scope=current

                   << All the keywords from the current scope will   >>
                   << be printed.  The keywords from preceding       >>
                   << scopes will not be printed.                    >>

     #PRINTKEYWORDS scope=previous

                  << All the keywords from the previous scope will    >>
                  << be printed.  The keywords from preceding         >>
                  << scopes or the current scope will not be printed. >>

SECTION CONSTRUCT ENHANCEMENT 

This enhancement allows the SECTION construct to be used within the ENTRY
construct.  The only restriction is that there must eventually be a
SECTION construct that is not within an ENTRY construct so that the
entries will be assigned to some location.

Example 

     #ENTRY name="ent1ofsec1" section="sec1"
     #SECTION name="sec2"
     This is from ent1ofsec1
     #ENDENTRY

     #ENTRY name="ent1ofsec2" section="sec2"
     This is from ent1ofsec2
     ENDENTRY

     #SECTION name="sec1"

     GENOUT will look like:

     This is from ent1ofsec2
     This is from ent1ofsec1

The following shows an example that will cause an error:

     #ENTRY name="ent1" section="sec1"
        #SECTION name="sec1"
     #ENDENTRY

                 << This will give an error of "undefined     >>
                 << sections", since the code never specifies >>
                 << an actual location to move the code to.   >>

ENTRY CONSTRUCT ENHANCEMENT 

The ENTRY construct has been enhanced to allow unnamed entries within a
section.  The ENTRY construct no longer requires the "NAME=" keyword.
The keywords can be any string value.  If only the "SECTION=" keyword is
specified, the generator will create a sequential unique entry name.
These unnamed entries will be grouped together at the beginning of the
specified section followed by any explicitly named entries.

DESCRIPTION CONSTRUCT ENHANCEMENT 

The DESCRIPTION construct has been enhanced so that blanks in the
"COMMENT=" string are not suppressed.  Note that the leading spaces in a
"COMMENT=" string will be preserved.  The continuation character "&" will
result in a blank in the output text.  Therefore, do not break a word
with the continuation character when the line needs to be continued.

     ****************************************************************
     Begin comment with a blank
     ****************************************************************
     #description  comment=" This is a program to perform the update&
     #to the ORDERS database"

     GENOUT will look like:
     *********************************************************
     Begin comment with a blank
     *********************************************************
     * This is a program to perform the update to the ORDERS
     *database

     The example below shows the result of splitting words:

     ****************************************************************
     Multi-line comment with word splits
     ****************************************************************
     #DESCRIPTION  comment="Transaction to perform an upd&
     #ate to the ORDERS database. Two screens are displ&
     #ayed which allow a data entry operator to enter the information"

     GENOUT will look like:
     ****************************************************************
     Multi-line comment with word splits
     ****************************************************************
     *Transaction to perform an upd ate to the ORDERS database. Two
     *screens are displ ayed which allow a data entry operator to enter
     *the information



MPE/iX Communicators