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

tbl.enter_begin(t)....tbl.enter_end(t)

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

    tbl.enter_begin(t)....tbl.enter_end(t)

    Could someone point me to my errors here? Am trying to add multiple records to a table via a button using xbasic. It calls an xdialog to get a Year value (xPlan_Yr) and then a Month value (xplan_Month).

    Code:
    if dialog_result = "OK" then
    	var->glo_Year = vPlan_Yr
    	dim tbl as p
    	tbl = table.current()
    	debug(1)
    	select
    	    case vPlan_Month = "January"
    	    	tbl.enter_begin(.t.)
    			tbl.ap_sortno = 1
    			tbl.ap_month = "January"
    			tbl.ap_year = vPlan_Yr
    			tbl.enter_end(.t.)
    	    	tbl.enter_begin(.t.)
    			tbl.ap_sortno = 2
    			tbl.ap_month = "February"
     			tbl.ap_year = vPlan_Yr
    			tbl.enter_end(.t.)    [COLOR="Red"]<< error comes here[/COLOR]
    	end select
    end if
    Am trying to load all twelve months, but only using 2 for now because I keep getting the attached error on the second tbl.enter_end(t). Can't find what error 8003 is. The reason for getting the month is this determines the first month in the clients fiscal year for record keeping. There may be a better way to do this, but am trying to replicate an Excel program where it lists the months in order starting with the one chosen. So am showing it in a Browse.
    Any help greatly appreciated. Thanks.
    Ernie

    #2
    Re: tbl.enter_begin(t)....tbl.enter_end(t)

    This would be easier if you showed the entire script and furnished a sample database.

    It looks like a timing issue.

    But...

    Does your script check the mode of the table before it runs? You can't begin a new record if the table is in CHANGe or ENTER mode already.
    Last edited by Tom Cone Jr; 09-18-2008, 02:59 PM.

    Comment


      #3
      Re: tbl.enter_begin(t)....tbl.enter_end(t)

      I agree with Tom that it is a timing issue. Try something simple like placing xbasic_wait_for_idle() between your tbl.enter_end and tbl.enter_begin

      My guess is that your first tbl.enter_end did not have time to finish before you started entering again.

      Hope this helps ...

      Scott

      Comment


        #4
        Re: tbl.enter_begin(t)....tbl.enter_end(t)

        If it's a timing issue, you can put the "processing" portion of your script in a function. The script will halt each time the function runs, and will resume only after the function has completed. Here's a quick and dirty example that illustrates the technique.

        Code:
        tbl = table.open("customers")
        
        enter_new(tbl,"Bob",1)
        enter_new(tbl,"Sam",2)
        enter_new(tbl,"Tom",3)
        
        tbl.close()
        	
        Function enter_new as L (ptr as p, cust as C, sort as n)
        	ptr.enter_begin(.t.)
        	    ptr.name = cust
        	    ptr.idnum = ltrim(str(sort))
        	    ptr.enter_end(.t.)
        end function

        Comment


          #5
          Re: tbl.enter_begin(t)....tbl.enter_end(t)

          Appreciate all the suggestions. I kind of had and inkling it might be timing, but still new to a5. I'll give this a try and see what happens. If no luck, I'll post a zip of the app for further review.
          Thanks again.
          Ernie

          Comment


            #6
            Re: tbl.enter_begin(t)....tbl.enter_end(t)

            I used to have the same 8003 error when I used tbl.enter_begin().

            Now I use tbl.change_begin() - tbl.change_end() like this:
            Code:
            	dim tabla as P
            	tabla=table.get("control_dia")
            	tabla.add_blank_records(1)
            	tabla.change_begin(.T.)
            	   tabla.EMPRESA_ID=XEMPRESA
            	   tabla.UO_ID=XUO
            	   tabla.FECHA_PRODUCCION=xfecha
            	tabla.change_end(.T.)
            ANGEL

            Comment


              #7
              Re: tbl.enter_begin(t)....tbl.enter_end(t)

              Now I'm new to Alpha, but having programming experience, shouldn't you have a CASE statement for each month? It looks like you have Case statements missing between your monthly processing.

              Comment


                #8
                Re: tbl.enter_begin(t)....tbl.enter_end(t)

                Thanks, Angel. I am assuming I can add/change one right after the other????
                Code:
                	select
                	    case vPlan_Month = "January"
                                tbl.add_blank_records(12)
                                tbl.change_begin(.t.)
                			tbl.ap_sortno = 1
                			tbl.ap_month = "January"
                			tbl.ap_year = vPlan_Yr
                			tbl.change_end(.t.)
                	    	tbl.change_begin(.t.)
                			tbl.ap_sortno = 2
                			tbl.ap_month = "February"
                 			tbl.ap_year = vPlan_Yr
                			tbl.change_end(.t.) 
                                etc.........
                	end select
                Ernie

                Comment


                  #9
                  Re: tbl.enter_begin(t)....tbl.enter_end(t)

                  Code:
                  select
                  	    case vPlan_Month = "January"
                                  tbl.add_blank_records(12) [COLOR="Red"][B]' focus is now on the last record added[/B][/COLOR]
                                  tbl.change_begin(.t.) [COLOR="Red"]'begins changing that record[/COLOR]
                  			tbl.ap_sortno = 1
                  			tbl.ap_month = "January"
                  			tbl.ap_year = vPlan_Yr
                  			tbl.change_end(.t.)
                  	    	tbl.change_begin(.t.) [COLOR="red"]'haven't moved so we're changing the same record[/COLOR]
                  			tbl.ap_sortno = 2
                  			tbl.ap_month = "February"
                   			tbl.ap_year = vPlan_Yr
                  			tbl.change_end(.t.) 
                                  etc......... [COLOR="red"]'etc[/COLOR]
                  	end select
                  Last edited by Stan Mathews; 09-19-2008, 03:42 PM.
                  There can be only one.

                  Comment


                    #10
                    Re: tbl.enter_begin(t)....tbl.enter_end(t)

                    Try it like this.

                    Code:
                    SELECT
                    	CASE vPlan_Month = "January"
                    		tbl.add_blank_records(12)
                    		[COLOR="Blue"]FOR i = 1 TO 11
                    			tbl.fetch_prev()
                    		NEXT i[/COLOR]
                    		[COLOR="Red"]'now we're back to first added record[/COLOR]
                    		tbl.change_begin(.t.)
                    		tbl.ap_sortno = 1
                    		tbl.ap_month = "January"
                    		tbl.ap_year = vPlan_Yr
                    		tbl.change_end(.t.)
                    		[COLOR="blue"]tbl.fetch_next() [/COLOR][COLOR="red"]'now on second added record[/COLOR]
                    		tbl.change_begin(.t.)
                    		tbl.ap_sortno = 2
                    		tbl.ap_month = "February"
                    		tbl.ap_year = vPlan_Yr
                    		tbl.change_end(.t.)
                    		[COLOR="blue"]tbl.fetch_next()[/COLOR][COLOR="red"]'now on third added record[/COLOR]
                    		'etc.........
                    END SELECT
                    There can be only one.

                    Comment


                      #11
                      Re: tbl.enter_begin(t)....tbl.enter_end(t)

                      Thanks Stan. It didn't dawn on me that the tbl.add_blank_records(12) was adding them right then, all at once. That makes perfect sense. Appreciate the help in this.
                      Ernie

                      Comment


                        #12
                        Re: tbl.enter_begin(t)....tbl.enter_end(t)

                        RE: tbl.add_blank_records(12)
                        This should work really well in a networked situation. User A adds 12 records. At the same point in time, user B adds 12 records. Then user A moves back 12 records. Will user A really end up where he started or could some of user B's records be intermixed? Not likely to happen often but what if it does? Or is there an "exclusive access" built into the add_blank_records function? I'd want to know before I implemented this but I don't see the answer in the Help file.

                        I think there has to be something else going on with the initial problem even though the part of the script we see looks OK. Otherwise, (a) running it with the Debug(1) should solve the timing issue and (b) running a WHILE loop to enter records would be likely to cause the same problem (and it's something I've done more than once with no problem) and (c) why would the "add_blank_records()" work if timing was a problem?

                        You might try eliminating the .T. in the enter_begin() unless there's some reason you really need it. Using this will try to enforce some additional field rules but normally you should be checking those before entering new data via xbasic anyway. Otherwise your script will just be generating errors that the users will have to decipher and resolve - or call you to fix - and this may result in bad data if the first few records get added but not the last ones.

                        FWIW: You probably don't need the .T. in the enter_end() either. The .T. in the enter_end() is only there to tell it 'yes, I want to save this record' but that's the default anyway. The only time I've used this is the rare situation when I'm doing development and don't want to actually save the record because it would negatively affect subsequent testing - i.e., I need the info in that record to NOT be there in order to test the routine and I may need to test the routine many times. Then, in most cases, I will set a variable at the beginning of the script so I can set it to .F. when I don't want to save anything or to .T. when I do want to save things. Once it goes into production, I usually remove all those variables but sometimes I just set them to .T. and leave them. Hmmm, I said "usually" but can only recall doing this once in about 15 years.
                        Last edited by CALocklin; 09-21-2008, 12:35 AM.

                        Comment


                          #13
                          Re: tbl.enter_begin(t)....tbl.enter_end(t)

                          Originally posted by ewagner View Post
                          Now I'm new to Alpha, but having programming experience, shouldn't you have a CASE statement for each month? It looks like you have Case statements missing between your monthly processing.
                          I assume there will be once s/he gets January to work correctly.

                          Comment


                            #14
                            Re: tbl.enter_begin(t)....tbl.enter_end(t)

                            Cal,
                            As always, thank you for a full explanation. Here again, I have read into the help files about the .t. in the begin and end statements that I needed it there to make sure my auto-increment fields got incremented properly. After further reading, I think I am way off base. I still don't fully understand what the purpose is for, i.e. field rules...., but don't think it is for making sure my auto fields get incremented.
                            I think there has to be something else going on......
                            I fully agree. I think I'll continue to play with it a bit and see what transpires.
                            Thanks again for the explanations.
                            Ernie

                            FWIW: I took out the .t. from begin and end and removed the xbasic_wait _for_idle statement and ran it and it added the records just fine.
                            Last edited by enstorms; 09-21-2008, 10:35 AM.

                            Comment


                              #15
                              Re: tbl.enter_begin(t)....tbl.enter_end(t)

                              Originally posted by enstorms View Post
                              FWIW: I took out the .t. from begin and end and removed the xbasic_wait _for_idle statement and ran it and it added the records just fine.
                              Now that's interesting! It was only a wild guess on my part. (Here's a secret - that's how a lot of my solutions are found.)

                              I checked the Help file and found this very significant note:
                              Note : The Field_Rules_Flag parameter is only honored if the <TBL> pointer is the same pointer that a layout is using. For example,....
                              This doesn't tell me why it didn't work in your case but it does give me the feeling that it was trying to do something it couldn't do and therefore timing became more of an issue. But here's the real reason why this note is important....

                              I know that in my apps many of the situations where I'm entering data via xbasic are NOT entering it into the same table as the parent form. Also note that the above Note says, "the <TBL> pointer is the same pointer that a layout is using". It does not say, "the <TBL> pointer points to the same table as the layout is using". This is a BIG difference. The way I read this is that
                              tbl = table.open( "<TheSameTableastheForm>" )
                              won't do it because the "tbl" pointer does not actually point to the layout but
                              tbl = table.get( "<ATableintheForm>" )
                              or
                              tbl = table.current(n) (where "n" is the table number if not the parent)
                              or
                              tbl = parentform:tables:<ATableintheForm>.this
                              should work.

                              Edit: I think the original wording in the Help file would be more correct and/or more understandable like this:
                              ... if the <TBL> pointer is pointing to a table in the same session as the layout is using ...Unfortunately even that isn't very clear so examples are the best way to understand this. Hopefully my examples are correct - no absolute guarantees on that.
                              Last edited by CALocklin; 09-21-2008, 12:39 PM.

                              Comment

                              Working...
                              X