Share this page

# lrd_to_printable

Converts a variable to a printable string.

    LRDRET lrd_to_printable( LRD_VAR_DESC *mptVarDesc, unsigned long muliIndex, char *mpszOutputStr, unsigned long muliOutputStrSize, char *mpszOutputStrFmt );

mptVarDesc | A pointer to the descriptor of the variable being converted.
muliIndex | The index of the element to be converted in an array (zero for a simple variable).
mpszOutputStr | A pointer to the area to contain the returned string.
muliOutputStrSize | The amount of storage allocated for the result string.
mpszOutputStrFmt | A pointer to a string specifying the output format. Only LRD_OUTPUT_STR_FMT_DFLT is available.

The lrd_to_printable function converts a variable or an array element to a printable string. This function is generated during recording in the print.inl file located in the script directory. It provides information on how to display the results in VuGen's grid.

lrd_to_printable is used in the automatically generated PrintRow<N> functions in print.inl that are passed as callback functions to lrd_fetch* functions. lrd_to_printable converts the data only if the the Log runtime settings `Extended log` and `Data returned by server` are set. They can be set in the script by ORing the current log level with LR_MSG_CLASS_EXTENDED_LOG and LR_MSG_CLASS_RESULT_DATA. See the example.

When you access data using lrd_bind_col, you use lrd_to_printable to convert data that cannot be printed in its original type (for example a fixed length character string that is not null-terminated). You must repeat this function for every row that is retrieved by lrd_fetch.

When you access data with lrd_col_data, you call lrd_to_printable to convert the data into a printable string, regardless of the data type.

For more details refer to the Function Header File lrd.h in the include directory.

## Return Values

See LRD Return Values.

## Parameterization

You cannot use standard parameterization for any arguments in this function.

## Example

In the following example, lrd_to_printable tells VuGen to display two columns in the grid. In the first column it displays the NAME and in the second column it displays the ID.

The first segment shows the recorded script in the Actions section. The second segment shows the corresponding section (PrintRow14) in the print.inl file generated during recording.

Copy code

     /* Actions section from run.c */
    unsigned int msg;
    lrd_stmt(Csr1, "select * from Employees", -1, 1, 1, 0);
    lrd_bind_col(Csr1, 1, &NAME_D11, 0, 0);
    lrd_bind_col(Csr1, 2, &ID_D12, 0, 0);
    lrd_exec(Csr1, 0, 0, 0, 0, 1);
    /* Set the log level to enable lrd_to_printable
        before the lrd_fetch */
    msg = lr_get_debug_message();
    lr_set_debug_message
      (msg|LR_MSG_CLASS_EXTENDED_LOG|LR_MSG_CLASS_RESULT_DATA,
      LR_SWITCH_ON);
    lrd_fetch(Csr1, -3, 15, 0, PrintRow14, 0);
    /* Restore the log level */
    lr_set_debug_message(msg, LR_SWITCH_ON);

| NAME_D11 | ID_D12
--- | --- | ---
1 | Kim Smith | 200
2 | Janet Jones | 201
3 | Annette Taylor | 202

Copy code

     / * PrintRow1 section from print.inl. */
    LRD_PRINT_ROW_PROTO(PrintRow14)
    {
     LRDRET gjLRDRet = LRDRET_I_OK;
     char szNAME_D11[256];
     char szID_D12[256];
    lrd_to_printable(&NAME_D11, muliRowIndex, szNAME_D11, 256, "");
    lrd_to_printable(&ID_D12, muliRowIndex, szID_D12, 256, "");
     lr_debug_message(LR_MSG_CLASS_RESULT_DATA, "%s, %s", szNAME_D11, szID_D12);
     return gjLRDRet;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: