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

lost in loop

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

    lost in loop

    I have totally lost myself in a loop. Here is what I am trying to do:

    Open table
    set filter/order
    fetch first matching record
    open second table
    set filter/order
    fetch first matching record
    edit record in second table
    edit record in first table

    If I need to enter a new record in the second table, I have no problems. But since I need to find a matching record in the second table so that I can edit it, I am totally brain dead. The filter for the second table should be the matching inv_id fields.

    Here is my code when I want to enter a new record in the second table. Can somebody tell me where I need to make my modifications so that I can change the matching record in the second table?
    Code:
    dim t_source as P
    dim t_dest as P
    dim global vcgInv_ID as c
    
    t_source = table.open("nceinvn")  'get here if valid serial number, so now we mark the records  
    query.filter = "(serial_num = var->vcgSerialNum) .AND. (ship_num= \"\")"
    query.options = "" 
    qry = t_source.query_create() 
    count = qry.records_get()
    
    t_source.fetch_first()    'fetch first in filtered list
    while .NOT. t_source.fetch_eof()
        t_dest = table.open("atvendor")    
        t_dest.enter_begin(.t.)
        t_dest.inv_id = t_source.Inv_id
        t_dest.atv_id = REMSPECIAL(API_UUIDCREATE())
        t_dest.vendor = vcgVendor
        t_dest.atv_shipno = vcgAtvShipNum
        t_dest.Rma = vcgRMA    '20060705 CKL added
        t_dest.Ven_out = date()
        t_dest.enter_end(.t.)
        
        xbasic_wait_for_idle()
    
        'Assign value to vcgInv_ID for use in filter when loading form
        vcgInv_ID = t_source.Inv_id
        
        xbasic_wait_for_idle()
    
        '20060702 CKL mark atven field to true
        t_source.change_begin(.t.)
        t_source.Atven = .t.
        t_source.change_end(.t.)
        
        xbasic_wait_for_idle()
        
       
        t_source.fetch_next()   'fetch the next record, should be none
    end while   
    
    
    t_source.query_detach_all()
    t_source.close()
    t_dest.close()
    
    xbasic_wait_for_idle()
    
    '=======================================================================
    The above code works great. Here is the garbage I have come up with to update a record in the second table, which is not even close to working. The filter is working on the first table, but the code never gets past that. I am not properly filtering/fetching the matching record in the second table, nor do I seem to be updating either record in the first or second table :(
    Code:
    dim t_source as P
    dim t_dest as P
    dim global vcgInv_ID as c
    
    t_source = table.open("nceinvn")  'get here if valid serial number, so now we mark the records  
    query.filter = "(serial_num = var->vcgSerialNum) .AND. (ship_num = \"\") .AND. (atven = .t.)"
    query.options = "" 
    qry = t_source.query_create() 
    count = qry.records_get()
    
    t_source.fetch_first()    'fetch first in filtered list
    'Assign value to vcgInv_ID for use in filter when loading form
    vcgInv_ID = t_source.Inv_id
    while .NOT. t_source.fetch_eof()
        t_dest = table.open("atvendor")    
        query.filter = "(inv_id = var->vcgInv_ID)"
        query.options = "" 
        qry2 = t_dest.query_create() 
        count2 = qry2.records_get()
        t_dest.fetch_first()
        while .NOT. t_dest.fetch_eof()
            t_dest.change_begin(.t.)
             t_dest.Ven_in = vdgDateIn
               t_dest.change_end(.t.)
        t_dest.fetch_next()
        end while
        
            xbasic_wait_for_idle()
    
        'Assign value to vcgInv_ID for use in filter when loading form
        'vcgInv_ID = t_source.Inv_id
        
        'xbasic_wait_for_idle()
    
            '20060702 CKL mark atven field to false
            t_source.change_begin(.t.)
            t_source.Atven = .f.
            t_source.change_end(.t.)
        
            xbasic_wait_for_idle()
           
            t_source.fetch_next()   'fetch the next record, should be none
    end while   
    
    t_source.query_detach_all()
    t_source.close()
    t_dest.query_detach_all()
    t_dest.close()
    Cheryl
    #1 Designs By Pagecrazy
    http://pagecrazy.com/

    #2
    Re: lost in loop

    Actually, the second table matching record is getting updated properly. The date in field is populated with the current date as expected, but that is where the script ends and gets lost.

    In actuallity, there is only one record in each table that will match the filters set.
    Cheryl
    #1 Designs By Pagecrazy
    http://pagecrazy.com/

    Comment


      #3
      Re: lost in loop

      Are you sure the filter is working in the first instance? Seems

      Code:
      query.filter = "(serial_num = var->vcgSerialNum) .AND. (ship_num= \"\")"
      should be

      Code:
      query.filter = "(serial_num = "+quote(var->vcgSerialNum)+") .AND. (ship_num= \"\")"
      and

      Code:
      query.filter = "(serial_num = var->vcgSerialNum) .AND. (ship_num = \"\") .AND. (atven = .t.)"
      should be

      Code:
      query.filter = "(serial_num = "+quote(var->vcgSerialNum)+") .AND. (ship_num = \"\") .AND. (atven = .t.)"
      assuming var->vcgSerialNum is character.

      And
      Code:
      query.filter = "(inv_id = var->vcgInv_ID)"
      should be

      Code:
      query.filter = "(inv_id = "+quote(var->vcgInv_ID)+")"
      There can be only one.

      Comment


        #4
        Re: lost in loop

        Yes the filters are working correctly when entering a new record in the second table and updating the existing record in the first table. I did, however, make the changes as you suggested since that is the proper syntax, and one day my filter probably will stop working.

        I don't think I will ever get my expressions right. You and Tom have given me so much help with expressions and I still can't seem to get them :(

        I do ok with my loops but only if they are simple loops. I always get lost when trying to do something different :(

        However, I did get it to work properly with the following:
        Code:
        dim t_source as P
        dim t_dest as P
        dim global vcgInv_ID as c
        
        t_source = table.open("nceinvn")  'get here if valid serial number, so now we mark the records  
        'query.filter = "(serial_num = var->vcgSerialNum) .AND. (ship_num = \"\") .AND. (atven = .t.)"
        uery.filter = "(serial_num = "+quote(var->vcgSerialNum)+") .AND. (ship_num = \"\") .AND. (atven = .t.)"
        query.options = "" 
        qry = t_source.query_create() 
        count = qry.records_get()
        
        t_source.fetch_first()    'fetch first in filtered list
        'Assign value to vcgInv_ID for use in filter when loading form
        vcgInv_ID = t_source.Inv_id
        while .NOT. t_source.fetch_eof()
            t_dest = table.open("atvendor")    
            query.filter = "inv_id = " + quote(var->vcgInv_ID)
            query.options = "" 
            qry2 = t_dest.query_create() 
            count2 = qry2.records_get()
            t_dest.fetch_first()
            while .NOT. t_dest.fetch_eof()
                t_dest.change_begin(.t.)
                 t_dest.Ven_in = vdgDateIn
                   t_dest.change_end(.t.)
            
                xbasic_wait_for_idle()
        
            'Assign value to vcgInv_ID for use in filter when loading form
            'vcgInv_ID = t_source.Inv_id
            
            'xbasic_wait_for_idle()
        
                '20060702 CKL mark atven field to false
                t_source.change_begin(.t.)
                t_source.Atven = .f.
                t_source.change_end(.t.)
            
                xbasic_wait_for_idle()
               
                t_source.fetch_next()   'fetch the next record, should be none
            t_dest.fetch_next()
            end while
        end while   
        
        t_source.query_detach_all()
        t_source.close()
        t_dest.query_detach_all()
        t_dest.close()
        Edited: Now to go clean up my code tabs and commented out garbage so I can read it and understand it later :)
        Cheryl
        #1 Designs By Pagecrazy
        http://pagecrazy.com/

        Comment

        Working...
        X