Page 1 of 1

plugins.file.writeFile warning

PostPosted: Tue Nov 15, 2011 9:33 pm
by Peter de Groot
Hi all,

in some global method I have the following :

/**
* @properties={typeid:24,uuid:"356B5A2A-2FED-4A76-99CB-7D5316BAC33D"}
* @param {String} $pdfName
* @param {Array} $pdf
*/
function gen_pdf($pdfName, $pdf) {

var $fileName = plugins.file.createTempFile($pdfName, '.pdf');

plugins.file.writeFile($fileName,$pdf);
application.executeProgram('rundll32', 'url.dll,FileProtocolHandler', $fileName);
}

but on the line plugins.file.writeFile($fileName,$pdf); there is this warning,
The function writeFile(Object,Array<byte>,[?]) is not applicable for the arguments (JSFile,Array)

what's wrong with the method above, when I run this method the expected pdf is generated, I'm using Servoy 6.0.3

Regards,

Peter

Re: plugins.file.writeFile warning

PostPosted: Thu Nov 17, 2011 5:13 pm
by david
writeFile doesn't use the file suffix parameter like createTempFile does. Should be a string (not an array) specifying the mime type.

Re: plugins.file.writeFile warning

PostPosted: Thu Nov 17, 2011 9:12 pm
by Peter de Groot
David,

Move the sample that comes with plugins.file.writeFile it gives the same warning.

Regards,
Peter

Re: plugins.file.writeFile warning

PostPosted: Tue Nov 22, 2011 11:10 am
by jcompagner
i will update the sample code by doing this:

/** @type {Array<byte>}*/
var bytes = new Array();


thats also what you need to do, its a array of bytes that it want to have, not just an array..

Re: plugins.file.writeFile warning

PostPosted: Tue Nov 22, 2011 1:55 pm
by Peter de Groot
jcompagner wrote:i will update the sample code by doing this:

/** @type {Array<byte>}*/
var bytes = new Array();



Hmm, I overlooked that in the documentation, thanks for the reply.

Peter