Alpha Video Training
Results 1 to 11 of 11

Thread: BUG: Custom toolbar makes error in report save

  1. #1
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Grand Rapids, Michigan
    Posts
    4,212

    Default BUG: Custom toolbar makes error in report save

    Attached is a very pared down application that showes a bug when final compilation for distribution was tested. I would like confirmation on this before submitting it as a formal bug report. It is a bit complicated to reproduce over and over again in the example, because it seems to clear itself, in the full app it persists. Secondly, this app is in v7, because that is what the client owns full runtime of, but when I tested it in v10, the bug is here also.

    The app has a form named "Status Agents". There is a red button on that form that runs a UDF named 'agent_status_send()'. When the form is configured with system toolbar... all is fine. When configured with ANY custom toolbar an error is generated. I believe the error manifest at line 53 of the code where it saves the report as a PDF. To show the error do the following.

    1. from the main menu, open the Status Agent form
    2. press the red 'Preview and Email....' button.
    3. press Exit the Report preview toolbar button to close preview
    4. press'yes' button on the 'Report Email Query' dialog
    ......The email client will open showing the email with attachment to send
    5. press red 'X' to close the dialog (you will be out of app so go back to it).
    6. place form in Design mode. Goto Form Properties.
    7. Select Menu/Toolbar tab
    8. Select "Custom Form" in the Toolbars > View, press "OK", Save the layout.
    9. Return the form to view mode.
    10. Repeat steps 2 and 3 and the error will manifest.
    .... The error in this example manifests once and then clears. In my complete app it persists. You can generate the error over and over again by returning the form toolbar to System toolbar, run the UDF, then return toolbar to Custom and run the UDF.

    I can't tell you how many days before figuring out the source of thie issue have been spent on this!!! Thanks for your help. BTW: version 2814:3539. I adownloaded and installed 2916:3554 (v10.5.6). Manifests there too.
    Last edited by Mike Wilson; 06-05-2010 at 02:13 PM.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  2. #2
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,957

    Default Re: BUG: Custom toolbar makes error in report save

    following your instructions, xppro machine, release cand 6, all works as advertised
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    martin_w_cole@msn.com

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

  3. #3
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Grand Rapids, Michigan
    Posts
    4,212

    Default Re: BUG: Custom toolbar makes error in report save

    I've got it erroring on 3 different machines.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  4. #4
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,957

    Default Re: BUG: Custom toolbar makes error in report save

    what is the error?
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    martin_w_cole@msn.com

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

  5. #5
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: BUG: Custom toolbar makes error in report save

    I see the errors.
    Looks like a bug, but it is not.
    Fixed.
    No more errors.

  6. #6
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Grand Rapids, Michigan
    Posts
    4,212

    Default Re: BUG: Custom toolbar makes error in report save

    Thank you very much, Gabriel!
    I won't even attempt to figure out why it worked with a system toolbar and why it didn't work with custom toolbar.

    Martin,
    FYI, the error message is attached.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  7. #7
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: BUG: Custom toolbar makes error in report save

    Quote Originally Posted by Mike Wilson View Post
    I won't even attempt to figure out why it worked with a system toolbar and why it didn't work with custom toolbar.
    Actually, with the system toolbar, it didn't work but it didn't produce the error either. I won't attempt to figure out why either because the only way to figure it out is if I knew the code behind saveas(), and I don't.

  8. #8
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: BUG: Custom toolbar makes error in report save

    Hi Mike,

    Quote Originally Posted by Mike Wilson View Post
    I won't even attempt to figure out why it worked with a system toolbar and why it didn't work with custom toolbar.
    The reason (with about a 98% Correction: I'll make that 100% certainty) is that you are using variables that Alpha uses in the report.saveas() method. There is no reason to. Eg. your code is
    query.filter = "Agent_pqid = "+quote(vagentpqid)+ " .and. isblank(\"Date_done\")"
    query.order = "Last_name"
    'replace variables in the filter with their actual values
    query.filter = convert_expression(query.filter,"V")

    :Report.Preview("Agent Statuses",query.filter,query.order)
    ' ....Other code of yours
    :Report.SaveAs("Agent Statuses","PDF",query.filter,query.order,voutfile ,.F.)
    The values in red are not what you originally set. Changing it to something like
    dim myfilter as c
    dim myorder as c
    myfilter = "Agent_pqid = "+quote(vagentpqid)+ " .and. isblank(\"Date_done\")"
    myorder = "Last_name"
    'replace variables in the filter with their actual values
    myfilter = convert_expression(myfilter,"V")

    :Report.Preview("Agent Statuses",myfilter,myorder)
    ' ....Other code of yours
    :Report.SaveAs("Agent Statuses","PDF",myfilter,myorder,voutfile ,.F.)
    will make the error go away. What is happening? "query" is a global pointer variable that alpha uses for queries. If you happen to set the properties (Order and filter) of the pointer and run a query, you are fine.

    However, you are passing these values of properties to report.Preview() method. This is still fine, as the values are correct before using the method and are passed to the method as values. However, because you set a custom toolbar for the report, it now needs to find the toolbar in the database's al* files. (which is just a DBF table renamed, where it is stored). To do this, Alpha Five runs a query for the location of the toolbar in this renamed table, and guess what? It changes the property values of the global pointer "query" to what it needs. (Had you used the "System toolbar", no query by Alpha is required, and the query pointer properties would not have changed.)

    Now the filter is no longer what you require, and now you are passing the changed values to the Report.saveas() method.

    Oops. It didn't work!
    That's because the global filter properties have changed after the preview method.

    I'll add an addition to my tips on variable usage, which is don't count on Alpha Five maintaining it's "system-defined" global variables beyond the next call that might use them. This is why I stress constantly that you use local variables where ever possible and DIM all of them!

    Added: Is it a bug in Alpha? Not really. You were using a system defined global variable, and expecting it to be preserved, which Alpha does not guarantee. In fact, it's possible for 2 different forms (or threads/sessions) both running code to step on each other's usage of this global pointer variable. While this is not typical for most Alpha users, it can be done if you switch forms while a long operation is happening that uses it.

    Should the values be preserved? I recommend that all functions and methods be written as close to what's referred to as a "pure" function as possible. Realistically (and in cases similar to this, historically going back to A5v1), it can't always be done without making a lot of other historical code (user's and Alpha's) fail. Alpha can change this one to work, but not all cases you might run into.

    It is better to control your own destiny and fix your code.
    Last edited by csda1; 06-05-2010 at 08:53 PM.
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  9. #9
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: BUG: Custom toolbar makes error in report save

    The custom toolbar is used with the form, not the report.

    query.filter & query.order have nothing to do with the error produced.

    The error is produced as alpha is attempting to parse the name of the file to save.

  10. #10
    VAR csda1's Avatar
    Real Name
    Ira J Perlow
    Join Date
    Apr 2000
    Location
    Boston, Massachusetts, USA
    Posts
    3,530

    Default Re: BUG: Custom toolbar makes error in report save

    Quote Originally Posted by G Gabriel View Post
    The custom toolbar is used with the form, not the report.

    Yes, you are correct the custom toolbar is on the form, but the problem and solution still holds.

    The form creates a session (also called shared) pointer variable called query with the same properties that has the value of the last thing queried, which is the custom toolbar (which is the error message being shown). This is also version/release dependent, depending upon whether the custom toolbar is refetched at various points (which Alpha has played with) The last value of the session variable pointer query is
    ?ptr.query
    = filter = name = 'custom form' .and. left(type,4) = "TLBR"
    order = ""
    The button that runs the report.preview() and the report.saveas() invokes the function agent_status_send() in the current form's session.

    That code has no locally defined pointer called query. Hence it uses the next higher scoped value it finds, which in this case is session/shared variable pointer query (as opposed to global).

    Depending upon when and if the custom toolbar is refetched, the values to query.filter and query.order that the code changed, would be overwritten by the refetch of the custom toolbar.

    Had the query pointer been DIM'd locally, the error would not have occured. Nevertheless, using any system defined variables was not needed for these calls to report.preview() and report.saveas() and by implicit DIM'ing, rather than an explicit local DIM variable, gave rise to the problem
    Regards,

    Ira J. Perlow
    Computer Systems Design


    CSDA A5 Products
    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
    CSDA Barcode Functions

    CSDA Code Utility
    CSDA Screen Capture



  11. #11
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: BUG: Custom toolbar makes error in report save

    1-Mike assigns new values to query filter/order right before saving the report. Any previous values do not count.
    2-Run the script from the code tab, it works fine.
    Last edited by G Gabriel; 06-05-2010 at 10:36 PM.

Similar Threads

  1. Help w/ creating custom toolbar to open a report
    By first5.0 in forum Alpha Five Version 7
    Replies: 5
    Last Post: 04-06-2006, 04:29 PM
  2. Custom Toolbar Error Message
    By Chris Valencia in forum Alpha Five Version 6
    Replies: 2
    Last Post: 02-28-2005, 11:18 AM
  3. Custom Toolbar
    By mel in forum Alpha Five Version 5
    Replies: 13
    Last Post: 01-30-2004, 09:33 AM
  4. Creating a report that makes a text file.
    By Jesse Sanders in forum Alpha Five Version 4
    Replies: 1
    Last Post: 07-26-2000, 04:25 PM
  5. custom toolbar
    By Duane Pederson in forum Alpha Five Version 4
    Replies: 2
    Last Post: 04-25-2000, 08:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •