Printf Record (printf)

The printf record is used to generate and write a string using a format specification and parameters, analogous to the C printf() function.

Parameter Fields

The record-specific fields are described below, grouped by functionality.

Scan Parameters

The printf record has the standard fields for specifying under what circumstances it will be processed. These fields are listed in Scan Fields.

String Generation Parameters

The printf record must specify the desired output string with embedded format specifiers in the FMT field. Plain characters are copied directly to the output string. A pair of percent characters '%%' are converted into a single percent character in the output string. A single precent character '%' introduces a format specifier and is followed by zero or more of the standard printf() format flags and modifiers:

The following character specifies the conversion to perform, see your operating system's printf() documentation for more details. These conversions ultimately call the snprintf() routine for the actual string conversion process, so are subject to the behaviour of that routine.

The fields INP0 ... INP9 are input links that provide the parameter values to be formatted into the output. The format specifiers in the FMT string determine which type of the data is requested through the appropriate input link. As with printf() a * character may be used in the format to specify width and/or precision instead of numeric literals, in which case additional input links are used to provide the necessary integer parameter or parameters. See "Address Specification" for information on specifying links.

The formatted string is written to the VAL field. The maximum number of characters in VAL is given by SIZV, and cannot be larger than 65535. The LEN field contains the length of the formatted string in the VAL field.

FieldSummaryTypeDCT DefaultReadWriteCA PP
FMTFormat StringSTRING [81]Yes YesYesYes
INP0Input 0INLINKYes YesYesNo
INP1Input 1INLINKYes YesYesNo
INP2Input 2INLINKYes YesYesNo
INP3Input 3INLINKYes YesYesNo
INP4Input 4INLINKYes YesYesNo
INP5Input 5INLINKYes YesYesNo
INP6Input 6INLINKYes YesYesNo
INP7Input 7INLINKYes YesYesNo
INP8Input 8INLINKYes YesYesNo
INP9Input 9INLINKYes YesYesNo
VALResultSTRING[SIZV]No YesYesYes
SIZVSize of VAL bufferUSHORTYes41YesNoNo
LENLength of VALULONGNo YesNoNo

Output Specification

The output link specified in the OUT field specifies where the printf record is to write the contents of its VAL field. The link can be a database or channel access link. If the OUT field is a constant, no output will be written.

In addition, the appropriate device support module must be entered into the DTYP field.

FieldSummaryTypeDCT DefaultReadWriteCA PP
OUTOutput SpecificationOUTLINKYes YesYesNo
DTYPDevice TypeDEVICEYes YesYesNo

Operator Display Parameters

See Fields Common to All Record Types for more on the record name (NAME) and description (DESC) fields.

FieldSummaryTypeDCT DefaultReadWriteCA PP
NAMERecord NameSTRING [61]No YesNoNo
DESCDescriptorSTRING [41]Yes YesYesNo

Alarm Parameters

The printf record has the alarm parameters common to all record types. Alarm Fields lists the fields related to alarms that are common to all record types.

The IVLS field specifies a string which is sent to the OUT link if if input link data are invalid.

FieldSummaryTypeDCT DefaultReadWriteCA PP
IVLSInvalid Link StringSTRING [16]YesLNKYesYesNo

Device Support Interface

The record requires device support to provide an entry table (dset) which defines the following members:

 typedef struct {
     long number;
     long (*report)(int level);
     long (*init)(int after);
     long (*init_record)(printfRecord *prec);
     long (*get_ioint_info)(int cmd, printfRecord *prec, IOSCANPVT *piosl);
     long (*write_string)(printfRecord *prec);
 } printfdset;

The module must set number to at least 5, and provide a pointer to its write_string() routine; the other function pointers may be NULL if their associated functionality is not required for this support layer. Most device supports also provide an init_record() routine to configure the record instance and connect it to the hardware or driver support layer.

Device Support for Soft Records

A soft device support module Soft Channel is provided for writing values to other records or other software components.

Device support for DTYP stdio is provided for writing values to the stdout, stderr, or errlog streams. INST_IO addressing @stdout, @stderr or @errlog is used on the OUT link field to select the desired stream.