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

Restrict deleting

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

    Restrict deleting

    If you want to stop a user from using control-D to delete a record but rather would want to force them to use a button for the delete (so you can embed code in the button to record the user, date, time, etc.), it seems the way to do this is begin the button execution by unrestricting the delete and end the button execution by restricting delete.

    I use the object properties of the current form's window and set the property of restrict_delete to False when I want to unrestrict a deletion and True when I want to restrict a deletion.

    The problem is, when you have the restrict delete at the end, after the delete record would have been executed, it does not allow a delete record, as if the restrict delete appeared before the delete record. The unrestrict delete works to unrestrict deletes when I separately make sure the restrict delete is True (using a separate button to test this) if I don't have the restrict delete set to True at the end (commented out), but if I do have it at the end, it appears to overwrite the entire sequence and not allow a deletion of record.

    This would not appear to be the way it should work. Does anyone know why the restrict delete at the end prevents a prior delete command from executing?

    Thank you.

    Jeff

    #2
    Re: Restrict deleting

    Jeff

    I think that I understand your question.

    You have a form, in the form's properties you have restricted delete.

    Now you have a button on the form to delete the current view record.

    The button should have code similar to this

    Code:
    parentform.restrict_delete=.f.
    parentform.delete_record()
    parentform.restrict_delete=.t.
    Now when you push the button, the current record is not deleted.

    Is this correct.

    I have a test app which I did exactly what I think you did - the form had restrict delete box check in the properties.

    Then I created a button with the above code.

    If you tried to delete a record with Ctrl-D, nothing would happen since the forms properties are restricting delete. If you press the button the first line turns off the form's delete restriction, the second line deletes the current record (asking if you want to delete the record) and then the last line would turn on the delete restriction. It works every time.

    Have I missed something (or is there code other that just what I have listed above - which may be causing a timing issue),


    Tom

    Comment


      #3
      Re: Restrict deleting

      Originally posted by Tbaker View Post
      Jeff

      I think that I understand your question.

      You have a form, in the form's properties you have restricted delete.

      Now you have a button on the form to delete the current view record.

      The button should have code similar to this

      Code:
      parentform.restrict_delete=.f.
      parentform.delete_record()
      parentform.restrict_delete=.t.
      Now when you push the button, the current record is not deleted.

      Is this correct.

      I have a test app which I did exactly what I think you did - the form had restrict delete box check in the properties.

      Then I created a button with the above code.

      If you tried to delete a record with Ctrl-D, nothing would happen since the forms properties are restricting delete. If you press the button the first line turns off the form's delete restriction, the second line deletes the current record (asking if you want to delete the record) and then the last line would turn on the delete restriction. It works every time.

      Have I missed something (or is there code other that just what I have listed above - which may be causing a timing issue),


      Tom
      You understand it exactly. You raised two questions that may have a bearing on this, and I will test both. First, you are using Xbasic code while I used Action Scripting. This should not make a difference. Second, the possible timing issue you referred to may be the issue. I do have an external procedure running prior to the delete command, but I'm not sure why it would cause the command after the delete (turn on delete restriction) to stop the delete from working.

      I'll try both of these and report back.

      Thanks.

      Jeff

      Comment


        #4
        Re: Restrict deleting

        Originally posted by Jeff Fried View Post
        You understand it exactly. You raised two questions that may have a bearing on this, and I will test both. First, you are using Xbasic code while I used Action Scripting. This should not make a difference. Second, the possible timing issue you referred to may be the issue. I do have an external procedure running prior to the delete command, but I'm not sure why it would cause the command after the delete (turn on delete restriction) to stop the delete from working.

        I'll try both of these and report back.

        Thanks.

        Jeff
        Tom,

        I stripped all Action Script lines except the equivalent of the Xbasic lines:

        parentform.restrict_delete=.f.
        parentform.delete_record()
        parentform.restrict_delete=.t.

        It is not working with Action Scripting. The object used is the <formname> window. The property set for that window is restrict_delete. And the value specified is "False" for the first line, prior to the delete command, and "True" for the third line, after the delete command.

        If you see something about these Action Scripting lines that you think are wrong, please let me know. Otherwise, I will go the Xbasic route and I'm sure it will work the way it works for you.

        Thank you.

        Jeff

        Comment


          #5
          Re: Restrict deleting

          Jeff

          Could you make a screen shot of your action scripting code. I want to see if I can reproduce what you are seeing.


          Tom

          Comment


            #6
            Re: Restrict deleting

            I very rarely use action scripting but I did put together just as you did the AS code to match the xbasic.

            Set the properties of the form to allow delete
            Record Delete
            Set the properties of the form to restrict delete.

            Looked at the underlying code of those three AS actions and they are identical to the xbasic script.

            Tested it in my little test app and it worked the same as using xbasic.

            Therefore it must be a timing issue with the code after you push the button to delete the record - the next bit of code is firing and the delete does not take place.

            When an issue with timing comes up the solution is to create a UDF with the code to delete the record - this code would work till it completed and delete the record and put the form's restrict_delete back on - and then go to the next step in the code.

            Posting a small sample with sample data would help.

            Tom Baker

            Comment


              #7
              Re: Restrict deleting

              Originally posted by Tbaker View Post
              I very rarely use action scripting but I did put together just as you did the AS code to match the xbasic.

              Set the properties of the form to allow delete
              Record Delete
              Set the properties of the form to restrict delete.

              Looked at the underlying code of those three AS actions and they are identical to the xbasic script.

              Tested it in my little test app and it worked the same as using xbasic.

              Therefore it must be a timing issue with the code after you push the button to delete the record - the next bit of code is firing and the delete does not take place.

              When an issue with timing comes up the solution is to create a UDF with the code to delete the record - this code would work till it completed and delete the record and put the form's restrict_delete back on - and then go to the next step in the code.

              Posting a small sample with sample data would help.

              Tom Baker
              Tom,

              I'm not sure what's going on, but here's what I did. I set up a test button with xbasic code with the three lines. I'm trying to make this work in an A5V7 app (long story) and this test button is not firing the delete record command in it. Same test button set up in A5V10 and it does fire. However, in V10, using the Action Scripting approach, it does not fire. I'm sure you are right that timing has something to do with this, but the plain vanilla situation of just the three lines should not, I would think, have a timing issue. Since it appears it does, I would like to try your UDF approach. Do you think this can work if I remain with the Action Scripting approach but use Inline Xbasic for the UDF?

              If so, what would I add to the code to determine that the delete operation completed? There are two scenarios, one where the user clicks to delete but clicks no instead of yes to delete. The other is to click yes to delete. Can both scenarios be trapped in this Inline Xbasic Action Scripting line sufficient to slow it down prior to executing the next, prevent delete line?

              Thanks.

              Jeff

              Comment


                #8
                Re: Restrict deleting

                Jeff

                I don't think there is a way to create a UDF in action scripting.

                You would have to first create the function in the xbasic code editor and then use inline xbasic to call the function.

                In other create the delete record UDF (function) in Xbasic say with those three lines of code.

                In the xbasic code editor click on the white space. A genie will come up click on new, then function.

                The function genie will come up asking for a name of the function. Then it will ask you for the return type - select logical. then push the okay button.

                The xbasic code editor will come up with the beginning of the function with the function name and its return value then end function. Place the xbasic code between the function - end function. Save the code, and now you will have a function to call from inline xbasic

                Code:
                result=yourfunctionname()
                The result will be the way to find out if the delete worked. You would test result for true or false.

                then continue the rest of the script with AS.

                That is the basic way. If this sounds confusing, it is because as I said I very rarely use Action Scripting - got away from it years ago. I prefer to roll my own code so I control it now Alpha.

                I will put something together tonight after I come back from babysitting my grandkids.

                I will be in touch.

                Tom Baker

                Comment


                  #9
                  Re: Restrict deleting

                  Originally posted by Jeff Fried View Post
                  Tom,

                  I'm not sure what's going on, but here's what I did. I set up a test button with xbasic code with the three lines. I'm trying to make this work in an A5V7 app (long story) and this test button is not firing the delete record command in it. Same test button set up in A5V10 and it does fire. However, in V10, using the Action Scripting approach, it does not fire. I'm sure you are right that timing has something to do with this, but the plain vanilla situation of just the three lines should not, I would think, have a timing issue. Since it appears it does, I would like to try your UDF approach. Do you think this can work if I remain with the Action Scripting approach but use Inline Xbasic for the UDF?

                  If so, what would I add to the code to determine that the delete operation completed? There are two scenarios, one where the user clicks to delete but clicks no instead of yes to delete. The other is to click yes to delete. Can both scenarios be trapped in this Inline Xbasic Action Scripting line sufficient to slow it down prior to executing the next, prevent delete line?

                  Thanks.

                  Jeff
                  Finally a solution to this timing problem (and thank you for providing the insight that it is a timing issue).

                  Using Action Scripting (the same idea would work in Xbasic using "xbasic_wait_for_idle()"), just insert the "Wait for Idle" command after the Delete Record command and it won't continue with the restrict delete true until after processing the Delete Record, whether the user answers yes or no.

                  Thanks.

                  Jeff

                  Comment


                    #10
                    Re: Restrict deleting

                    Jeff

                    I am glad you got it worked out - I had forgotten about the xbasic_wait_for_idle() function. I am not used to using action scripting.

                    That is a basic way of halting a script till the job is complete. For much larger scripts a UDF could be the only way to halt the execution of the next code section until the code is finished.

                    Again glad it is working.

                    Tom Baker

                    Comment


                      #11
                      Re: Restrict deleting

                      Originally posted by Tbaker View Post
                      Jeff

                      I don't think there is a way to create a UDF in action scripting.

                      You would have to first create the function in the xbasic code editor and then use inline xbasic to call the function.

                      In other create the delete record UDF (function) in Xbasic say with those three lines of code.

                      In the xbasic code editor click on the white space. A genie will come up click on new, then function.

                      The function genie will come up asking for a name of the function. Then it will ask you for the return type - select logical. then push the okay button.

                      The xbasic code editor will come up with the beginning of the function with the function name and its return value then end function. Place the xbasic code between the function - end function. Save the code, and now you will have a function to call from inline xbasic

                      Code:
                      result=yourfunctionname()
                      The result will be the way to find out if the delete worked. You would test result for true or false.

                      then continue the rest of the script with AS.

                      That is the basic way. If this sounds confusing, it is because as I said I very rarely use Action Scripting - got away from it years ago. I prefer to roll my own code so I control it now Alpha.

                      I will put something together tonight after I come back from babysitting my grandkids.

                      I will be in touch.

                      Tom Baker
                      Tom,

                      I had sent my "wait for idle" solution just before I received your reply. I understand what you're saying, and because of the "wait for idle" simplicity, I won't need to go into creating a UDF that would then need to be tested.

                      I find myself using Action Scripting more than I probably should, but it works until I run into a situation where I need to get under the hood. I also work a lot with creating and running compiled Foxpro routines as an Action Scripting "run another program" command and it works well. I'm usually using these compiled Foxpro routines for rapid data manipulation and other complex processes. If not for this, I probably would have embraced more direct coding with Xbasic. I enjoy the more efficient language of Foxpro (it's actually Visual Foxpro) and it has the additional virtue of being compiled into EXE routines for speed. Unfortunately Alpha Software never got to the point of allowing us to compile the Xbasic, though they spoke about the possibility of doing it at one of the meetings I attended but thought it would be too massive an undertaking. I think their focus shifted so much to the web that it wasn't worth putting that much additional resource into desktop. I don't blame them.

                      Hope the grandkids were cooperative tonight.

                      Thanks again.

                      Jeff

                      Comment


                        #12
                        Re: Restrict deleting

                        xbasic_wait_for_idle() is a function that can work for some "minor" timing issues MOST of the time (it can be inconsistent especially between Alpha versions)....whereas a UDF, so far for me, has worked ALL of the time for every timing issue I have run across.

                        Just so that you are aware of this aspect as if/when you see some failures in the future, you know where to look first. :)
                        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


                          #13
                          Re: Restrict deleting

                          Originally posted by MikeC View Post
                          xbasic_wait_for_idle() is a function that can work for some "minor" timing issues MOST of the time (it can be inconsistent especially between Alpha versions)....whereas a UDF, so far for me, has worked ALL of the time for every timing issue I have run across.

                          Just so that you are aware of this aspect as if/when you see some failures in the future, you know where to look first. :)
                          Mike,

                          Thanks for the tip. So far the wait_for_idle appears to have resolved it, but if setting up a UDF would be more insurance for this, why not? I assume the UDF would contain both the delete function as well as the turning back on of the prevent delete.

                          Thanks.

                          Jeff

                          Comment


                            #14
                            Re: Restrict deleting

                            Place in the UDF whatever has to finish prior to something else starting is a general rule I use.....place anything else in the UDF that also relates so long as if when the UDF is used in more than one place, that all the included code will work as wanted.

                            To bulletproof some code that had/possibly would have timing issues I many times have several UDFs used in sequence....an example are operations that tend to open and close tables or iterate through all the records during their processing....and I will place each operation into a UDF and have sometimes 10 or more in succession.
                            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


                              #15
                              Re: Restrict deleting

                              to disable the Ctrl-D on a layout, in the form's onkey event put this code:

                              Code:
                              if a_user.key.value="{^d}"
                                     a_user.key.handled=.t.
                                     end
                              end if
                              Cole Custom Programming - Terrell, Texas
                              972 524 8714
                              [email protected]

                              ____________________
                              "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                              Comment

                              Working...
                              X