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

Duplicate code fails in 4.5.266

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

    Duplicate code fails in 4.5.266

    Hi all,

    I may have found a problem in Version 4.5 regarding code I "borrowed" from Peter Wayne's article "Duplicating a set". (This code is also included in the new version of _Xbasic for Everyone_.)

    The objective is to duplicate a set's record: both parent and children. The parent is simple. Child records are put in an array and new children created. During this process the new parent number is stuffed into the child copies to ensure they link to the new parent.

    I find this code now fails in 4.5 which I installed earlier in the summer. It works fine on the same machine using 4.03 build 229.

    I was worried about complicated interactions in my application so I went back to basics and dummied up Dr. Waynes application. The result is the same: fails in 266, works in 229.

    A demo is attached. Here is what to look for. There are two tables linked 1:N and a form based on the set. The only code is attached to a button ("duplicate") on the form. There is only one parent record and it has three child items.

    In 4.03:
    Press the button and you will have a new header (with the header id autoincremented) and three new child records.

    In 4.5:
    Press the button and you get a new header, a good first child record, and 2 more blank child records.

    I would appreciate if someone could confirm this for me. The only thing I have not yet done is reinstall A5 and patch it up to 266.

    Thanks,
    Bill
    Bill Hanigsberg

    #2
    RE: Duplicate code fails in 4.5.266

    Bill,
    Tried the example and got the same result that you did. I also got a crash when I tried to open the form a second time. This is with version 4.5 build 267. Version 4.03 build 230 works fine. I looked at the code and everything looks fine. I checked and the count_items is calculating correctly.

    Jerry

    Comment


      #3
      RE: Duplicate code fails in 4.5.266

      Hi Jerry,

      Thanks for checking this out. I too get the crash the second time. Forgot to mention that which was not that nice of me. Sorry.

      Did you find a patch to 4.5.267 or is that what came with your download?

      Bill
      Bill Hanigsberg

      Comment


        #4
        RE: Duplicate code fails in 4.5.266

        Hello again,

        In case anyone is following this I tried opening a second instance of the child table just to see if the problem might be there. (Thanks to Tom Cone for the suggestion.) Anyway, it solved nothing. The behavior is unchanged. I just wouldn't like anyone to waste time on a dead end.

        Here is the code:

        ''XBasic
        'duplicate composite record
        on error goto error_handler
        dim hdr as p
        dim items as p
        dim old_parent as b
        dim count_items as n
        dim i as n

        'debug(1)

        hdr=table.current(1)
        items=table.current(2)
        count_items = count(Inv_Items->Inv_No,GRP->INV_HDR)
        if count_items>0 then
        dim records[count_items] as b
        i=0
        items.fetch_first()
        while i0

        old_parent=hdr.record_data_get()

        hdr.enter_begin()
        ' note, in this table the inv_no is an autoincrement field
        ' a new inv_no is assigned by the field rule,
        ' which overrides the Xbasic record_data_set()
        hdr.record_data_set(old_parent)
        hdr.enter_end(.t.)

        '*************************
        'Remove this:
        'if count_items>0 then
        ' for i=1 to count_items
        ' items.enter_begin()
        ' items.record_data_set(records[i])
        ' items.inv_no=hdr.inv_no
        ' items.enter_end(.t.)
        ' next
        'end if ' count_items>0
        '*************************
        'Replace with this:
        'try entering data into a 2nd instance of the child table
        if count_items>0 then
        new_items = table.open("inv_items.dbf")
        for i=1 to count_items
        new_items.enter_begin()
        new_items.record_data_set(records[i])
        new_items.inv_no=hdr.inv_no
        new_items.enter_end(.t.)
        next
        new_items.close()
        end if ' count_items>0
        '*************************
        parent.resynch()
        end
        '------------------
        error_handler:
        on error goto 0
        end
        Bill Hanigsberg

        Comment


          #5
          RE: Duplicate code fails in 4.5.266

          Bill,

          What does this mean?

          while i i=i+1
          There can be only one.

          Comment


            #6
            RE: Duplicate code fails in 4.5.266

            Hi Stan,

            It means that I made a clerical error getting the code on to the board. I've carefully checked to verify that this typo exists nowhere else in my chain of working copies.

            Sorry for the distraction.

            Thanks,
            Bill
            Bill Hanigsberg

            Comment


              #7
              RE: Duplicate code fails in 4.5.266

              Bill,

              You didn't make a typo, it's just a consequence of pasting text that includes code that looks like html code (starting with the less than sign).

              A headache of this board to be sure.

              Regards,

              Ira J. Perlow
              Computer Systems Design & Associates
              [email protected]
              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


              Comment


                #8
                RE: Duplicate code fails in 4.5.266

                Thanks Ira,

                I couldn't imagine how I'd done that.

                Bill
                Bill Hanigsberg

                Comment


                  #9
                  RE: Duplicate code fails in 4.5.266

                  Ah so! Then the code really is:


                  ''XBasic
                  'duplicate composite record
                  on error goto error_handler
                  dim hdr as p
                  dim items as p
                  dim old_parent as b
                  dim count_items as n
                  dim i as n

                  'debug(1)

                  hdr=table.current(1)
                  items=table.current(2)
                  count_items = count(Inv_Items->Inv_No,GRP->INV_HDR)
                  if count_items>0 then
                  dim records[count_items] as b
                  i=0
                  items.fetch_first()
                  while i " count_items
                  i=i+1
                  records[i]=items.record_data_get()
                  items.fetch_next()
                  end while
                  end if 'count_items>0

                  old_parent=hdr.record_data_get()

                  hdr.enter_begin()
                  ' note, in this table the inv_no is an autoincrement field
                  ' a new inv_no is assigned by the field rule,
                  ' which overrides the Xbasic record_data_set()
                  hdr.record_data_set(old_parent)
                  hdr.enter_end(.t.)

                  '*************************
                  'Remove this:
                  'if count_items>0 then
                  ' for i=1 to count_items
                  ' items.enter_begin()
                  ' items.record_data_set(records[i])
                  ' items.inv_no=hdr.inv_no
                  ' items.enter_end(.t.)
                  ' next
                  'end if ' count_items>0
                  '*************************
                  'Replace with this:
                  'try entering data into a 2nd instance of the child table
                  if count_items>0 then
                  new_items = table.open("inv_items.dbf")
                  for i=1 to count_items
                  new_items.enter_begin()
                  new_items.record_data_set(records[i])
                  new_items.inv_no=hdr.inv_no
                  new_items.enter_end(.t.)
                  next
                  new_items.close()
                  end if ' count_items>0
                  '*************************
                  parent.resynch()
                  end
                  '------------------
                  error_handler:
                  on error goto 0
                  end

                  If anyone wants to experiment.
                  There can be only one.

                  Comment

                  Working...
                  X