Sign in to follow this  
Followers 0
James

Printing

27 posts in this topic

Hey all!

I have this code for printing text documents.

$FilePrint =  $DocEd1
    If @error Then MsgBox(0, "Print", "Error:" & @CRLF & "The file was not printed.")
        
    $print = _fileprint($FilePrint, @SW_SHOW)
        If $FilePrint Then
        MsgBox(0, "Print", "The file was succesfully printed.")
    Else
        MsgBox(0, "Print", "Error: " & @error & @CRLF & "The file was not printed.")
    EndIf

But its not working. I have looked at the example and that doesn't work either.

Thanks Secure

Share this post


Link to post
Share on other sites



Hi,

do you get the error message? Is your filehandle really a filehandle?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi,

$FilePrint =  $DocEd1
    If @error Then MsgBox(0, "Print", "Error:" & @CRLF & "The file was not printed.")
       
    $print = _fileprint($FilePrint, @SW_SHOW)
        If $FilePrint Then ; <--- SHOULD BE $print, right????????????????????????????????
        MsgBox(0, "Print", "The file was succesfully printed.")
    Else
        MsgBox(0, "Print", "Error: " & @error & @CRLF & "The file was not printed.")
    EndIf
oÝ÷ ÚX¤zØb±«­¢+Ø¥¹±Õ±Ðí¥±¹ÔÌÐì(ÀÌØí¥±AÉ¥¹ÐôMÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈìĹÑáÐÅÕ½Ðì()%}¥±AÉ¥¹Ð ÀÌØí¥±AÉ¥¹Ð°M]}M!=¤Q¡¸(%5Í  ½à À°ÅÕ½ÐíAÉ¥¹ÐÅÕ½Ðì°ÅÕ½ÐíQ¡¥±ÝÌÍÕÍÕ±±äÁÉ¥¹Ñ¸ÅÕ½Ðì¤)±Í(%5Í   ½à À°ÅÕ½ÐíAÉ¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÉɽÈèÅÕ½ÐìµÀìÉɽȵÀì
I1µÀìÅÕ½ÐíQ¡¥±Ý̹½ÐÁÉ¥¹Ñ¸ÅÕ½Ðì¤)¹%

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

no problem. Good luck, hope it helps you out.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Well.. I tried it. And all it does is say that the File was not printed.

Isn't it about time now to start learning about how to debug your scripts in stead of saying "It doesn't work" ?

- test for return codes

- put in ConsoleWrite()/MsgBox() at strategic places showing you more info.

Just saying it doesn't work leaves us guessing ...

:P


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

did you try to get the reason?

Try this:

#include <File.au3>
$FilePrint = @ScriptDir & "\1.txt"

If Not FileExists($FilePrint) Then
    MsgBox(16, "Error", "File not found!")
    Exit (0)
ElseIf _FilePrint($FilePrint, @SW_SHOW) Then
    MsgBox(0, "Print", "The file was succesfully printed.")
Else
    MsgBox(0, "Print", "Error: " & @error & @CRLF & "The file was not printed.")
EndIf

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Sorry, but I did say that it always says "Error:2 The file was not printed." And it doesn't print, but gives no errors.

No need to say sorry ... just trying to explain to you that telling us that things don't work is fine in the beginning but you are supposed to learn to debug scripts yourself.

Try to figure it out yourself by testing/trying/putting debug lines in the script ...etc ... or else I will have to change your group title to n00b again :P


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

easiest way is always to show the whole script with detailed problem description. What to achieve and what happens.

So long,

Mega

P.S.: I'll have a look when you post again.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Sorry, but I did say that it always says "Error:2 The file was not printed." And it doesn't print, but gives no errors.

well let's analyse your problem.

Return code 0, @error = 2. Hm... nothing in the help file.

What would I do??? Hey, let's look at the source code for _FilePrint.... O.K. there we have:

DllCall("shell32.dll", "long", "ShellExecute", _.....

O.K. So it's using ShellExecute (also documented in the help file!). Well, the documentation for ShellExecute will for sure explain what return code 2 could possibly mean.

So, let's use google.com to find the documentation on MDSN. --> LINK: http://msdn.microsoft.com/library/default....llexecute.asp

O.K. now, we have the following:

[i]Return Value (of ShellExecute):

    Returns a value greater than 32 if successful, or an error value that is less than or equal to 32 otherwise. The following table lists the error values. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. The only thing that can be done with the returned HINSTANCE is to cast it to an int and compare it with the value 32 or one of the error codes below.
    0   The operating system is out of memory or resources.
    ERROR_FILE_NOT_FOUND    The specified file was not found.
    ERROR_PATH_NOT_FOUND    The specified path was not found.
    ERROR_BAD_FORMAT    The .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image).
    SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
    SE_ERR_ASSOCINCOMPLETE  The file name association is incomplete or invalid.
    SE_ERR_DDEBUSY  The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed.
    SE_ERR_DDEFAIL  The DDE transaction failed.
    SE_ERR_DDETIMEOUT   The DDE transaction could not be completed because the request timed out.
    SE_ERR_DLLNOTFOUND  The specified DLL was not found.
    SE_ERR_FNF  The specified file was not found.
    SE_ERR_NOASSOC  There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
    SE_ERR_OOM  There was not enough memory to complete the operation.
    SE_ERR_PNF  The specified path was not found.
    SE_ERR_SHARE    A sharing violation occurred.

[/i]

So, what the hell is return code 2 ??? O.K., let's search for the consants ERROR_FILE_NOT_FOUND and ERROR_PATH_NOT_FOUND, again via google.com.

searching.... searching .... searching .... Wait, here we go: several links to: ERROR_FILE_NOT_FOUND = 2 and ERROR_PATH_NOT_FOUND = 3.

So, now WHAT is your problem now???

First hint: Check the file path.. :P

Second hint: look at the source code of _FilePrint to figure out if the path has to be fully qualified!

EDIT: Third hint: check your code! It's allways good to use the right variables at the right place :D

$print = _fileprint($FilePrint, @SW_SHOW)
        If $FilePrint Then

That's the way to debug a problem. No special programming skills needed, just a little bit common sense!!

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Wow thanks Kurt! You have taught me a special skill..

not until you can explain the problem :P So, now it's your turn...

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

OK, Mega; here is my FULL source code.

The funny thing is, you do it right in one place and you do the very same thing wrong in another place... Re-check your code. With my hints you should be able to find the problem very soon.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Okey Dokey Dev. I will re-check my code, and if I can't then I will ask again.

O.K.

BTW: MsgBox() is you friend, while debugging !!

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
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
Sign in to follow this  
Followers 0