Jump to content

Problems Printing


daserraf
 Share

Recommended Posts

Hi guys,

I have this problem printing this is my code the first time i click on the print button it works but if i click the print button again i get an error. Any ideas?

This is the error "(437) : ==> Subscript used with non-Array variable."

Thanx for the help !

Frank

#include <GuiConstants.au3>
#include 'printMGv2.au3'    ;the print UDF

Global $hp,$selected_picking_slip_depot
Local $mmssgg,$marginx,$marginy
$hp = _PrintDllStart($mmssgg);this must always be called first
if $hp = 0 then
    consolewrite("Error from dllstart = " & $mmssgg & @CRLF)
    Exit
endif

GUICreate("My GUI")       ; will create a dialog box that when displayed is centered
$Printbtn=GUICtrlCreateButton (" Print ",0,-1)
GUISetState (@SW_SHOW)     ; will display an empty dialog box
                            ; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Printbtn
                            ;choose the printer if you don't want the default printer
                        _PrintSetPrinter($hp);see also _PrinterSelectPrinter
                        _PrintPageOrientation($hp,0);set landscape printing
                        _PrintStartPrint($hp)
                        $pght = _PrintGetpageheight($hp) - _PrintGetYOffset($hp)
                        $pgwd = _PrintGetpageWidth($hp) - _PrintGetXOffset($hp)
                        $axisx = Round($pgwd * 0.8)
                        $axisy = Round($pght * 0.8)
                        _PrintSetFont($hp,'Arial',18,0,'bold,underline')
                        $Title = "hello world"
                        $tw = _PrintGetTextWidth($hp,$Title)
                        $th = _PrintGetTextHeight($hp,$title)
                        _PrintText($hp,$title,Int($pgwd/2 - $tw/2),_PrintGetYOffset($hp))
                        _PrintEndPrint($hp)
                        _PrintNewPage($hp);Not really needed if no more pages to be printed
                        _printDllClose($hp)
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Link to comment
Share on other sites

Hi guys,

I have this problem printing this is my code the first time i click on the print button it works but if i click the print button again i get an error. Any ideas?

You must remove the _PrintDllClose from the end of the code for the button. The function _PrintDllClose should only be called when yoiu have finished using the print dll, on exit from the script for example.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...