B Code

The B code allows mvBASIC subroutines to process data from within an Attribute Definition item. Two forms of the B code are supported.

Format

B;[file.name] sub.name

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.

The first form passes data to the subroutine, and receives data from the subroutine a single value at a time. This form of the B code 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.

The second form of the B code 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 this form of the B code is used, it must be specified on line 8 of the Attribute Definition item. This form of the B code may not be included with the A or F correlatives, or within a series of multiple conversion codes.

Description

When using either form of the B code, 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

In the following example, an index is created 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 next example is the mvBASIC subroutine INX:

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 these rules:

See Also

Deriving Data from Attributes

C Code

Extracting Data

S Code

Testing Data

Manipulating Existing Data