Hi everybody,
Did someone ever tried to link Navision to a Brother QL-580N labelprinter by using the P-Touch / b-PAC SDK automation (also delivered by Brother) ?
Labels are configured in the P-Touch software and the templates are then used for printing data from Navision.
This could be the code:
CREATE(autLabelDocG);
autLabelDocG.Open('c:\item.lbx'); //This is the template created in P-Touch
intIndexG := autLabelDocG.GetTextIndex('Barcode'); //'Barcode' is a text label in the template
autLabelDocG.SetText(intIndexG,'*'+item."No."+'*'); //'Barcode'-text is now replaced by the item number
autLabelDocG.StartPrint('test',0);
autLabelDocG.PrintOut(1,0);
autLabelDocG.EndPrint;
autLabelDocG.Close;
CLEAR(autLabelDocG);
This works fine if I look at the result coming out of the printer, but Navision crashes every time the code runs.
An "internal error"-message appears (without module-no.).
Strange thing is that the error only occurs when the complete code is executed. So I can debug my complete object (with multiple printouts if needed) and during the last step in my debugger the internal error occurs.
The tests were done on Navision 3.70 and NAV2009.
Does anybody have experience with this ?
Thank you very much in advance for your replies.
Tom
0
Comments
turn on the debugger and see at what line it crashes.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Deleting the CLEAR or close-lines does not solve the problem.
It actually crashes on the last line of the code. So if I add some code now, it will execute everything and crash on the moment that the object is closed.
I tried to simulate 3 print-commands in 1 piece of code. The printer printed 3 labels and navision crashed afterwards.
I have experienced a similar thing. It was with the Excel automation. I was able to fix it with the second parameter in the CREATE statement.
Can you try and create your automation with the second parameter of TRUE.
CREATE(autLabelDocG,TRUE);
This will always create a new instance for your automation.
let us know if that worked.
Regards,
Willy
I'm guessing the print job hasn't finished before you are clearing the variable.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Tom, are you doing anything 'unusual' with the codeunit, the main thing I'm thinking of is passing a copy of a codeunit around and into the codeunit itself. If the last reference to the codeunit goes out of scope while it's being executed the client will crash.
If not then I suppose it's your average corruption problem; if single instancing a link codeunit doesn't work you might try creating an out of process wrapper DLL/EXE. It's slower but at least it cannot crash Navision. Another possibility is to use the VBScript DLL to call your printer DLL, VBScript uses different calling methods that are sometimes more robust against bad DLLs.
TVision Technology Ltd
Thank you very much for your answers. Unfortunately it seems to be impossible to solve the issue directly in Navision.
I created a VBScript to call the printer automation and from Navision I just call the VBScript with a SHELL command.
It's working...but not the most ideal solution :-).