Does anybody know how to copy a file binary in Java script??
in Dos the syntax is:
copy /b sourcefile destination
Youll probably wonder why I want to do this well Im 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.
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
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.