PreviousIntroduction to the REQL Language FunctionsNext

Chapter 12: Language Constructs

This chapter provides examples and details for the language constructs included in REQL.

12.1 break

The break command exits out of for and while loops. Break exits the innermost nested loop.

Syntax

break

Example

for x <: para;
{
if (sum((state in x)) > 100);
{
show x;
break;
}
}


12.2 continue

Used in for and while loops, the continue command branches immediately to the beginning of the innermost loop.

Syntax

continue

Example

for x <: para;
{
if (sum((state in x)) > 100);
continue;
show x;
}


12.3 delete

The delete command removes the specified variable.

Syntax

delete variable

Example

To remove the user variable ioState:

delete ioState;


12.4 for

The for command performs a REQL command or a list of commands over an entire set. With every iteration, the user variable is assigned the next element of the domain set. If the domain set is preceded by an "@" sign, then the set is recalculated with each iteration; this provides a powerful mechanism for doing breath-first searching.

Syntax

for uservar <: set reql_command ;

for uservar <: set { reql_command ; reql_command;.........}

for uservar <: @set { reql_command ; reql_command;.........}

Examples

The following query shows the paragraphs which have more than 100 statements:

for x <: para;
{
if (sum((state in x)) > 100);
{
show x;
}
}

The following query determines every paragraph that is executed during the execution of the paragraph named 1200-DETAIL:

vSetPara:=cobol_label_para="START-SCREEN-PROCESSA";

for vPara<:@vSetPara{

show red vPara;

vSetPara:=(vSetPara&(cobol_label_para usedin vPara));

vSetPara:=(vSetPara&(cobol_label_section usedin vPara));

}

delete vSetPara;


12.5 if

The if command executes a REQL command or a list of commands only if "condition" evaluates to TRUE. An optional else qualifier causes the execution of a list of REQL commands only if the condition evaluates to FALSE.

Syntax

if condition reql_command ;

if condition { reql_command ; ........}

if condition reql_command; else reql_command;

if condition { reql_command; .........} else { reql_command; ..... }

Examples

To print "You have selected a big variable:" if the physical memory required for the selected variable exceeds 10000 bytes:

if (selected:>attr_size > 10000);
{
show "You have selected a big variable:",selected:>attr_name;
}

The following example displays a message for any size of variable:

if (selected:>attr_size > 10000){
show "you have selected a bigvariable:",selected:>attr_name;
} else {
show "you have selected a smallvariable:",selected:>attr_name;
}


12.6 open

The open command opens tools or views based on the specified type and scope.

Syntax

open <icon> codeflow|dataview|shell|screen|sourceview|inventory

Examples

To open the Code Flow view as icons:

open icon codeflow;

To open Screen view:

open screen;


12.7 scope

The scope feature focuses the analysis on a specific item or group of items in your project.

Syntax:

scope:=components of interest

Example:

To set the scope of the analysis to include all components in entire project:

scope:=all

To set the scope to the selected group or category that is displayed at the bottom of the Shell tool:

scope:=selected

To view the scope:

show scope;

12.8 show

The show command is the work horse of REQL. It displays sets, elements, variables, strings and numbers. If a color is specified to highlight sets and elements, the optional "%" sign specifies the justification (default is left justified and + is right justified) and field length.

Syntax

show <color> <%|%+number> set|element|variable|number|string, ....

The string "/t" will produce a tab stop, and "/n" will produce a new line. A new line is automatically added after each show command. The /" allows you to put the quote character in a string. These special instructions can be imbedded in text strings.

Examples

To list the paragraphs containing go statements, and highlight them in blue in open tools or views:

show blue (para having go);

To display some metrics in a column format:

show %10 program:>lines, %10 sum(state);

To display the same metrics on separate lines:

show program:>lines, "/n", sum(state);

To display some metrics separated by tabs:

show; x:>name,"/t",division_id:>lines,"t",division_environment:>lines;

To display all of the attributes and relationships associated with the selected element:

show selected:>relation;


12.9 while

The while command executes a list of REQL commands until the "condition" evaluates to FALSE.

Syntax

while condition reql_command ;

while condition { reql_command ; ........}

Example

j :=1;
while (j<10) {
j :=(j+1);
if (j==4)
continue;
if (j==7)
break; show j;
}
delete j;

Yields:

2

3

5

6


12.10 Special Tokens

The following section describes Operators, Symbols, and Special Variables that are by some REQL tasks.

12.10.1 Operators

The REQL language provides the operators that are described in the following table.

Operator
Example
Description
+ n1 :=(n2+n3) Addition
- n1 :=(n2-n3) Subtraction
& set1 :=(set2 & set3) Set Union
^ set1 :=(set2 ^ set3) Set Intersection
~ set1 :=(set2~set3) Set Subtraction
== if (n1==n2) {} Equal To
<> if (n1<>n2) {} Not Equal To
> if (n1>n2) {} Greater Than
< if (n1<n2) {} Less Than
:>and:< show para="A5":> usedin or var="*DATE*":<of Denotes forward and backward chaining
::>and<:: var::>level="1" or (var::of in para)="*SALES*" Denotes forward and backward scanning
&& if ((j==5)&&(i==10)) Logical And
|| if ((j==5) || (i==10)) Logical Or
! if (!(j==10)) Logical Not

12.10.2 Symbols

The syntax of REQL uses the following symbols:

Symbol
Description
Example
// Indicates a comment. //Display number of statements
# Indicates that the line will be echoed to the Shell when processed. #show "Comany ABC Report"
<: Iterates through a set. for x < :para {}
@ Reevaluates a set at each iteration. for x,: @para {}
; Delimits a list of commands. if (n=5) {show x;show y;}
() Sets precedence. show ((para having go)&(move))
() Delimits function parameters. show (para having (go & move))
* Indicates a wildcard. show var="WS-*":<of
% Sets left justification and field width. show %10 program:>name
%+ Sets right justification and show field width. %+10 program:>name
< Inverts a relationship. show var="WS-*":<of
. Delimits a partial type name. cobol.para
, Separates an argument. show "Name" ,x:>name
"" Delimits a string. show "Number of statements"

12.10.3 Special Variables

The REQL language provides the special reserved variables described in the following table.

Name
Variable Type
Description
all set Signifies a set of all the elements in every component, regardless of the scope. The use of the all variable is restricted to the clear all and scope:=all commands.
color color Used in highlighting. Also found on User tab.
echo string Controls echo to the shell and can be assigned "on" or "off."
F1-F12 string Represents a function key. If that function key is pressed, the string value of the variable will be processed as a query.
scope set Focuses on a set of components. For example: scope:=cics_state will set the scope of the query to all CICS components displayed under the CICS folder in the Project Manager.
selected element Used to identify an object across different windows. For example, you can select something in the Shell tool and view the item in a corresponding Source view window. For example, selected :=component="BATCH1.CBL"; makes BATCH1.CBL the selected component. Its name is displayed at the bottom of the Desktop. This same functionality is available when you right click an item in a tool or view and choose Select on the speed menu.


Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousIntroduction to the REQL Language FunctionsNext