New call-to-action
Results 1 to 9 of 9

Thread: Running Operations From Xbasic

  1. #1
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default Running Operations From Xbasic

    I've run into a bizarre problem which makes me wonder if Alpha is behaving as desired. Namely, I have several operations which are run from Xbasic scripts. Since the operations require you to specify the master and transaction tables I would have thought that they were completely independent of which form contained the script from which they were called. Instead, I have found out the *&^%$#*! way that they are dependent on the table.current().

    Specifically, a form based on Table_A has a button with a script which calls the Append_1 operation. In the Append_1 operation, the master table is Table_B and the transaction table is Table_C. When this script runs, Append_1 completes its task and the usual message box appears stating the number of appended records. Upon pressing OK, however, the script has an error reading: "Object does not support requested interface."

    Upon viewing the Xbasic code for the Append_1 operation, I later realized that the operation opens the "current" table onto which it later applies the append method:

    a_tbl = table.current()
    . . .
    . . .
    a_tbl.append()

    This implies that the behavior of an operation is dependent on what tables are open at the time the operation is called. Hence, if two forms are based on different tables, you cannot call the same operation from each form and expect the same results. Have others encountered this problem?

    Workarounds (e.g. opening files prior to calling the operation) are obvious but I wouldn't have expected such to be required. Thank you.

    Steve



  2. #2
    "Certified" Alphaholic
    Real Name
    William Hanigsberg
    Join Date
    Apr 2000
    Location
    Toronto, ON
    Posts
    4,018

    Default RE: Running Operations From Xbasic

    Steve,

    Is it possible that the operation requires exclusive access to one or more tables and may not be able to get it depending on the form from which it is launched? I suspect this is the case but I am not certain.

    If this is the issue, the solution is to rewrite the actions on a record-by-record basis rather than using high-level code.

    I am doing exactly this in order to eliminate some problems with simultaneous appends to a common destination.

    Bill

  3. #3
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default RE: Running Operations From Xbasic

    Hi Bill,

    Whatever the requirements may be I personally think that the Action Scripting (and Xbasic Script Genie) should only let you select operations assigned to table.current(). There is no indication of these restrictions when running a saved operation.

    I see your point in doing a record-by-record loop rather than relying upon operations. But for now I am going to do a compomise. Namely, whenever the table for an operation is not table.current() I am going to replace the [operation].run() statement with its Xbasic equivalent (obtained from the operation editor). Then I will replace the table.current() assignment with a table.open() and close it when finished.

    I still have no explanation as to why Alpha doesn't simply open the master table. If they want to avoid too many open/close sequences, they could at least have a flag to tell the operation whether to use current() or do an open/close. Maybe Lenny is reading this thread.

    Steve

  4. #4
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default RE: Running Operations From Xbasic

    Bill,

    I just stumbled onto another alternative which looks cleaner. When you edit an operation and view the Xbasic code (from the toolbar), a window pops up with the code. At the top of the window is a list of three options:
    1. Raw
    2. Processed
    3. Processed - without confirmation dialogs

    While Raw is the default, the Processed options do indeed open the master table rather than use the table.current(). One button on this window allows you to save the code as a script.

    Well, seeing no way to set this option on the operation itself, I plan to save scripts for any operations where this poses a problem. Then with a script_play_local(), I can actually be running the operation. Using a naming convention, I will make it obvious that this script is derived from an operation.

    Thanks for your thoughts on the matter.

    Steve

  5. #5
    "Certified" Alphaholic
    Real Name
    William Hanigsberg
    Join Date
    Apr 2000
    Location
    Toronto, ON
    Posts
    4,018

    Default RE: Running Operations From Xbasic

    Hi Steve,

    This is interesting and I hope I come to understand this area better.

    You write, "While Raw is the default, the Processed options do indeed open the master table rather than use the table.current()."

    I see how this would help with some problems but if an operation requires exclusive use of a table opening a second instance will not work, right?

    The question is, does an append require exclusive access?

    I think it may. I had problems on a network with one until I wrote around it as I described.

    Bill

  6. #6
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default RE: Running Operations From Xbasic

    Hi Bill,

    As you indicate, I may check the table out insofar as in_use, multiple-instances and exclusive use conditions prior to calling the operation. In the meantime, I've learned a few more things but it still doesn't seem to jive.

    In Ed's good ole CHM, there is a page titled "Using the Xbasic Window" which gets into those three modes for an operation. Under "Processed Xbasic", it states that when you switch to this mode "... the code shown changes to the actual complete script that will be processed by Alpha Five." Moreover, for a given operation on the ControlPanel, if you select "Run Genie"-""Show Xbasic"-""Low Level Xbasic" it does show the "Processed" Xbasic which opens the master table - doesn't use the current() table.

    HOWEVER, it stalls upon using the statements:
    query.filter = ""
    append.run_silent("aTL_Punch_Records",query.filter)
    whereas it runs fine if I replace the above statements with the "Processed" Xbasic code generated by the append operation editor.

    Thus, it is still a mystery as to why the run_silent() and run() methods get hung up. Thanks again for your input.

    Steve

  7. #7
    "Certified" Alphaholic
    Real Name
    William Hanigsberg
    Join Date
    Apr 2000
    Location
    Toronto, ON
    Posts
    4,018

    Default RE: Running Operations From Xbasic

    Hi again,

    "In Ed's good ole CHM, there is a page titled "Using the Xbasic Window" which gets into those three modes for an operation. "

    Valuable; I'll check this out immediately. Thanks.

    "Moreover, for a given operation on the ControlPanel, if you select "Run Genie"-""Show Xbasic"-""Low Level Xbasic" it does show the "Processed" Xbasic which opens the master table - doesn't use the current() table."

    I guess because there is no current table when the context is the control panel, no?


    "HOWEVER, it stalls upon using the statements:
    query.filter = ""
    append.run_silent("aTL_Punch_Records",query.filter)
    whereas it runs fine if I replace the above statements with the "Processed" Xbasic code generated by the append operation editor. "

    There must be something else besides (before) these lines causing the trouble. These seem totally inoccuous.

    I am working on fixing something which taps into this exact issue so I may get back to you. If my "fix" doesn't work it will disconfirm my understanding and if does work I will be free to move on to new errors!

    I think of this as a spur to personal growth as it fosters humility.

    Best,
    Bill

  8. #8
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default RE: Running Operations From Xbasic

    Hi Bill,

    First for the good news. While the CHM indicates that the last parameter for append.run() is [Silent as L], there is actually another parameter showing from the bubble help. That parameter is [Show_Xbasic as L]. When I use the lines:

    query.filter = ""
    append.run("aTL_Punch_Records",query.filter,.T.,.T.)

    it works without hanging up!

    I'm not sure what the Show_Xbasic is supposed to do but I've notified Ed about the discrepency. Whatever it's intention, it seems to get me by. I guess I'd label this a "black hole solution".

    Steve

  9. #9
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default RE: Running Operations From Xbasic

    Hi Bill,

    Well, so much for that "black hole solution". The reason that it didn't hang up is because it didn't process! Maybe that Show_Xbasic parameter is for something like posting the Xbasic lines (somewhere like the trace window) without executing them. I still don't know what it does.

    So the lesson learned is whenever a statement causes the system to hang, just comment it out and it won't hang anymore. The safest system is a null system.

    Steve

Similar Threads

  1. Operations Converted to Xbasic
    By John Castle in forum Alpha Five Version 5
    Replies: 0
    Last Post: 03-31-2005, 04:20 AM
  2. Running operations silently
    By sfzaborsky@hotmail.com in forum Alpha Five Version 5
    Replies: 4
    Last Post: 08-06-2003, 05:36 AM
  3. Date Operations And Xbasic
    By James Watson in forum Alpha Five Version 4
    Replies: 8
    Last Post: 02-19-2002, 10:04 AM
  4. xBasic vs Saved Operations
    By Rhett Scott in forum Alpha Five Version 4
    Replies: 11
    Last Post: 07-28-2001, 12:59 PM
  5. xbasic syntax for running operations?
    By William Perry in forum Alpha Five Version 4
    Replies: 2
    Last Post: 04-25-2000, 04:57 AM

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
  •