Was this helpful?
Variable Usage
Fortran variables declared to EQUEL can substitute for most elements of EQUEL statements that are not keywords. Of course, the variable and its data type must make sense in the context of the element. The generic uses of host language variables in EQUEL statements are discussed further in the QUEL Reference Guide. The following discussion covers only the usage issues particular to Fortran language variable types.
You must verify that the statement using the variable is in the scope of the variable's declaration. For a discussion of variables in an EQUEL/Fortran program, see The Scope of Variables. As an example, the following retrieve statement uses the variables "namvar" and "numvar" to receive data, and the variable "idno" as an expression in the where clause:
## retrieve (namvar = employee.empname,
##           numvar = employee.empnum) where
##           employee.empnum = idno
Simple Variables
The following syntax refers to a simple scalar-valued variable (integer, floating-point, or character string):
simplename
Syntax Notes:
If you use the variable to send values to Ingres, the variable can be any scalar-valued variable.
If you use the variable to receive values from Ingres, the variable can only be a scalar-valued variable.
The following example shows a message handling routine. It passes two scalar-valued variables as parameters: buffer, which is a character string, and secs, which is an integer variable.
## subroutine PrtMsg(buffer, secs)
## declare forms
## character*(*) buffer
## integer secs

## message buffer
## sleep secs

## end
Array Variables
The following syntax refers to an array variable:
arrayname (subscripts)
Syntax Notes:
Subscript the variable because only scalar-valued elements (integers, floating-point, and character strings) are legal EQUEL values.
The EQUEL preprocessor does not evaluate subscript values when the array is declared and referenced. Consequently, even though the preprocessor confirms that array subscripts have been used, it accepts illegal subscript values. You must make sure that the subscript is legal. For example, the preprocessor accepts both of the following references, even though only the first is correct:
## real salary(5) 
C  declaration

## APPEND TO employee (esal = salary(1)) 
C   Correct reference
## APPEND TO employee (esal = salary(-1)) 
C  Incorrect reference
Do not subscript arrays of variable addresses that are used with param target lists. For example:
## character*200 target 
## integer*4 addr(10) 

C Array of variable addresses

## RETRIEVE (PARAM (target, addr))
For more information about parameterized target lists, see Dynamically Built Param Statements.
The following example uses the variable "i" as a subscript. However, the variable does not need to be declared to EQUEL because array subscripts are not parsed or evaluated.
UNIX:
## character*8  frnams(3) 
   integer        i

   data         frnams /'empfrm', 'dptfrm'. 'hlpfrm'/

   do 10 i = 1, 3 
##    FORMINT frnams(i) 
10    continue 1 

VMS:
##  character*8 formnames(3) / 'empfrm', 'deptform', 
'helpform'/
integer i

do i=1,3
## Forminit formnames(i)
end do  

Windows:
##    declare
##    character*8 formnames(3)/'empfrm','deptform','helpform'/
##    declare forms
       integer i
       character*(*) active
       do i=1,3
       active = formname(i)
##    Forminit active
       end do  
Structure Variables - VMS only
You cannot use a structure variable as a single entity. Only elementary structure members can communicate with Ingres data. This member must be a scalar value (integer, floating-point, or character string).
Using a Structure Member
The syntax EQUEL uses to refer to a structure member is the same as in Fortran:
structure.member{.member}
Syntax Notes:
The structure member the above reference denotes must be a scalar value (integer, floating-point or character string). There can be any combination of arrays and structures, but the last object referenced must be a scalar value. Thus, the following references are all legal in an EQUEL statement, assuming they all translate to scalar values:
      employee.sal 
C     Member of a structure
      person(3).name 
C     Member of an element of an array 
      structure.mem2.mem3.age 
C     Deeply nested member
In general, the preprocessor supports unambiguous and fully qualified structure member references.
Using Indicator Variables
The syntax for referring to an indicator variable is the same as for a simple variable, except that an indicator variable is always associated with a host variable:
host_variable:indicator_variable
Syntax Note:
The indicator variable can be a simple variable, an array element or a structure member that yields a short integer. For example:
## integer*2    indvar, indarr(5)
     var_1:indvar
     var_3:indarr(2)
Last modified date: 06/10/2024