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

very frequent a5 crashes

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

    very frequent a5 crashes

    A5 has crashed on me more than 10 times since yesterday morning.

    It happens frequently but not consistantly when running the following xbasic from a button push.

    Code:
    	'************************************************************
    'open the cl_team form. Get id and delete record.
    '************************************************************		
    dim clid as c
    dim tbl as p
    tbl = table.open("cl_team",FILE_RW_SHARED)
    
    tbl.fetch_first()
    tbl.batch_begin()
    while .not. tbl.fetch_eof()
    	
    if tbl.Picked= .t. then
    		clid = tbl.cl_id
    		'***delete client for cl_team table
    		tbl.change_begin(.t.)
    		tbl.delete()
    		tbl.change_end(.t.)
    		
    		
    		'**************************
    		'***open the clients table
    		'**************************
    		dim atbl as p
    		atbl=table.open("clients",FILE_RW_SHARED)
    		
    		'***filter to client id
    		atbl.index_primary_put("client_id")
    		atbl.fetch_find(var->clid)
    
    		
    		'***delete the clients picture if it exists
    		dim img as c
    		img=atbl.Client_picture
    		dim name as c
    		dim bname as c
    		dim fullpath as c
    		name = word(img,-1,"\\",1)
    		bname=word(name,1,chr(34))
    		fullpath=a5.get_path()+chr(92)+"images"+chr(92)+"ClientPictures"+chr(92)+bname
    		if file.exists(fullpath) then
    			file.remove(fullpath)
    		end if
    		
    		'***delete the client
    		atbl.change_begin()
    		atbl.delete()
    		atbl.change_end(.t.)
    		atbl.close()
    								
    		'**************************
    		'***open the cl_exer table
    		'**************************
    		dim btbl as p
    		btbl=table.open("cl_exer",FILE_RW_SHARED)
    		btbl.delete_range("client_id="+s_quote(clid))
    		btbl.close()
    			
    		'**************************
    		'***open the cl_workout table
    		'**************************
    		dim ctbl as p
    		ctbl=table.open("cl_wrkout",FILE_RW_SHARED)
    		ctbl.delete_range("client_id="+s_quote(clid))
    		ctbl.close()	
    		
    		'**************************
    		'***open the cl_notes table
    		'**************************
    		dim dtbl as p
    		dtbl=table.open("cl_notes",FILE_RW_SHARED)
    		dtbl.delete_range("client_id="+s_quote(clid))
    		dtbl.close()
    			
    end if	
    
    	
    end while	
    tbl.batch_end()
    tbl.close()
    '************************************************************
    'refresh the form
    '************************************************************
    athlete_Browse.refresh()
    athlete_Browse.fetch_first()

    Does anything in this script look like it may cause an a5 crash?

    I did do a one step doc with the a5 documenter addin yesterday morning as well. I do not know if that has done something.

    Any thoughts would be appreciated.
    Tony

    #2
    Re: very frequent a5 crashes

    I have added several msgbox's to see if I could figure out where it is hanging up:

    Code:
    		msgbox("","0")
    	'************************************************************
    'open the cl_team form. Get id and delete record.
    '************************************************************		
    dim clid as c
    dim tbl as p
    tbl = table.open("cl_team",FILE_RW_SHARED)
    	msgbox("","0a")
    tbl.fetch_first()
    tbl.batch_begin()
    while .not. tbl.fetch_eof()
    	msgbox("","0b")
    if tbl.Picked= .t. then
    	msgbox("","1")
    		clid = tbl.cl_id
    		'***delete client for cl_team table
    		tbl.change_begin(.t.)
    		tbl.delete()
    		tbl.change_end(.t.)
    		
    		
    		'**************************
    		'***open the clients table
    		'**************************
    	msgbox("","2")
    		dim atbl as p
    		atbl=table.open("clients",FILE_RW_SHARED)
    		
    		'***filter to client id
    		atbl.index_primary_put("client_id")
    		atbl.fetch_find(var->clid)
    
    	msgbox("","3")		
    		'***delete the clients picture if it exists
    		dim img as c
    		img=atbl.Client_picture
    		dim name as c
    		dim bname as c
    		dim fullpath as c
    		name = word(img,-1,"\\",1)
    		bname=word(name,1,chr(34))
    		fullpath=a5.get_path()+chr(92)+"images"+chr(92)+"ClientPictures"+chr(92)+bname
    		if file.exists(fullpath) then
    			file.remove(fullpath)
    		end if
    	msgbox("","4")		
    		'***delete the client
    		atbl.change_begin()
    		atbl.delete()
    		atbl.change_end(.t.)
    		atbl.close()
    	msgbox("","5")								
    		'**************************
    		'***open the cl_exer table
    		'**************************
    		dim btbl as p
    		btbl=table.open("cl_exer",FILE_RW_SHARED)
    		btbl.delete_range("client_id="+s_quote(clid))
    		btbl.close()
    	msgbox("","6")			
    		'**************************
    		'***open the cl_workout table
    		'**************************
    		dim ctbl as p
    		ctbl=table.open("cl_wrkout",FILE_RW_SHARED)
    		ctbl.delete_range("client_id="+s_quote(clid))
    		ctbl.close()	
    	msgbox("","7")		
    		'**************************
    		'***open the cl_notes table
    		'**************************
    		dim dtbl as p
    		dtbl=table.open("cl_notes",FILE_RW_SHARED)
    		dtbl.delete_range("client_id="+s_quote(clid))
    		dtbl.close()
    			
    end if	
    
    	
    end while	
    tbl.batch_end()
    tbl.close()
    '************************************************************
    'refresh the form
    '************************************************************
    athlete_Browse.refresh()
    athlete_Browse.fetch_first()
    it displays msgbox("","0b"). I click the close button on the msgbox and it flashes and remains open. I then have to open my windows task manager and close a5 down.

    Comment


      #3
      Re: very frequent a5 crashes

      One more discovery. If i comment out the if then statement then it does not lock up.

      Comment


        #4
        Re: very frequent a5 crashes

        Hi Tony,

        Just a thought and unknown if related to your current problem.....I would think that normally child records would be deleted before the parent especially if you are still using data from the parent to find the child(ren).
        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


          #5
          Re: very frequent a5 crashes

          Tony

          I just reveiwed your code again, I think that the problem lies in the fact that you are starting out with tbl.fetch_first(), then going through the iteration ; however your first bit of code if tbl.Picked=.t. then do stuff, there is no way for your code to fetch the next record if tbl.picked=.F. You are getting hung up because if tbl.picked =.f. then you will always look at the first record fetched since there is nothing to fetch the next record.

          Just add tbl.fetch_next() before the end while statement - then if tbl.picked=.f. then the fetch_next() will start the iteration at the next record.

          If tbl.picked=.t. the table fetch would not upset the tbl.delete() and the tbl.delete_range() statements within you code.

          You would still need the tbl.fetch_next() before the end while statement to keep the iteration going since you are going through the whole client file both picked=.t. and picked=.f.

          Comment


            #6
            Re: very frequent a5 crashes

            Tony, I think Tom is on to something, but I'd recommend doing it differently. use an ELSE statement before the "end while" statement and put your tbl.fetch_next() there. You don't need it when tbl.picked = .t. because the delete method will automatically fetch the next record for you.

            Other issues:
            a) you are dimming, opening and closing all the child tables and the related variables each time through the WHILE... END WHILE code block. Don't. Open them before the code block. Dim your variables at the top, before the Code Block. Then close all the tables when the code block finishes. i.e. only dim, open, and close once for each child table.

            b) If it were me, I'd put the child table delete sequences in separate user defined functions to avoid timing issues. Do not assume your script will stop running when a command requires alpha to go over to the server fetch some records and then delete them. the script does not wait unless you do the disk activity work inside a udf.

            Comment


              #7
              Re: very frequent a5 crashes

              dim clid as c
              Change to:
              dim global clid as c

              Comment


                #8
                Re: very frequent a5 crashes

                This all make sense. It does bring up two more questions.
                1) would i be better off removing the if..then and instead use query_create() to filter the table to just include the .t. values. This table could hold up to 600 records with only small numbers of records getting deleted at a time.

                2) Gabriel. Why should I use a global variable here? I am not sure I understand the reason since it is only used within the script.

                Thanks again for all of the help!
                Tony

                Comment


                  #9
                  Re: very frequent a5 crashes

                  Alright,
                  I have tried to implement your suggestions.

                  Here is what I now have:

                  Code:
                  dim global cl_id as c
                  dim tbl as p
                  dim atbl as p
                  dim btbl as p
                  dim ctbl as p
                  dim dtbl as p
                  
                  atbl=table.open("clients",FILE_RW_SHARED)
                  btbl=table.open("cl_exer",FILE_RW_SHARED)
                  ctbl=table.open("cl_wrkout",FILE_RW_SHARED)
                  dtbl=table.open("cl_notes",FILE_RW_SHARED)				
                  
                  tbl = table.open("cl_team",FILE_RW_SHARED)
                  tbl.query_create("","picked=.t.")
                  tbl.fetch_first()
                  tbl.batch_begin()
                  
                  while .not. tbl.fetch_eof()
                  
                  	clid = tbl.cl_id
                  		
                  	'***Clients Table-Remove record and delete the clients image stored in the storage folder
                  	Delete_Athl_Client_Tbl()
                  
                  	'***Delete from cl_exer table
                  	Delete_Athle_Exer()
                  	
                  	'***delete from the cl_workout table
                  	Delete_Athle_Wo()
                  
                  	'***delete from the cl_notes table
                  	Delete_Athl_Notes()
                  	
                  	'***delete the cl_team record
                  	tbl.change_begin(.t.)
                  	tbl.delete()
                  	tbl.change_end(.t.)
                  			
                  end while
                  	
                  tbl.batch_end()
                  
                  tbl.close()
                  atbl.close()
                  btbl.close()
                  ctbl.close()
                  dtbl.close()
                  '************************************************************
                  'refresh the form
                  '************************************************************
                  athlete_Browse.refresh()
                  athlete_Browse.fetch_first()
                  My UDFs just contain the delete code for each table

                  For instance, my Delete_Athle_Wo() udf is:

                  Code:
                  dtbl.delete_range("client_id="+s_quote(clid))
                  Am I more in the ballpark here???
                  Thanks again.
                  Tony

                  Comment


                    #10
                    Re: very frequent a5 crashes

                    yes, almost, but you should pass the filter / search key to each function as a parameter, and your function should open each table. You don't need to open the child tables in your main script if you are using UDF's

                    The function would be something like:

                    Code:
                    FUNCTION Delete_Athle_Wo AS L (srch_key as C)
                          dtbl = table.open("cl_notes")
                          dtbl.delete_range("client_id = " + s_quote(srch_key))
                          dtbl.close()
                    END FUNCTION
                    And then call it in your script like this:

                    Code:
                    Delete_Athle_Wo( clid )
                    What I've described is the simpler approach. Once you get it working you might want to open each child table in the main script and pass a pointer to that table to your function as well as the srch_key. Your functions wouldn't have to open and close the tables each time they're called if you did it that way. However, this is more advanced.

                    Comment


                      #11
                      Re: very frequent a5 crashes

                      Tom,
                      I didnt take long for me to figure out what I had posted would not work.

                      Here is what I had come up with...Here is the udf:

                      Code:
                      FUNCTION Delete_Athlete_Child_Rec AS C (tabl as p )
                      
                      tabl.delete_range("client_id="+s_quote(clid))
                      END FUNCTION
                      Here is how I called the function:
                      Code:
                      	delete_athlete_child_rec(btbl)
                      	
                      	'***delete from the cl_workout table
                      	Delete_athlete_child_rec(ctbl)
                      
                      	'***delete from the cl_notes table
                      	Delete_athlete_child_rec(dtbl)

                      As you had initially suggested, I dimmed the pointer variables and opened/closed the tables outside the loop.

                      I must admit that I was quite suprised that this worked for me as I have not really done much with UDFs yet.

                      Is this acceptable or do I need to change it to you your suggestion?

                      Comment


                        #12
                        Re: very frequent a5 crashes

                        Tony, I think what you have will work fine. In my own work here I try to design my functions so that there are no dependencies. If a value is needed inside the function I pass it to the function explicitly. In the last version your function is dependent on the term "clid" being declared and populated by some other process. If it were me, I'd pass the table pointer AND the search key to the function. This removes the dependency and makes the UDF more versatile. -- tom

                        Comment


                          #13
                          Re: very frequent a5 crashes

                          Makes perfect sense Tom.

                          I will make the change.
                          Thanks
                          Tony

                          Comment

                          Working...
                          X