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

Failing xbasic code from build 3629 to current and version 11

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

    Failing xbasic code from build 3629 to current and version 11

    Hello to everyone.

    I had a custom routine written for me back in 2010 that has worked flawlessly since it was written...until I tried to upgrade to the latest v10.5 build. I have also loaded the database on my v11 system and it fails there also. Interestingly, it fails to display the contents of a query in form view, but it does display the query in form design mode.

    I have included the code below and would greatly appreciate it if anyone spots something obvious that is causing the failure.

    dim tbl as p
    dim b_tbl as p
    dim qry as p
    dim qrecs as n
    dim b_tbl as p
    dim b_id as n =1
    dim holdtbl as c
    b_tbl=table.open("billings") 'zap the billings table to keep the procedure clean
    b_tbl.zap(.t.)
    b_tbl.zap(.t.)
    b_tbl.close()
    tbl=table.open("contracts") 'open the contracts table
    'this line will filter the query to return only ACTV=true On_hold=false CR_updates = true and cur_bal_hors <= to e_hours
    query.filter="actv=.t. .and. on_hold=.f. .and. cr_updates=.t. .and. cur_bal_hrs <="+s_quote(parentform:e_hours.value)
    query.order="client_name" 'order the resultant query by Client_name
    query.options="T" 'make this a temporary query
    qry=tbl.query_create() 'create the query
    qrecs=qry.records_get() 'get the number of records in the query
    if qrecs=0 then ' if it is zero no record met the criteria - give msg stating that then zap the table to start over
    msgbox("Alert","No Records Met Your Criteria",UI_STOP_SYMBOL)
    b_tbl=table.open("billings")
    b_tbl.zap(.t.)
    b_tbl.close()
    parentform:browse1.resynch()
    end
    end if
    tbl.fetch_first() 'if there are records in the query open the billings table and empty it b_tbl=table.open("billings")
    b_tbl.zap(.t.)
    b_tbl.close()
    b_tbl=table.current(2)

    'since this form was based on a set with billings_cc as the parent and billings as the child
    'open the billings table as the second table in the set
    b_tbl.batch_begin()

    'start a batch to populate the billings table based on the filter
    WHILE .NOT. tbl.fetch_eof()
    b_tbl.enter_begin(.T.)
    b_tbl.contract_id=tbl.contract_id
    b_tbl.client_id=tbl.client_id
    b_tbl.client_name=tbl.client_name
    b_tbl.cur_bal_hrs=tbl.cur_bal_hrs
    b_tbl.contract_rate=tbl.billable_rate
    'b_tbl.p_date=date() 'This is now in the field rules for p_date but it's being updated here anyway
    b_tbl.emp_id=parentform:emp_id.value
    b_tbl.employee=parentform:employee.value
    b_tbl.old_bal_hrs=parentform:e_hours.value
    b_tbl.bill_now=.t.
    b_tbl.enter_end(.T.)
    b_id=b_id+1
    tbl.fetch_next()
    end while
    b_tbl.batch_end()
    'the next lines drop the query, close the contract table -
    'the rest of the code is force refreshing of the
    'of the browse that contains the new records in the billing table.
    qry.drop()
    tbl.close()
    ui_yield()
    sys_send_keys("{^home}")
    credits_checker:browse1.refresh()
    credits_checker:browse1.activate()
    parentform.commit()
    credits_checker:browse1.Resynch("billings")
    sys_send_keys("{F5}")
    parentform.Refresh_Layout()
    END

    Thank you.

    Tom

    #2
    Re: Failing xbasic code from build 3629 to current and version 11

    Hey Tom,

    This would be much easier to understand if you preserved indented sections with CODE tags.

    Comment


      #3
      Re: Failing xbasic code from build 3629 to current and version 11

      Sorry Tom.

      I've never posted any scripts on the Forum and have no idea how to do that.

      Tom

      Comment


        #4
        Re: Failing xbasic code from build 3629 to current and version 11

        Paste the formatted script into a reply.

        Choose "Go Advanced" button

        "Select" the formatted script with your mouse.

        Click the hash tag ( pound sign ) button to surround your selected text with CODE tags

        Submit your reply.

        The HTML CODE tags tell the message board to preserve your formatting.

        Comment


          #5
          Re: Failing xbasic code from build 3629 to current and version 11

          Code:
          dim tbl as p
          dim b_tbl as p
          dim qry as p
          dim qrecs as n
          dim b_tbl as p
          dim b_id as n =1
          dim holdtbl as c
          
          b_tbl=table.open("billings") 'zap the billings table to keep the procedure clean
          	b_tbl.zap(.t.)
          	b_tbl.zap(.t.)
          	b_tbl.close()
          
          tbl=table.open("contracts")  'open the contracts table
          
          'this line will filter the query to return only ACTV=true On_hold=false CR_updates = true and cur_bal_hors <= to e_hours
          query.filter="actv=.t. .and. on_hold=.f. .and. cr_updates=.t. .and. cur_bal_hrs <="+s_quote(parentform:e_hours.value)
          
          query.order="client_name"  'order the resultant query by Client_name
          
          query.options="T"  'make this a temporary query
          
          qry=tbl.query_create()    'create the query
          
          qrecs=qry.records_get()   'get the number of records in the query
          
          if qrecs=0 then   ' if it is zero no record met the criteria - give msg stating that then zap the table to start over
              msgbox("Alert","No Records Met Your Criteria",UI_STOP_SYMBOL)
              b_tbl=table.open("billings")
              b_tbl.zap(.t.)
              b_tbl.close() 
          	 parentform:browse1.resynch()   
              end 
          end if
          
          tbl.fetch_first() 'if there are records in the query open the billings table and empty it
          	b_tbl=table.open("billings")
          	b_tbl.zap(.t.)
          	b_tbl.close()
          
          b_tbl=table.current(2)
          'since this form was based on a set with billings_cc as the parent and billings as the child
          'open the billings table as the second table in the set
          
          b_tbl.batch_begin()
          'start a batch to populate the billings table based on the filter
          
          WHILE .NOT. tbl.fetch_eof()
           	b_tbl.enter_begin(.T.)
           		b_tbl.contract_id=tbl.contract_id
           		b_tbl.client_id=tbl.client_id
           		b_tbl.client_name=tbl.client_name
           		b_tbl.cur_bal_hrs=tbl.cur_bal_hrs
           		b_tbl.contract_rate=tbl.billable_rate
           		'b_tbl.p_date=date() 'This is now in the field rules for p_date but it's being updated here anyway
           		b_tbl.emp_id=parentform:emp_id.value
           		b_tbl.employee=parentform:employee.value
           		b_tbl.old_bal_hrs=parentform:e_hours.value
           		b_tbl.bill_now=.t.
           		
          	b_tbl.enter_end(.T.)
          	b_id=b_id+1
          	tbl.fetch_next()
          end while
          
          b_tbl.batch_end()
          
          'the next lines drop the query, close the contract table - 
          'the rest of the code is force refreshing of the 
          'of the browse that contains the new records in the billing table.
          
          qry.drop()
          tbl.close()
          ui_yield()
          
          sys_send_keys("{^home}")
          credits_checker:browse1.refresh()
          credits_checker:browse1.activate()
          
          parentform.commit()
          
          credits_checker:browse1.Resynch("billings")
          sys_send_keys("{F5}")
          parentform.Refresh_Layout()
          
          END

          Comment


            #6
            Re: Failing xbasic code from build 3629 to current and version 11

            Much better, right?

            Comment


              #7
              Re: Failing xbasic code from build 3629 to current and version 11

              Tom,

              The script zaps the Billings table 3 times if there are records to be created there. That seems unnecessary to me.

              Suggest you run the script through the debugger and let us know what you get.

              If this, too, is unfamiliar ground its time you got acquainted with the debugger. Check the help system topic "Watching Script Execution with the Debugger".

              If you haven't figured it out afterwards, post some sample data for us to work with.

              Comment


                #8
                Re: Failing xbasic code from build 3629 to current and version 11

                Tom,

                I have tried the debugger and it tells me that...
                Line 70, end while not found tbl not found
                and then on...
                Line 31 "qrecs=qry.records_get() 'get the number of records in the query
                Argument is incorrect data type.

                None of this makes sense to me unless something has changed from one Alpha build to the next.

                Tom
                Attached Files

                Comment


                  #9
                  Re: Failing xbasic code from build 3629 to current and version 11

                  What version of a5 are you coming from?
                  And have you tried rebuilding indexes on the tables? (I can't help but wonder whether something has become corrupted.)

                  The error on line #17 qrecs=qry.records_get() might be a clue.
                  And the error you report on line #70 error isn't matching up to anything. Exactly where is the debugger at that point?

                  Also:
                  Where is this code being called from? I believe zap only works with an exclusive lock on the table.
                  And... credits_checker:browse1.Resynch("billings") seems odd. (I didn't know that <browse>.Resynch() took a parameter.
                  Last edited by SNusa; 03-18-2013, 12:59 PM.
                  Robert T. ~ "I enjoy manipulating data... just not my data."
                  It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                  RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                  Comment


                    #10
                    Re: Failing xbasic code from build 3629 to current and version 11

                    Robert,

                    Thanks for your comments.

                    I tried re-indexing and that didn't help.

                    In running the debugger again, I found that the errors that were being generated went away when I simply replaced the form name with "parentform" on the 3 lines of code where the form name is specified. That eliminated the errors I was getting in the debugger but didn't have an impact on the runtime. The problem is still there.

                    As for a lock on the table or the resynch command, I can't say. All I can say is that the code above has been working fine for 2 1/2 years under build 3629.

                    Tom

                    Comment


                      #11
                      Re: Failing xbasic code from build 3629 to current and version 11

                      Tom,

                      When you post sample data for us to work with please describe the context in which this script runs. Is it running from a form, if so, which form?

                      I will hazard a couple of guesses based solely on code review thus far. I won't spend any more time on it until you post sample data and the form or forms that are involved after that.

                      Guesses:

                      1) Alpha may be confused by two assignments to the same pointer variable. In one place you use b_tbl to reference a new instance of the billings table. In another you use the same pointer to reference the copy of Billings table supporting your form. so ask yourself which of these should B_tbl actually reference.

                      2) The Zap() method documentation for the <tbl> object should be studied. You will find that this method requires that the target table be opened for exclusive use. If the Billings table is part of the set supporting your form then its open when the form opens and the ZAP() method will fail. Every time.

                      Suggestions:

                      1) The script includes no error traps to alert you when errors occur. Including error traps would make debugging this easier for you.

                      2) Break your script into separate scripts and run each one at a time. This will help you spot the problem.

                      Comment


                        #12
                        Re: Failing xbasic code from build 3629 to current and version 11

                        Thanks for your help and efforts on this Tom. I really appreciate it.

                        I'll try your suggestions before posting sample data.

                        Tom

                        Comment

                        Working...
                        X