Introduction to the REQL Language | Functions |
This chapter provides examples and details for the language constructs included in REQL.
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;
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.
break
for x <: para;
{
if (sum((state in x)) > 100);
{
show x;
break;
}
}
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:
clear;
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;
The close command closes the active shell.
close
open shell;
close;
Used in for and while loops, the continue command branches immediately to the beginning of the innermost loop.
continue
for x <: para;
{
if (sum((state in x)) > 100);
continue;
show x;
}
The delete command removes the specified variable.
delete variable
To remove the user variable ioState:
delete ioState;
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:
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;
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);
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;
}
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;
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;
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)
continue;
if (j==7)
break; show j;
}
delete j;
Yields:
2
3
5
6
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 | 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 |
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" |
The REQL language provides the special reserved variables described in the following table.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Introduction to the REQL Language | Functions |