Exemple #1
0
/*--------------------------------------------------------------------------*/
int sci_getio(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt opt, int nout, scilabVar* out)
{

	if (nin != 0)
	{
		Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), fname, 0);
		return 1;
	}

	if (nout != 1)
	{
		Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), fname, 1);
		return 1;
	}

    //get diarys count
    int diary = 0;
    int* diarys = getDiaryIDs(&diary);
    //don't care about ids
    delete[] diarys;

    //create data values array
    std::vector<double> val = {5, 5, (double)diary, 6};
    //create output matrix
    scilabVar var = scilab_createDoubleMatrix2d(env, 1, 4, 0);
    //fill it
    scilab_setDoubleArray(env, var, val.data());
    //return it to scilab
    out[0] = var;
	return 0;
}
/*--------------------------------------------------------------------------*/
double *getDiaryIDsAsDouble(int *array_size)
{
	int *iIDs = getDiaryIDs(array_size);
	if (*array_size > 0)
	{
		if (iIDs)
		{
			double *dIDs = new double[*array_size];
			for(int i = 0;i < *array_size; i++)
			{
				dIDs[i] = (double)iIDs[i];
			}
			delete [] iIDs;
			return dIDs;
		}
		else
		{
			*array_size = 0;
		}
	}
	return NULL;
}