2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2006 - INRIA - Allan CORNET
4 * Copyright (C) 2009 - DIGITEO - Allan CORNET
5 * Copyright (C) 2010 - DIGITEO - Antoine ELIAS
6 * Copyright (C) 2011 - DIGITEO - Cedric DELAMARRE
8 * Copyright (C) 2012 - 2016 - Scilab Enterprises
10 * This file is hereby licensed under the terms of the GNU GPL v2.0,
11 * pursuant to article 5.3.4 of the CeCILL v.2.1.
12 * This file was originally licensed under the terms of the CeCILL v2.1,
13 * and continues to be available under such terms.
14 * For more information, see the COPYING file which you should have received
15 * along with this program.
18 /*--------------------------------------------------------------------------*/
19 #include "filemanager.hxx"
20 #include "fileio_gw.hxx"
24 #include "function.hxx"
29 #include "localization.h"
31 #include "charEncoding.h"
34 /*--------------------------------------------------------------------------*/
35 types::Function::ReturnValue sci_mputstr(types::typed_list &in, int _iRetCount, types::typed_list &out)
37 int iFile = -1; //default file : last opened file
38 types::String* pString = NULL;
41 types::Double* pdFileId = NULL;
43 if (in.size() < 1 || in.size() > 2)
45 Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), "mputstr", 1, 2);
46 return types::Function::Error;
49 if (in[0]->isString() == false || in[0]->getAs<types::String>()->isScalar() == false)
51 Scierror(999, _("%s: Argument #%d: a single string expected.\n"), "mputstr", 1);
52 return types::Function::Error;
55 pString = in[0]->getAs<types::String>();
59 if (in[1]->isDouble() == false || in[1]->getAs<types::Double>()->isScalar() == false || in[1]->getAs<types::Double>()->isComplex())
61 Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), "mputstr", 2);
62 return types::Function::Error;
64 iFile = static_cast<int>(in[1]->getAs<types::Double>()->get(0));
70 Scierror(999, _("%s: Wrong file descriptor: %d.\n"), "mputstr", iFile);
71 return types::Function::Error;
73 iErr = mputl(iFile, pString->get(), 1, FALSE);
76 out.push_back(new types::Bool(!iErr));
78 return types::Function::OK;
80 /*--------------------------------------------------------------------------*/