_Rformat ()- 設定記錄格式名稱
格式
#include <recio.h>
void _Rformat(_RFILE *fp, char *fmt);語言層次
ILE C 延伸
安全執行緒
是
工作 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 );
}