I've written a script in V2 that prints labels on a Zebra printer. Currently, I write the ZPL codes to a text file, then
Run an external DOS utility to send the file to a printer. It works well, but I would like to have the script self contained. When I came across this Printers class, I was quite excited. I've been trying to convert it to V2, but I'm still in the very early stages of learning DLLCalls.
@jNizM, have you by any chance converted this to V2, or could you perhaps give me a couple of pointers?
Take for example, this code segment:
Code: Select all
GetDefault()
{
if !(DllCall("winspool.drv\GetDefaultPrinter", "ptr", 0, "uint*", size))
{
size := VarSetCapacity(buf, size << 1, 0)
if (DllCall("winspool.drv\GetDefaultPrinter", "str", buf, "uint*", size))
return buf
}
return false
}
V2 is throwing up warnings about
size not having been defined, even if I turn warnings off. V1 (I think) treated an undefined variable as null, but threw no errors. What should the value of
size be - zero or null or empty string?
"Size" first appears early in the method here:
Code: Select all
if !(DllCall("winspool.drv\GetDefaultPrinter", "ptr", 0, "uint*", size))
and I get a warning about it.
I understand that I need to change
Code: Select all
size := VarSetCapacity(buf, size << 1, 0)
to
but there's that "size" again, this time left shifted. What value, exactly, is shifted one bit to the left?
Any insight would be greatly appreciated.
Russ