plugins.file.writeFile warning

Questions, tips and tricks and techniques for scripting in Servoy

plugins.file.writeFile warning

Postby Peter de Groot » Tue Nov 15, 2011 9:33 pm

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
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: plugins.file.writeFile warning

Postby david » Thu Nov 17, 2011 5:13 pm

writeFile doesn't use the file suffix parameter like createTempFile does. Should be a string (not an array) specifying the mime type.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: plugins.file.writeFile warning

Postby Peter de Groot » Thu Nov 17, 2011 9:12 pm

David,

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

Regards,
Peter
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: plugins.file.writeFile warning

Postby jcompagner » Tue Nov 22, 2011 11:10 am

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..
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: plugins.file.writeFile warning

Postby Peter de Groot » Tue Nov 22, 2011 1:55 pm

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
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...


Return to Methods

Who is online

Users browsing this forum: No registered users and 10 guests