_Rformat() — レコード・フォーマット名の設定
フォーマット
#include <recio.h>
void _Rformat(_RFILE *fp, char *fmt);
言語レベル
ILE C Extension
スレッド・セーフ
はい
ジョブ CCSID インターフェース
この関数に送信される文字データは、すべてジョブの CCSID 内にあると想定されます。この関数によって戻された文字データは、すべてジョブの CCSID 内にあります。 詳細については、CCSID およびロケールの理解を参照してください。
説明
_Rformat() 関数は、 fp で指定されたファイルのレコード・フォーマットを fmt に設定します。
fmt パラメーターは、ヌル終了 C ストリングです。 fmt パラメーターは大文字で指定してください。
_Rformat() 関数は、複数フォーマットの論理データベース、DDM ファイル、 ディスプレイ、ICF およびプリンター・ファイルの場合に有効です。
例
この例では、_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 );
}