Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

printer over ride to default

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • printer over ride to default

    Hi,
    I have some code set to do some automatic printing for a report. The user selects the printer they want first using a dialog box. The dialog box is populated with a list of printers. Since the report is goig to be printed to 2 different printers depending on a value in the data.

    This code is used to get values, etc then used to populate the dialog box
    dim cprinter as c
    dim cprinterset as c
    dim ptr as P
    dim ptr.dummy as L
    ptr.dummy = .t.
    cprinter = ui_printer_default_get()
    cprinterset = ui_printer_settings_get(cprinter, ptr)

    2 values are set in the dialog cprinter and yprinter.

    When the printing is done then this command is issued in the script just ahead of the print command which is this:
    report.print("Invoice_Logo","Accounts->Invoiceno = " + "'" + word(foo.value,-1) + "'","")

    last_printer = :report.printer_override(cprinter) or
    last_printer = :report.printer_override(yprinter)

    It runs quite well, sending the reports to the proper printers, etc all automatically.
    My problem is that when it is all done, I need to be able to set the printing back to a normal process. If I go to print a different report or letter, I don't get the normal windows pop up to select a printer. The report goes automatically to the whatever the last printer was assigned in the routine list above. So obviously we need to reset the Alpha Printing so that we can get the normal windows popup. The only way to get it back is to resstart Alpha. The help file has nothing on how to reset the printing to the defaults.

    the help file say that using the command :report.printer_override(cprinter,oriprinter) the oriprinter is supposed to hold the original settings. But that doesn't work.


    Anyone have any ideas?
    Thanks,
    mike
    Mike Reed
    Phoenix, AZ

  • #2
    Re: printer over ride to default

    Mike, I'm a bit confused by what you are doing. The way I read it, your script does this:

    report.print("Invoice_Logo","Accounts->Invoiceno = " + "'" + word(foo.value,-1) + "'","")

    last_printer = :report.printer_override(xxxxxx)


    But there is no printer_override() statement before the report.print() statement so it should just use whatever printer is defined for that report. Basd on my vast experience (one time), you need a report.printer_override() statement before the report.print() statement to change the printer then again afterward to change it back. Also, fwiw, I don't believe the printer_override() will work with report.preview()

    As best I recall, the printer_override() didn't work very well for me when I only gave it the printer name. I also had to pass the appropriate printer options via the pointer. (This may not be necessary - just reporting how I did it. However, I suspect that using just the name works only if all the other printer options are the same. In my case, one printer was a continuous feed label printer and the other was an 8.5x11 printer and the options were completely different.)

    Assume you wanted to use a printer called "MyOtherPrinter" to print a report and you wanted to return to whatever the original printer was. I think the following would work - however, in the one case where I used printer_override, I think I ended up getting the printer options from the printer operating manual and hard coding them instead of using ui_printer_settings_get() - not sure if I had to or if I "just did it that way."

    Code:
    [COLOR=darkorchid]dim ptr as P[/COLOR]
    ptr.dummy = .t.
    [COLOR=blue]'This just sets the values in "ptr" - it doesn't return anything. (See "Interactive Window" notes)[/COLOR]
    [COLOR=darkgreen]ui_printer_settings_get([/COLOR] "MyOtherPrinter", ptr )
    delete ptr.dummy   [COLOR=blue]'may not be required - I like it because it keeps things cleaner.[/COLOR]
    
    DIM orig_ptr as P
    orig_ptr.dummy = "dummy"
    [COLOR=darkgreen]last_printer_name = report.printer_override([/COLOR] "MyOtherPrinter", ptr, orig_ptr )
    [COLOR=blue]'This should print to "MyOtherPrinter"[/COLOR]
    [COLOR=darkgreen]report.print([/COLOR] "Invoice_Logo", "Accounts->Invoiceno = " + "'" + word(foo.value,-1) + "'", "" )
    
    [COLOR=blue]'Now reset to the original printer.[/COLOR]
    [COLOR=blue]'No need to get the last printer name/info in this case.[/COLOR]
    [COLOR=darkgreen][COLOR=#000000]delete orig_ptr.dummy  [/COLOR][COLOR=blue]'Again, maybe not needed.[/COLOR]
    report.printer_override([/COLOR] last_printer_name, orig_ptr )
    Here's what you get when running ui_printer_settings_get() in the interactive window: (Hint - running new functions in the Interactive Window and be very useful sometimes.)
    Code:
    dim ptr as P
    ptr.dummy = "dummy"
    ?ui_printer_settings_get("Alpha Five Printer", ptr )
    = [B][COLOR="Blue"]<No data returned>[/COLOR][/B]
    ?ptr
    = collate = .F.
    color = "Color"
    copies = 1
    defaultsource = "Default bin"
    dummy = "dummy"
    duplex = "Simplex"
    orientation = "portrait"
    papersize = "Letter 8 1/2 x 11 in"
    quality = "Draft"
    truetype = "Substitute"
    Last edited by CALocklin; 04-16-2010, 12:59 AM.

    Comment


    • #3
      Re: printer over ride to default

      HI Cal,
      Thanks for the info, I'm going to work on it later today.

      Sorry also for the confusion. I printer override does come before the report.print command, I entered that wrong in my message.

      I just have to be able to give the user back the choice to select their printer rather than having Alpha Five automatically print to the last one assigned by the :report.printer_override().
      Unfortunately the help file doesn't offer much help there.

      Thanks again, I'll post the outcome when I'm done.

      mike
      Mike Reed
      Phoenix, AZ

      Comment


      • #4
        Re: printer over ride to default

        Originally posted by Mike Reed View Post
        I just have to be able to give the user back the choice to select their printer rather than having Alpha Five automatically print to the last one assigned by the :report.printer_override().
        OK, I think I understand your problem better now. Try this:
        report.Printer_override("")
        No guarantees - I just did one quick test and that seemed to work.

        Comment


        • #5
          Re: printer over ride to default

          What Cal says is usually correct. But if his suggestion does not work, you might look at two other things:

          1) Someone not nearly as expert as Cal posted an printer override article on Learnalpha.com a couple of years ago. Some of the article is a bit obtuse but if you can get by that, then by using some of the code in the article (might have been a download sample) one can do just about anything regarding automatically printing to a specified printer, paper size, orientation, depending on the user, data items, etc. and then going back to whatever printer and setup the user began with. It works!

          2) Probably much easier in your case would be to use Action Scripting (I know, the Gods forbid this!) to print a report, choose Options, choose Printer Override and make some choices, then convert the Action Script to Xbasic, copy the relevant code into your own situation and it is almost guaranteed to work for you. By the way, take what the Gods, any Gods, say about AS and much else with a grain of salt.

          Raymond Lyons

          Comment


          • #6
            Re: printer over ride to default

            Just another 2 pennies.....

            I do this all the time, the user chooses from a radio box selection for the printer they want to print to....in this case a large format (11x17 printer). It is a little confusing...but in the end the help file is right on.

            From the help file

            last_printer = :report.printer_override("HPLaserJet 4P")
            :report.print("invoices")
            :report.printer_override(last_printer)
            the help file say that using the command :report.printer_override(cprinter,oriprinter) the oriprinter is supposed to hold the original settings. But that doesn't work
            You just need to make sure the 3rd line in the code from the help file above is set to "last_printer".....not your user's selected printer name. It is confusing because the help file has 2 different examples (one includes the old options if they were special). But, it sounds like you just want the normal printer dialog back. The example above does the trick for that. I have no doubt Cal's option works as well.....just wanted to share my experience.

            Regards,

            Jeff
            Last edited by jkletrovets; 04-17-2010, 12:26 AM.

            Comment


            • #7
              Re: printer over ride to default

              Thanks for all your replies.
              I worked through the issues based on your comments and got it working fine.

              Thanks again,
              mike
              Mike Reed
              Phoenix, AZ

              Comment


              • #8
                Re: printer over ride to default

                Don't keep us in suspense! What was the solution?

                Comment


                • #9
                  Re: printer over ride to default

                  Originally posted by CALocklin View Post
                  Don't keep us in suspense! What was the solution?
                  Sorry for not making the note.

                  Your suggestion of using this:
                  report.Printer_override("") is what made it work.

                  At least so far,
                  Mike Reed
                  Phoenix, AZ

                  Comment


                  • #10
                    Re: printer over ride to default

                    Oddly enough, I had to do some work with .printer_override() this afternoon and happened to open my own A5v5 XBasic Help file which has the Help from A5v4 (converted from the PDF), as well as A5v5 and some later functions, and in it the Printer_override topic says:

                    If printer_name is equal to a null string (""), then Alpha Five will use the Default Windows printer.

                    I guess they took that out for some reason when they created the newer Help file.

                    Comment

                    Working...
                    X