_Rformat ()- 设置记录格式名称

格式

#include <recio.h>

void  _Rformat(_RFILE *fp, char *fmt);

语言级别

ILE C 扩展

线程安全

作业 CCSID 接口

发送到此函数的所有字符数据都应该使用作业的 CCSID。 此函数返回的所有字符数据都使用作业的 CCSID。 请参阅 了解 CCSID 和语言环境 以获取更多信息。

描述

对于 fp指定的文件, _Rformat() 函数将记录格式设置为 fmt

fmt 参数是以 null 结束的 C 字符串。 fmt 参数必须为大写。

_Rformat() 功能对多格式逻辑数据库, DDM 文件,显示器, ICF 和打印机文件有效。

返回值

_Rformat() 函数返回 void。 请参阅 表 1表 1 以获取 errno 设置。

示例

此示例显示如何使用 _Rformat()
#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 );
}

相关信息