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

help in terminating a "while" routine

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

    #16
    Re: help in terminating a "while" routine

    guys,

    i will make explain more and will attach a screen shot.

    i have products table w/h u can see above portion of the form.
    2 grids, 1 for sales and 1 for purchases.
    i made 2 calculated fields to total all purchases and sales respectively to get total of all sales and all purchases per item.
    i then post these values to the primary table w/c is products on fields purchases and sales field. then i subtract sales from purchases to get the qty_oh.

    im doing this in form level just to save me from creating codes for the total() of transactions per item and also some filtering...

    hopes this clarifies things
    Francis

    Comment


      #17
      Re: help in terminating a "while" routine

      martin and gabriel,

      i thought of a workaround... i dont know if this will work and also dont know how to get the value of the record number.

      what i have in mind is fetch the last record and store the recno to a variable which we can test if it reaches this number and will end the while routine...

      the this i dont know how to get the current recno...


      Code:
      dim txtable as p
      dim vLast as n
      
      txtable = table.current()
      txtable.fetch_last()
      vLast = recno() ' is recno returns numeric?
      txtable.fetch_first()
      
      while .not. txtable.recno() = vLast
      	PURCHASES.value = PURCHASED_TOT.value
      	SALES.value = SALES_TOT.value
      	QTY_OH.value = PURCHASES.value - SALES.value
      	
      	topparent.commit()
      	
      	:process_data.Fetch_Next()
      
      end while
      
      ui_msg_box("TLCSYS", "Processing comleted...",UI_INFORMATION_SYMBOL+UI_OK)
      will this work?
      Francis

      Comment


        #18
        Re: help in terminating a "while" routine

        Originally posted by martinwcole View Post
        If you use my original script, then yes, you would use tablesum()

        but just for the fun of it try my line where I put

        while .not. parentform:tables.parent table name here.fetch_eof()
        (note:this presumes the calculated fields are all up-to-date)

        otherwise, I think my original script with tablesum() would be necessary
        martin,

        i tried using :process_date.fetch_eof() '<--it doesnt show on the auto complete list
        the form doesnt support to go eof
        Francis

        Comment


          #19
          Re: help in terminating a &quot;while&quot; routine

          Francis,
          There is a reason not to mix table and form levels when writing code....it is problematic at best. Keep them separate and try some of the suggestions.

          EOF is a table method and would be totally surprised if it worked at a form level.
          Mike
          __________________________________________
          It is only when we forget all our learning that we begin to know.
          It's not what you look at that matters, it's what you see.
          Henry David Thoreau
          __________________________________________



          Comment


            #20
            Re: help in terminating a &quot;while&quot; routine

            mike,

            i wish i could do them all in table level. i dont know how to use tablesum(). my apology to all.

            this code did worked.

            Code:
            'Date Created: 11-Jul-2010 04:43:15 PM
            'Last Updated: 11-Jul-2010 11:29:31 PM
            'Created By  : RT Angeles
            'Updated By  : fdd
            
            dim txtable as p
            txtable = table.current()
            txtable.fetch_last()
            vLast = txtable.recno()
            
            txtable.fetch_first()
            
            while .not. txtable.fetch_eof()
            	
            	PURCHASES.value = PURCHASED_TOT.value
            	SALES.value = SALES_TOT.value
            	QTY_OH.value = PURCHASES.value - SALES.value
            	
            	topparent.commit()
            	
            	:process_data.Fetch_Next()
            	if txtable.recno() = vLast then
            	    exit while
            	end if
            
            end while
            
            ui_msg_box("TLCSYS", "Processing completed...",UI_INFORMATION_SYMBOL+UI_OK)
            thanks
            Francis

            Comment


              #21
              Re: help in terminating a &quot;while&quot; routine

              As I suspected:
              1-You are trying to do alpha's work (calcuating values from the child)
              2-You are trying to calculate values from the child and post to the parent


              First off: table.current() will send a pointer to the topparent in the set. If you want to point to a child, use the proper number, e.g. table.current(2) or 3 or whatever the rank is. Your script as it is only shuffles through the topparent.

              Second, all you need is calc field for each one of these calculations using dbsum(). You don't need any scripts, a calc field is much better in this scenario.

              Comment


                #22
                Re: help in terminating a &quot;while&quot; routine

                Gabriel,

                my apology of not making it clear. im not that good in explaining of what i have in mind.

                the reason why i made this is to fix the qty on hand in my products table. i dont why the posting failed to get the accurate qty.

                data on my report shows like this example.

                code prod description purchased sold qty_oh
                0001 item description 10 2 6

                the owner wants to see the report in accurate output thats why i did this routine. but the thing is, after the last record, it creates a blank record on and on that i have to end task alpha.

                i was about to compare a while ago that in vfp, you can go eof at form level. (forgot to add this line when i told you i was doing this in alpha)

                regards
                Francis

                Comment


                  #23
                  Re: help in terminating a &quot;while&quot; routine

                  Francis:
                  Let me see if I could walk you through your code and try to explain why it doesn't work:
                  Code:
                  dim txtable as p
                  txtable = table.current() [COLOR="Blue"]this sends a pointer to the parent table, not the child[/COLOR]
                  txtable.fetch_first()
                  
                  while .not. txtable.fetch_eof()
                  	PURCHASES.value = PURCHASED_TOT.value[COLOR="Blue"]'this and the next 2 lines assign values to either fields in your table or variables. I don't know if these are fields in the parent or the child table.[/COLOR]
                  	SALES.value = SALES_TOT.value
                  	QTY_OH.value = PURCHASES.value - SALES.value
                  	
                  	topparent.commit()
                  	
                  	:process_data.Fetch_Next()[COLOR="Blue"]'this fetch the next record in the parent. After the very last loop, it will create a new record and then save it and that's exactly what you see, flashing (looping through all parent's records) then a new blank record[/COLOR]
                  
                  end while
                  To make things easier, post a zip file and indicate what you wish to do.
                  Last edited by G Gabriel; 07-11-2010, 12:30 PM.

                  Comment


                    #24
                    Re: help in terminating a &quot;while&quot; routine

                    If you are "stuck" doing it the way you are....as there is no function I know of to prevent going past the end of a browse/form record and creating a new record (as G has explained), there is a way to do this. Prior to any of the code, Fetch_Last() in your browse/form, set a variable to that record and then Fetch_First(). Then in your code, test for when the record equals the variable right before the Fetch_Next() and if it is the same, break out of the loop.

                    OR, and maybe the best idea, is to do as G last indicated....provide the sample.... :)
                    Mike
                    __________________________________________
                    It is only when we forget all our learning that we begin to know.
                    It's not what you look at that matters, it's what you see.
                    Henry David Thoreau
                    __________________________________________



                    Comment


                      #25
                      Re: help in terminating a &quot;while&quot; routine

                      mike and gabriel,

                      thank you so much in helping me.
                      my #20 post fixed my problem.

                      will post another issue... please read
                      Francis

                      Comment


                        #26
                        Re: help in terminating a &quot;while&quot; routine

                        You could avoid adding a new record by many different means, e.g. check the table mode, recno exceeded, certain values being blank etc. but that's not the issue. The issue is 1-Francis is shuffling the wrong table 2-with the object of summing up values 3-to post to the parent. None of that is happening here.

                        Comment

                        Working...
                        X