2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2006 - INRIA - Allan CORNET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
15 #include "api_scilab.h"
16 #include "localization.h"
18 #include "warningmode.h"
19 /*--------------------------------------------------------------------------*/
20 extern int C2F(intsave)(); /* fortran subroutine */
21 /*--------------------------------------------------------------------------*/
22 int sci_save(char *fname, unsigned long fname_len)
34 //filename or file descriptor
35 sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
38 printError(&sciErr, 0);
42 sciErr = getVarType(pvApiCtx, piAddr1, &iType1);
45 printError(&sciErr, 0);
49 if (iType1 == sci_strings)
59 for (i = 2 ; i <= Rhs ; i++)
61 sciErr = getVarAddressFromPosition(pvApiCtx, i, &piAddrI);
64 printError(&sciErr, 0);
68 sciErr = getVarType(pvApiCtx, piAddrI, &iTypeI);
71 printError(&sciErr, 0);
75 if (iTypeI != sci_strings)
81 sciErr = getVarDimension(pvApiCtx, piAddrI, &iRowsI, &iColsI);
84 printError(&sciErr, 0);
88 if (iRowsI != 1 || iColsI != 1)
94 if (getAllocatedSingleString(pvApiCtx, piAddrI, &pstVarI))
99 //try to get variable by name
100 sciErr = getVarAddressFromName(pvApiCtx, pstVarI, &piAddrI2);
103 // Try old save because here the input variable can be of type "string" but not a variable name
104 // Ex: a=""; save(filename, a);
115 freeAllocatedSingleString(pstVarI);
119 //call "overload" to prepare data to export_to_hdf5 function.
120 C2F(overload) (&lw, "save", (unsigned long)strlen("save"));
131 //new -> %_export_to_hdf5
135 if (getWarningMode())
137 sciprint(_("WARNING: Scilab 6 will not support the file format used.\n"));
138 sciprint(_("WARNING: Please quote the variable declaration. Example, save('myData.sod',a) becomes save('myData.sod','a').\n"));
139 sciprint(_("WARNING: See help('save') for the rational.\n"));
146 /*--------------------------------------------------------------------------*/