Skip to main content

$MVTRANS

Reads field data from a MultiValue file.

Synopsis

$MVTRANS(mvfile,recID,fieldno,code)

Parameters

Argument Description
mvfile The name of a MultiValue file defined in the VOC, specified as a quoted string. If there are multiple data files, you can specify mvfile as either "dirname,datafile" or simply "datafile".
recID The record ID of the desired record, specified as an integer.
fieldno Either an integer or a non-numeric string. If an integer, fieldno specifies the field number of the field to be read, or, if -1, returns the contents of the entire record. This usage is compatible with most MultiValue systems. If a non-numeric string, fieldno specifies an attribute to look up in the file's dictionary. If that attribute is a “D” data defining entry, $MVTRANS looks up the data using the corresponding field number recorded in the dictionary. This usage is compatible with UniData systems.
code A letter code that specifies what to do if the requested record does not exist. This letter code must be specified as a quoted string.

Description

The $MVTRANS function returns a field value from a MultiValue file. Unlike a READ statement, you do not have to use the OPEN statement to open the MultiValue file before issuing a $MVTRANS.

The code parameter determines how $MVTRANS should respond when you request an invalid field. The following are valid letter codes:

"X" Return an empty string if the specified record or field cannot be located.
"V" Return an empty string and generate an error message if the specified record or field cannot be located.
"C" Return the recID value if the specified record or field cannot be located.
"N" Return the recID value if the specified field value is null.

The ObjectScript $MVTRANS function corresponds to the Cache MultiValue Basic TRANS function.

Examples

The following examples illustrates the use of the $MVTRANS function. Because TEST.FILE does not exist, each returns the error value dictated by its code parameter:

  SET mydyn=$MVTRANS("TEST.FILE",6,1,"X")
  WRITE !,"the field value:",mydyn
  SET mydyn=$MVTRANS("TEST.FILE",6,1,"V")
  WRITE !,"the field value:",mydyn
  SET mydyn=$MVTRANS("TEST.FILE",6,1,"C")
  WRITE !,"the field value:",mydyn

See Also

  • TRANS function in the Caché MVBasic Reference

  • READ statement in the Caché MVBasic Reference

  • STATUS statement in the Caché MVBasic Reference

  • Dynamic Arrays in the Caché MVBasic Reference

FeedbackOpens in a new tab