ILE C/C++ Run-Time Library Functions


_Rformat() -- Set the Record Format Name

Format

#include <recio.h>
 
void  _Rformat(_RFILE *fp, char *fmt);

Language Level: ILE C Extension

Threadsafe: Yes.

Description

The _Rformat() function sets the record format to fmt for the file specified by fp.

The fmt parameter is a null-ended C string. The fmt parameter must be in uppercase.

Note:
The fmt parameter string must be EBCIDIC, even if the program is compiled using LOCALETYPE(*LOCALEUTF).

The _Rformat() function is valid for multi-format logical database, DDM files, display, ICF and printer files.

Return Value

The _Rformat() function returns void. See Table 12 and Table 14 for errno settings.

Example that uses _Rformat()

This example shows how _Rformat() is used.


#include <stdio.h>
#include <recio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void)
{
  char       buf[40];
  int        rc = 1;
  _RFILE     *purf;
  _RFILE     *dailyf;
 
  /* Open purchase display file and daily transaction file          */
  if ( ( purf = _Ropen ( "MYLIB/T1677RD3", "ar+,indicators=y" )) == NULL )
  {
      printf ( "Display file did not open.\n" );
      exit ( 1 );
  }
 
  if ( ( dailyf = _Ropen ( "MYLIB/T1677RDA", "wr,commit=y") ) == NULL )
  {
      printf ( "Daily transaction file did not open.\n" );
      exit ( 2 );
  }
 
  /* Select purchase record format */
  _Rformat ( purf, "PURCHASE" );
 
  /* Invite user to enter a purchase transaction.                   */
  /* The _Rwrite function writes the purchase display.              */
  _Rwrite ( purf, "", 0 );
  _Rreadn ( purf, buf, sizeof(buf), __DFT );
 
  /* Update daily transaction file                                  */
  rc = (( _Rwrite ( dailyf, buf, sizeof(buf) ))->num_bytes );
 
  /* If the databases were updated, then commit the transaction.    */
  /* Otherwise, rollback the transaction and indicate to the        */
  /* user that an error has occurred and end the application.       */
  if ( rc )
    {
        _Rcommit ( "Transaction complete" );
    }
  else
    {
        _Rrollbck ( );
        _Rformat ( purf, "ERROR" );
    }
 
  _Rclose ( purf );
  _Rclose ( dailyf );
}

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]