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

index & change_begin

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

    index & change_begin

    While .not. eof("archcomb")
    tarchcomb.fetch_next()
    tarchcomb.change_begin()
    ' tarchcomb.mark()
    cntmarked = cntmarked + 1
    tarchcomb.change_end()
    end while

    Problem: A change_begin, undoes the specified index.
    In the code used for testing above; if the commented line is left in as shown, the index\sequence is that desired. If the line is uncommented, the sequence does not retain the specified index.
    archcomb is the primary table in a set.
    Resolution. What must be done to maintained the specified index?

    #2
    Richard, there is no index specified in the script that you've shown.

    I think we're going to need to see the whole script and some information on the context in which it runs.

    Are you trying to mark records from the current position in your table to the eof, or are you trying to mark all the records in the table, or are you trying to mark all the records in a queried view?

    -- tom

    Comment


      #3
      Originally posted by Richard Froncek
      While .not. eof("archcomb")
      tarchcomb.fetch_next()
      tarchcomb.change_begin()
      ' tarchcomb.mark()
      cntmarked = cntmarked + 1
      tarchcomb.change_end()
      end while

      Problem: A change_begin, undoes the specified index.
      In the code used for testing above; if the commented line is left in as shown, the index\sequence is that desired. If the line is uncommented, the sequence does not retain the specified index.
      archcomb is the primary table in a set.
      Resolution. What must be done to maintained the specified index?
      I agree that we need more information. I do see that you are processing/marking records in "archcomb" order from the current record to the end of the table. I don't see why tarchcomb.change_begin() would discard the index. What are you seeing that leads you to know/believe that this is happening?
      There can be only one.

      Comment


        #4
        change_begin

        Index is called PL_Item: PL_ITEM + YEAR(SHIP_DATE) <===== INDEX
        '
        Dim tarchcomb as P
        '
        tarchcomb = table.open("C:\CDP7Hist\archcomb")
        tarchcomb.fetch_first()
        tarchcomb.unmark_range()
        tarchcomb.index_primary_put("Pl_Item")
        tarchcomb.close()
        '
        tarchcomb = table.open("C:\CDP7Hist\archcomb")
        tarchcomb.index_primary_put("Pl_Item")
        '
        Following used for testing: <===== Original submission =====>
        While .not. eof("archcomb")
        tarchcomb.fetch_next()
        tarchcomb.change_begin()
        ' tarchcomb.mark()
        cntmarked = cntmarked + 1
        tarchcomb.change_end()
        end while
        <===== Original submission ends =====>
        '
        I am only trying to mark selected records. How I know? I have a ui_msg diplay to indicate the record. It finds the first record I want, then jumps to the second record in the file. It definitely is not retaining the index.
        If this still isn't enough, I can supply all of the code. Tried to get pieces of the records to show, but niether a bit map or a Snagit picture to the clipboard permits it. I have spent a day testing this. the fact is, after the first "correct" record, the sequence desired is NOT maintained.
        Dick

        Comment


          #5
          Question about code

          Originally posted by Richard Froncek
          While .not. eof("archcomb")
          I don't use this construction so all I can do is surmise.

          In my original reading of the code I mistook the line to say something else.

          The documentation does recommend tblpointer.fetch_eof() over eof("tablename"). You are not reissuing the tarchcomb.fetch_first() after the second opening of the table though I'm not certain whether it would help.


          Possibly the while beginning line should be

          While .not. tarchcomb.fetch_eof()
          ?
          There can be only one.

          Comment


            #6
            Dick,

            I think the whole script is needed. Nothing in the portions you're showing thus far limits the range of records to be marked to those matching the selection criteria you mention the user specifies.

            Beyond that I think it's a bad practice to use the same pointer name twice in the same script. Your design indicates you think Alpha Five is going to wait to open the second instance of the table until the first "unmarking" sequence has finished. The script will not pause. The unmarking sequence will begin and then while that's going on Alpha will try to open the table again to begin the marking sequence (with a different index). Since you use the same pointer name I think it's understandable that confusion occurs.

            Suggest using different pointer names for each instance of the table that your script opens.
            Suggest using xbasic_wait_for_idle() before opening the second instance to begin the "marking" sequence. This will force the script to pause before beginning the "marking" sequence.

            -- tom
            Last edited by Tom Cone Jr; 02-01-2006, 01:32 PM.

            Comment


              #7
              Disregard my efforts.

              I was reading some things into your post that really aren't there like

              thinking you were using a filtered index

              misreading pointer.eof("indextagname") for eof("tablename")

              I think Tom is on the right track while I was wandering.
              There can be only one.

              Comment


                #8
                'Date Created: 04-Nov-2003 04:07:57 PM
                'Last Updated: 01-Feb-2006 01:28:49 PM
                'Created By : Richard A. Froncek
                'Updated By : Administrator
                ' plntsummary = Plant Summary
                '
                Dim tarchcomb as P
                Dim tbroker as P
                Dim tplants as P
                Dim global intodate as C
                Dim global todate as D
                Dim global infrmdate as C
                Dim global frmdate as D
                Dim global plant as C
                Dim global cust as C
                Dim global nomen as C 'Broker's name
                Dim global yr as C
                Dim shipday as C
                Dim nbrkr as N
                Dim nRec as N
                Dim yesno as C
                Dim brkr as C
                Dim Corp as C
                Dim cust as C
                Dim cntmarked as N
                cntmarked = 0
                nbrkr = 1
                cust = " "
                plant = " "
                nRec = 0
                '
                tarchcomb = table.open("C:\CDP7Hist\archcomb")
                tarchcomb.fetch_first()
                tarchcomb.unmark_range()
                tarchcomb.index_primary_put("Pl_Item")
                tarchcomb.close()
                xbasic_wait_for_idle()
                '
                tarchcomb = table.open("C:\CDP7Hist\archcomb")
                tarchcomb.index_primary_put("Pl_Item")
                plant = ui_get_text("PLANT:","Enter Plant Code",plant)
                'If plant = " "
                ' goto nogo
                'end if
                tplants = table.open("plants")
                tplants.index_primary_put("Account_Id")
                tplants.fetch_first()
                nRec = Reccount("plants")
                For I = 1 to nRec
                If tplants.Account_id = plant
                exit for
                end if
                tplants.fetch_next()
                If tplants.eof()
                ui_msg_box("No such plant"," ")
                ' goto nogo
                end if
                next
                nRec = 0
                ui_msg_box("Earliest Ship_date is 01/01/2000"," ")
                infrmdate = ui_get_date("Begin Date:","First date included _","01/01/2006")
                frmdate = ctod(infrmdate)
                intodate = ui_get_date("End Date:","Final date included _","12/31/2006")
                todate = ctod(intodate)
                yr = year(frmdate)
                '
                yesno = ui_get_text("Customer","For All Customers Yes (Y) or No (N)?","Y", yesno)
                'If yesno = " "
                ' goto nogo
                'end if
                If yesno = "Y" .OR. yesno = "y"
                goto tryagain
                end if
                cust = ui_get_text("Customer:","Enter Customer Code",cust)
                'If cust = " "
                ' goto nogo
                'end if
                '
                tryagain:
                Corp = ui_get_text("Corprate","For Company (C)or Salesman (S)?","C", Corp)
                If Corp = "C" .OR. Corp = "c"
                nbrkr = 0
                goto loopem
                end if
                If Corp = "S" .OR. Corp = "s"
                brkr = ui_get_text("Seller","Enter Salesman's Number?","1",brkr)
                nbrkr = val(brkr)
                ui_msg_box("Broker: ", str(nbrkr))
                goto rep
                end if
                goto tryagain
                wrongnumber:
                rep:
                If nbrkr > 9
                goto wrongnumber
                end if
                loopem:
                tbroker = table.open("broker")
                tbroker.fetch_first()
                If nbrkr = 0 .AND. tbroker.Bkrid = 0
                nomen = tbroker.Bkrname
                goto brkset
                end if
                nRec = Reccount("broker")
                tbroker.fetch_next()
                For I = 1 to nRec
                tbroker.change_begin()
                If tbroker.Bkrid = nbrkr
                nomen = tbroker.Bkrname
                ui_msg_box("Broker: ", nomen)
                end if
                tbroker.change_end()
                tbroker.fetch_next()
                If I = nbrkr
                exit for
                end if
                next
                brkset:
                tbroker.close()
                hourglass_cursor(.T.)
                tarchcomb.fetch_find(plant)
                If tarchcomb.eof()
                goto finale
                end if
                If tarchcomb.Plant_code > plant
                goto finale
                end if
                While .not. tarchcomb.fetch_eof()
                If yesno = "Y" .OR. yesno = "y"
                goto allcust
                else
                goto solecust
                end if
                If yesno = "N" .OR. yesno = "n"
                While tarchcomb.Plant_code < plant
                tarchcomb.fetch_next()
                end while
                end if
                allcust:
                While tarchcomb.Plant_code = plant
                If tarchcomb.Ship_date < frmdate .OR. tarchcomb.Ship_date > todate
                tarchcomb.fetch_next()
                goto bypass1
                end if
                tarchcomb.change_begin()
                If nbrkr = 0 .AND. tarchcomb.Plant_code = plant
                tarchcomb.mark()
                cntmarked = cntmarked + 1
                end if
                If nbrkr > 0 .AND. tarchcomb.Plant_code = plant .AND. tarchcomb.Seller = nbrkr
                tarchcomb.mark()
                cntmarked = cntmarked + 1
                end if
                tarchcomb.change_end()
                tarchcomb.fetch_next()
                If tarchcomb.Plant_code > plant
                goto finale
                end if
                bypass1:
                end while
                goto finale
                solecust:
                While tarchcomb.Plant_code = plant .AND. tarchcomb.Cust_code = cust
                If tarchcomb.Ship_date < frmdate .OR. tarchcomb.Ship_date > todate
                tarchcomb.fetch_next()
                goto bypass2
                end if
                tarchcomb.change_begin()
                If nbrkr = 0 .AND. tarchcomb.Plant_code = plant
                tarchcomb.mark()
                cntmarked = cntmarked + 1
                end if
                If nbrkr > 0 .AND. tarchcomb.Plant_code = plant .AND. tarchcomb.Seller = nbrkr
                tarchcomb.mark()
                cntmarked = cntmarked + 1
                end if
                tarchcomb.change_end()
                tarchcomb.fetch_next()
                If shipday > yr
                exit while
                end if
                If tarchcomb.Cust_code > cust .OR. tarchcomb.Ship_date > todate .OR. \
                tarchcomb.Plant_code > plant .OR. tarchcomb.eof()
                exit while
                end if
                If tarchcomb.Cust_code <> cust
                tarchcomb.unmark()
                end if
                bypass2:
                end while
                end while
                finale:
                hourglass_cursor(.F.)
                ui_msg_box("Records Marked", str(cntmarked))
                :Report.Preview("PlantSummary")
                nogo:
                tarchcomb.close()
                '=== Code above ===
                Have incorporated both Stan & Tom's comments, except for 1st & 2nd instances.
                It still does not retain the specified index. After correctly finding the first record, the sequence requested is deep-sixed (found through rec idenification, debugging).
                Have tried skinning the cat an alternate way via a query. However it is too cumbersome:
                a) cannot enter four parameters
                1) date
                2) plant
                3) customer
                4) broker
                b) the query input parameters don't\won't appear on the report; askc_plant & askd_date (specified in the 'variable' section of the report)
                c) the Action scripting to accomodate the query does not complete,i.e., it "hangs" on the browse being opened and does not the close browse and return to a menu specified.
                Thanks for all the help.
                Dick

                Comment


                  #9
                  Dick,

                  If it were me, I'd break the script down into it's separate components. You have several looping sequences that must occur in the correct order. I'd pull each of them out of the script and put them in separate scripts for testing and debugging. Once each is running correctly your script can be re-written to simply "play" each of the sub-scripts, so to speak.

                  I see you're ignoring my advice about re-use of pointer variables.

                  Assuming you want each looping sequence to conclude before the next begins, you have to use xbasic_wait_for_idle() each time, as explained above. For some reason you only use it once in the entire script, unless I'm missing something here. Think of it this way. Whenever your script interacts with the hard drive you should pause it. (on each fetch, and on each commit) Once you have the script running you may find that you can remove some of them without causing timing problems. At minimum I would expect you'll wind up needing it after each of the looping sequences.

                  -- tom

                  Comment


                    #10
                    Thanks Tom Will give it a try. Guess I didn't\don't understand the re-use of pointer variables. Your suggestion of separate scripts sounds like a winner.
                    Thanks again.

                    Comment


                      #11
                      Tom, did as you sugested. No better luck. I isolated the records using a query, marked 'em and then appended them to a temporary file (after zapping it). There are twenty-two records in the file. However running the the modified code (from above), the count is 251 records. The report is correct. By marking the records in the temp file (they don't come over marked), I could just run the report, but as I said, I can't get the Askc_plant and Askd_date into\on to the report. Five crazy days spent working on this, but A5V7 seems to want to do it's own sequencing in processing. Go figure.
                      Dick

                      Comment


                        #12
                        Dick,
                        I wouldn't want to kick you when you're down, but I'm not sure your script would ever do the same thing twice, starting almost from the beginning. This code segment:
                        Code:
                        tarchcomb = table.open("C:\CDP7Hist\archcomb")
                        tarchcomb.fetch_first()
                        tarchcomb.unmark_range()
                        tarchcomb.index_primary_put("Pl_Item")
                        tarchcomb.close()
                        will, I think, cause problems. If you don't supply an actual filter of your own to the unmark_range() method, then the last query or filter is used. I think what you want is for all records to be unmarked, which you can do rather simply with
                        Code:
                        tarchcomb = table.open("C:\CDP7Hist\archcomb")
                        tarchcomb.unmark_range(.t.)
                        Then you have a cumbersome way of looking for matching records. Instead of using queries, you do repetitive looping for matches. Once again, your code is:
                        Code:
                        tplants = table.open("plants")
                        tplants.index_primary_put("Account_Id")
                        tplants.fetch_first()
                        nRec = Reccount("plants")
                        For I = 1 to nRec
                        If tplants.Account_id = plant
                        exit for
                        end if
                        tplants.fetch_next()
                        If tplants.eof()
                        ui_msg_box("No such plant"," ")
                        ' goto nogo
                        end if
                        next
                        This can be simplified and sped up greatly with
                        Code:
                        tplants = table.open("plants")
                        query.filter="account_id="+quote(plant)
                        query.order=""
                        query.options="T"
                        ix=tplants.query_create()
                        if ix.records_get=0 then
                           ui_msg_box("","No such plant")
                        end if
                        You do this kind of looping over and over again, and it's difficult to figure out what you're doing. Instead of looping over portions of indexes you'd be much better off with queries.
                        Then you have
                        Code:
                        tarchcomb.fetch_find(plant)
                        ...many lines of more code
                        which again would be a lot simpler with
                        Code:
                        query.filter="plant_code="+quote(plant)+\
                        " .and. between(ship_date,{"+dtoc(frmdate)+"},{"+\
                        dtoc(todate)+"})"
                        query.order="ship_date"
                        query.options="T"
                        ix=tarchcomb.query_create()
                        tarchcomb.fetch_first()
                         cntmarked=0
                         while .not. tarchcomb.fetch_eof()
                         cntmarked=cntmarked+1
                         tarchcomb.change_begin()
                          select
                           case nbrkr=0 
                              tarchcomb.mark()
                           case nbrkr>0 .and. tarchcomb.Seller = nbrkr
                              tarchcomb.mark()
                          end select
                          tarchcomb.change_end()
                         tarchcomb.fetch_next()
                        end while
                        I think you'll not only find your code is easier to understand if you use queries, but it will execute faster.
                        Good luck!

                        Comment


                          #13
                          Thanks Peter. Will certainly take your advice. Will redo per your suggestions. Thanks again.
                          Dick

                          Comment


                            #14
                            Peter, the case gets stranger and stranger.
                            1) tarchcomb.unmark_range() works, with the '.T.' in the parens, it blows up.
                            2) the line
                            if ix.records_get=0 then
                            also blows up with the following,
                            "Not Found
                            ix.records_get subelement not found"
                            Further, I cannot find records_get in the help file.
                            3) After it aborts and I check the plants table, there is only one record in it, the selected plant. I have to do a compact to make all the records accessible.
                            Just thought I'd provide some feedback. A walk in the sun somehow turns into the perfect storm.
                            Thanks none-the-less, it does add to the learning experience.
                            Dick

                            Comment


                              #15
                              Peter, after replacing plant checking code with my original and substituting your marking code for mine, it works like a charm. Thank you very much. What a relief. Thanks again.
                              Dick

                              Comment

                              Working...
                              X