Copyfile Binair with Java Script

Questions, tips and tricks and techniques for scripting in Servoy

Copyfile Binair with Java Script

Postby Rene » Wed Jan 28, 2004 9:15 pm

Hello Everyone,

Does anybody know how to copy a file binary in Java script??
in Dos the syntax is:
copy /b sourcefile destination

You`ll probably wonder why I want to do this well I`m making a database which also contains pathnames of .tiff files (drawings) and because a tif file is a printable format you can copy it binair direct into a printerqueue without any driver or userinterferance. It is a very fast and simple procedure the output is the original (tiff) size when possible or else fit to papersize.
When you just copy the file into a printerqueue you`ll get a lot of pages containing ascii rubish.

ps. for some newer printers/multifunctionals it is also possible to copy pdf files into the printerqueue.

Using or omitting the /B switch when copying to a device

When destination is a device (for example, COM1 or LPT1), the /B switch
causes MS-DOS to copy data to the device in binary mode. In binary mode, all
characters (including such special characters as CTRL+C, CTRL+S, CTRL+Z, and
carriage return) are copied to the device as data. Whereas, omission of the
/B switch causes MS-DOS to copy data to the device in ASCII mode. In ASCII
mode, such special characters as those previously listed may cause MS-DOS to
take special action during the copying process.



Hope that anyone can help me.

Thanks in advance Rene
Rene
 
Posts: 121
Joined: Sat Dec 27, 2003 1:33 pm
Location: Venhorst, The Netherlands

Postby Jan Aleman » Wed Jan 28, 2004 9:23 pm

You can use executeProgram to execute system operating commands.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby Rene » Thu Jan 29, 2004 4:51 pm

Hello Jan,

So this should work
Field:
VT_FilePath contains the value 'O:\TDD\47828_Ooshop\300-399\old_docs\047828-330-40011-EN-B.TIF'

Method:
if ( utils.stringMiddle(application.getOSName(), 1, 7) == "Windows")
{
if (plugins.file.convertStringToJSFile(VT_FilePath.filepath).exists())
{
var VT_Queue = '\\\nlprnserv01\\nljerom-c'
application.executeProgramInBackground('Cmd.exe','copy /b ' + VT_FilePath + ' ' + VT_Queue)
}
}

It doesn't return an error but it doesn't work either

Can you please tell me what I`m doing wrong

Is there by the way another way to copy files binary than with the cmd.exe perhaps its possible with Java or a plugin.
Another challenge for the Servoy Team

Thanks in advance Rene
Rene
 
Posts: 121
Joined: Sat Dec 27, 2003 1:33 pm
Location: Venhorst, The Netherlands

Postby Jan Aleman » Thu Jan 29, 2004 5:04 pm

try to read the result back into a variable so you check in that variable the possible mistake:

var returnedMessage = application.ExecuteProgam.........etc

NOTE that if you execute in the background you obviously can't get the errorcode(s) back unless you write them out to a file.

You can also try to use the file-plugin's copy function to copy files to your queue. I don't know if that will work though. If I recall well the file-plugin is available in the latest 2.0 Release candidate.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby david » Fri Jan 30, 2004 4:35 pm

var VT_Queue = '\\\nlprnserv01\\nljerom-c'
application.executeProgramInBackground('Cmd.exe','copy /b ' + VT_FilePath + ' ' + VT_Queue)


application.executeProgram('Cmd.exe','copy','/b','filepath');

- david
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Postby Rene » Sat Jan 31, 2004 11:49 am

Thanks,

Don`t know yet if it works but I`m gonna try this monday.

Rene
Rene
 
Posts: 121
Joined: Sat Dec 27, 2003 1:33 pm
Location: Venhorst, The Netherlands

Postby Jan Blok » Wed Feb 11, 2004 5:23 pm

The file plugin as shipped with the Servoy 2.0 (beta)version has copyFile function.
Jan Blok
Servoy
Jan Blok
 
Posts: 2684
Joined: Mon Jun 23, 2003 11:15 am
Location: Amsterdam


Return to Methods

Who is online

Users browsing this forum: No registered users and 29 guests

cron