PreviousIntroduction to the REQL Language FunctionsNext

Chapter 13: Language Constructs

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

13.1 activate

The activate shell command will bring an existing shell to the foreground or will open a shell if one is not open.


activate shell


Open a new shell:

activate shell;

13.2 break

The break command exits out of for and while loops. Break helps reduce the number of iterations of a for command over a large set. Break exits the innermost nested loop.




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

13.3 clear

The clear command unhighlights the specified element, set, variable, color, or clears the active shell.


clear set|element|variable|color|shell


To clear the color "yellow" from any open tools or views:


To clear the set of paragraphs that contain the string READ in their name:

clear para="*READ*";

To unhighlight everything:

clear all;

To clear the text in the shell:

clear shell;

13.4 close

The close command closes the active shell.




open shell;


13.5 continue

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




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

13.6 delete

The delete command removes the specified variable.


delete variable


To remove the user variable ioState:

delete ioState;

13.7 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.


for uservar <: set reql_command ;

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

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


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:


for vPara<:@vSetPara{

show red vPara;

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

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


delete vSetPara;

13.8 high

The high command highlights the specified element, set or variable in the specified color.


high set|element|variable

high color set|element|variable


To highlight the user variable ioState in "red":

high red ioState;

To highlight in "yellow" the modifications of all variables ending in ID:

high yellow (mod of var="*NAME");

To highlight usages of copybooks in the default color:

high(usage of copybook);

13.9 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.


if condition reql_command ;

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

if condition reql_command; else reql_command;

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


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;

13.10 open

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


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


To open the Code Flow view as icons:

open icon codeflow;

To open Screen view:

open screen;

13.11 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.


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.


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;

13.12 while

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


while condition reql_command ;

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


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






13.13 Special Tokens

13.13.1 Operators

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

+ 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 D enotes 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

13.13.2 Symbols

The syntax of REQL uses the following symbols:

// 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"

13.13.3 Special Variables

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

Variable Type
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 © 1999 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