Natural for OpenVMS Version 6.3.12 for OpenVMS
 —  Statements  —

RUN

RUN [REPEAT] operand1 [operand2 [(parameter)]] 40

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

Belongs to Function Group: Invoking Programs and Routines


Function

The RUN statement is used to read a Natural source program from the Natural system file and then execute it.

For Natural Remote Procedure Call (RPC): See Notes on Natural Statements on the Server in the Natural Remote Procedure Call (RPC) documentation.

Top of page

Syntax Description

Operand Definition Table:

Operand Possible Structure Possible Formats Referencing Permitted Dynamic Definition
operand1 C S       A                         yes no
operand2 C S A G   A U N P I F B D T L   G   yes no

Syntax Element Description:

Syntax Element Description
REPEAT
REPEAT Option:

RUN REPEAT causes the program not to prompt the user for input until the program has finished executing even if multiple output screens (produced by INPUT statements) are produced.

This feature may be used if the program is to display multiple screens of information without having the user respond to each screen.

operand1
Program Name:

As operand1 the name of the program can be specified as an alphanumeric constant or as the content of an alphanumeric variable. If a variable is used, it must be 8 characters in length.

The program may be stored in the current library or in a concatenated library (default steplib is SYSTEM). If the program is not found, an error message is issued.

The program is read into the source program work area and overlays any current source program.

operand2
Parameters:

The RUN statement may also be used to pass parameters to the program to be run. A parameter may be defined with any format. The parameters are converted to a format suitable for a corresponding INPUT field. All parameters are placed on the top of the Natural stack.

The parameters can be read using an INPUT statement. The first INPUT statement issued will result in the insertion of all parameters into the fields specified in the INPUT statement. The INPUT statement must have the sign specification (session parameter SG=ON) for parameter fields defined with numeric format.

If more parameters are passed than are read by the next INPUT statement, the extra parameters are ignored. The number of parameters may be obtained with the system variable *DATA.

Note:
If operand2 is a time variable (format T), only the time component of the variable content is passed, but not the date component.

parameter
Date Format:

If operand2 is a date variable, you can specify the session parameter DF (described in the Parameter Reference) as parameter for this variable.

Top of page

Dynamic Source Text Creation/Execution

The RUN statement may be used to dynamically compile and execute a program for which the source or parts thereof are created dynamically.

Dynamic source text creation is performed by placing source text into global variables and then referring to these variables by using an ampersand (&) instead of a plus sign (+) as the first character of the variable name in the source text. The content of the global variable will be interpreted as source text when the program is invoked using the RUN statement.

A global variable with index must not be used within a program that is invoked via a RUN statement.

It is not allowed to place a comment or an INCLUDE statement in a global variable.

Top of page

Example

Program containing RUN statement:

** Example 'RUNEX1': RUN (with dynamic source program creation)         
************************************************************************
DEFINE DATA                                                             
GLOBAL                                                                  
  USING RUNEXGDA                                                        
LOCAL                                                                   
1 #NAME (A20)                                                           
1 #CITY (A20)                                                           
END-DEFINE                                                              
*                                                                       
INPUT 'Please specify the search values:' //                            
      'Name:' #NAME /                                                   
      'City:' #CITY                                                     
*                                                                       
RESET +CRITERIA     /* defined in GDA 'RUNEXGDA'                        
*                                                                       
IF #NAME = ' ' AND #CITY = ' '                                          
  REINPUT 'Enter at least 1 value'                                      
END-IF                                                                  
*                                                                    
IF #NAME NE ' '                                                      
  COMPRESS 'NAME' ' =''' #NAME '''' INTO +CRITERIA LEAVING NO        
END-IF                                                               
IF #CITY NE ' '                                                      
  IF +CRITERIA NE ' '                                                
    COMPRESS +CRITERIA 'AND' INTO +CRITERIA                          
  END-IF                                                             
  COMPRESS +CRITERIA ' CITY =''' #CITY '''' INTO +CRITERIA LEAVING NO
END-IF                                                               
*                                                                    
RUN 'RUNEXFND'                                                       
*                                                                    
END                                                              

Program RUNEXFND executed by RUN statement:

** Example 'RUNEXFND': RUN (program executed with RUN in RUNEX1)        
************************************************************************
DEFINE DATA                                                             
GLOBAL                                                                  
  USING RUNEXGDA
LOCAL                                                                   
1 EMPLOY-VIEW VIEW OF EMPLOYEES                                         
  2 NAME                                                                
  2 CITY                                                                
END-DEFINE                                                              
*                                                                       
* &CRITERIA filled with  "NAME = 'xxxxx' AND CITY = 'xxxx'"             
*                                                                       
FIND NUMBER EMPLOY-VIEW WITH &CRITERIA                                  
     RETAIN AS 'EMP-SET'                                            
DISPLAY *NUMBER                                                         
*                                                                       
END                                                                    

Global Data Area RUNEXGDA:

Global    RUNEXGDA  Library SYSEXSYN                      DBID    10 FNR    32
Command                                                                     > +
I T L  Name                             F Length     Miscellaneous             
All -- -------------------------------- - ---------- ------------------------->
     1 +CRITERIA                        A         80               

Top of page