static bool import_boolean(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
{
    int iRet = 0;
    int *piData = NULL;
    int iDims = 0;
    int* piDims = NULL;
    int iComplex = 0;
    int iSize = 0;
    SciErr sciErr;

    iRet = getDatasetInfo(_iDatasetId, &iComplex, &iDims, NULL);
    if (iRet < 0)
    {
        return false;
    }

    piDims = (int*)MALLOC(sizeof(int) * iDims);
    iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, piDims);

    if (iSize == 0)
    {
        FREE(piDims);
        return false;
    }

    piData = (int *)MALLOC(iSize * sizeof(int));
    iRet = readBooleanMatrix(_iDatasetId, piData);
    if (iRet)
    {
        FREE(piData);
        FREE(piDims);
        return false;
    }

    if (_piAddress == NULL)
    {
        sciErr = createNamedMatrixOfBoolean(pvCtx, _pstVarname, piDims[0], piDims[1], piData);
    }
    else                        //if not null this variable is in a list
    {
        sciErr = createMatrixOfBooleanInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, piDims[0], piDims[1], piData);
    }

    FREE(piDims);
    if (piData)
    {
        FREE(piData);
    }

    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return false;
    }

    return true;
}
Beispiel #2
0
int putBoolean(char *variableName, BOOL * variable, int nbRow, int nbCol)
{
    SciErr sciErr;

    sciErr = createNamedMatrixOfBoolean(NULL, variableName, nbRow, nbCol, variable);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return -1;
    }
    return 0;

}
Beispiel #3
0
/*--------------------------------------------------------------------------*/
int createNamedScalarBoolean(void* _pvCtx, const char* _pstName, int _iBool)
{
	SciErr sciErr; sciErr.iErr = 0; sciErr.iMsgCount = 0;

	sciErr = createNamedMatrixOfBoolean(_pvCtx, _pstName, 1, 1, &_iBool);
	if(sciErr.iErr)
	{
		addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_BOOLEAN, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarBoolean");
		printError(&sciErr, 0);
		return sciErr.iErr;
	}

	return 0;
}
static bool import_boolean_v1(int* pvCtx, int _iDatasetId, int _iItemPos, int *_piAddress, char *_pstVarname)
{
    int iRet = 0;
    int *piData = NULL;
    int iRows = 0;
    int iCols = 0;
    SciErr sciErr;

    iRet = getDatasetDims_v1(_iDatasetId, &iRows, &iCols);
    if (iRet)
    {
        return false;
    }

    if (iRows * iCols == 0)
    {
        return false;
    }
    piData = (int *)MALLOC(iRows * iCols * sizeof(int));
    iRet = readBooleanMatrix_v1(_iDatasetId, iRows, iCols, piData);
    if (iRet)
    {
        FREE(piData);
        return false;
    }

    if (_piAddress == NULL)
    {
        sciErr = createNamedMatrixOfBoolean(pvCtx, _pstVarname, iRows, iCols, piData);
    }
    else                        //if not null this variable is in a list
    {
        sciErr = createMatrixOfBooleanInNamedList(pvCtx, _pstVarname, _piAddress, _iItemPos, iRows, iCols, piData);
    }

    FREE(piData);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return false;
    }

#ifdef PRINT_DEBUG
    char pstMsg[512];

    sprintf(pstMsg, "boolean_%d (%d x %d)", _iItemPos, iRows, iCols);
    print_tree(pstMsg);
#endif
    return true;
}