B Correlative

The B correlative allows mvBASIC subroutines to process data from within an Attribute Definition item.

Two forms of the B correlative are supported. The first form passes data to the subroutine, and receives data from the subroutine a single value at a time. The B correlative may appear on line 7 or 8 of the Attribute Definition item; it may be included with A or F correlatives, and within a series of multiple conversion codes.

Format

B;[file.name] sub.name

Parameter(s)

file.name

Specifies the file in which the subroutine resides.

sub.name

Specifies the name of the subroutine.

Description

The second form of the B correlative may be used when multiple values are to be processed as a set rather than a single value at a time. The entire attribute, including all MultiValues and multisubvalues, are passed to the specified subroutine. The subroutine may return a result with MultiValues or multisubvalues. When the second form of the B correlative is used, it must be specified on line 8 of the Attribute Definition item. The B correlative may not be included with the A or F correlatives, or within a series of multiple conversion codes.

Format

B:[file.name] sub.name

Parameter(s)

file.name

Specifies the file in which the subroutine resides.

sub.name

Specifies the name of the subroutine.

Description

When using either form of the B correlative, if file name is specified, the file’s dictionary must contain the compiled object code for the specified subroutine. If file name is not specified, the specified subroutine must be cataloged.

Example

The next example creates an index for a report that is to be generated. The Attribute Definition item for REGION.INDEX and the subroutine shown below create an index file which may be sorted after the report has been generated.

0001 A

0002 12

0003

0004

0005

0006

0007

0008 B;BP INX

0009 L

0010 10

The mvBASIC subroutine INX is:

0001 SUBROUTINE INX

0002 $INCLUDE BASICLIB ACCESS.COMMON

0003 IF NOT (FIRST.TIME) THEN

0004       OPEN ‘INDEX.FILE’ TO INDEX ELSE STOP 201, ‘INDEX.FILE’

0005       FIRST.TIME = 1

0006 END

0007 IF NB$ > 1 THEN

0008       PAGE.NO = SYSTEM(5); * CURRENT PAGE NUMBER

0009       WRITE PAGE.NO ON INDEX, CURRENT$; * WRITE TO FILE

0010 END

0011 RETURN CURRENT$; * RETURN VALUE UNCHANGED

Subroutines used in B correlatives must conform to the following rules:

See Also

Correlatives and Conversions Reference