2.1.13.18 okoc_binary_mat_export


Description

Export a matrix object to a binary file without header. Data in the matrix will be written out in exact same way as internal storage of row-major order

Syntax

int okoc_binary_mat_export( LPCSTR lpcszRangeMat, LPCSTR lpcszPath, LPCSTR lpcszExt, string * pstrActualFilename, LPCSTR lpcszFilenamePrefix = NULL )

Parameters

lpcszRangeMat
[input] matrix object to be exported, empty string or NULL to use active matrix object
lpcszPath
[input] path to save the file
lpcszExt
[input] file extension without the '.'
pstrActualFilename
[output] actual fullpath file name for the exported file. It will be in the form of
abc218x256.b2d where abc is the lpcszFilenamePrefix and 218 the number of columns and 256 number of rows
lpcszFilenamePrefix
[input] optional filename prefix, if not given, matrix book short name will be used.

Return

0 if no error, otherwise <0 error codes

Examples

EX1

#include <okocUtils.h>
//make sure there is an active matrixsheet with data in it.
void okoc_binary_mat_export_ex1()
{
	MatrixLayer ml = Project.ActiveLayer();
	if ( ml )
	{
		MatrixObject mo(ml, 0);
		string strRange;
		if ( mo.GetRangeString(strRange) )
		{
			string strFile = "XX.b2d";
			int nErr = okoc_binary_mat_export(strRange, GetAppPath(true), "txt", &strFile, "MTX_");
			if ( nErr == 0 )
				printf("File %s save successfully.\n", strFile);
		}
	}
}

Remark

See Also

okoc_mat_binary_import

Header to Include

okocUtils.h

Reference