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

Script to fire depending on value in a field

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

    Script to fire depending on value in a field

    I need a script to monitor the value in a calc field as follows:
    I have 5 numeric fields on a form and a calc field (layout level) that sums the 5 fields. I want a script to fire when the amount in the calc field exceeds a certain limit. The only approach I can think of is to place the script in the OnDepart in each field. I am wondering if there is a simpler approach.

    #2
    Re: Script to fire depending on value in a field

    Would the CanSave event in the form layout be helpful iin your app? You could pop up a message box, and cancel the save if the value is exceeded for example.

    Actually, since I'm guessing at what your script will do, maybe better suggestions will be forthcoming if you tell us what is going to happen if the threshold value is exceeded.

    Comment


      #3
      Re: Script to fire depending on value in a field

      Gaby,

      Can you use the onchange event of the calculated field?

      Geoff

      edit:

      Interesting - the onchange event of calc field doesn't fire when its value changes due to another field being changed (tested in V8). I would think this is a bug as I can't imagine you would design it to work this way but needs to be checked in V9.
      Last edited by gmeredith17; 12-09-2008, 08:49 AM.

      Comment


        #4
        Re: Script to fire depending on value in a field

        Gaby, Geoff,
        What would be so hard in placing your script (or UDF) on the OnDepart event of just the fields that will change the calculated field you are referring to? If there are so many fields involved then use Tom's suggestion.

        Geoff, as far as I have seen events fire when physically changed or created....any time xbasic is used they inconsistently or never fire. This has been the way since I started at least. It may have been nice to have it the way you want (but then I bet other issues would pop up as a result too!), but at this time a change like that would break most apps.
        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: Script to fire depending on value in a field

          Hi guys:
          It is true that the OnChange event does not fire when the value is modified due to a calc. The help file seems to say that the Onchange fires when the user changes the value.
          It is not so hard to put the same script in each of the 5 data entry fields and in fact it works, I was just wondering if there was a more elegant way of doing this.
          The purpose is to warn the user that the total amount has been exceeded; in some specific cases a total amount that exceeds the limit is justified, in the majority of the cases it is not and just wanted to warn the user.

          Comment


            #6
            Re: Script to fire depending on value in a field

            Hi Mike,

            Nothing wrong with the ondepart method other than having to do it for each field.

            I can understand difficulties in ordinary fields being manipulated by xbasic and events not firing. However, a calculated field is being manipulated by the main alpha program and there really isn't any reason why the event shouldn't fire. I appreciate the fact that introducing it now or in future releases may cause a problem with existing applications and as such they would need to have a toggle option giving the developer the choice. Its not a major issue and there are definitely more pressing issues that need resolving but it seems to add to the current perception of needing to many work arounds.

            Comment


              #7
              Re: Script to fire depending on value in a field

              Originally posted by gmeredith17 View Post
              there really isn't any reason why the event shouldn't fire.
              Since it is defined as a user entry event it would be against it's own definition to fire when the system changes the value......

              One can argue that another event could be available to handle the system changing a value....
              Al Buchholz
              Bookwood Systems, LTD
              Weekly QReportBuilder Webinars Thursday 1 pm CST

              Occam's Razor - KISS
              Normalize till it hurts - De-normalize till it works.
              Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
              When we triage a problem it is much easier to read sample systems than to read a mind.
              "Make it as simple as possible, but not simpler."
              Albert Einstein

              http://www.iadn.com/images/media/iadn_member.png

              Comment


                #8
                Re: Script to fire depending on value in a field

                What about {WATCH}? The helps file says:

                The {WATCH} command monitors the value of a variable or expression and fires an event when that expression changes.

                sounds like what I need

                But since I am not an xbasic guy, the explanation given is way above my head.

                Comment


                  #9
                  Re: Script to fire depending on value in a field

                  Gaby,

                  There's another whole approach which I usually take in such scenarios. Namely, I (1) use layout variables rather than calculated fields and (2) use the OnTimer event.

                  If your form were set up with a timer interval of about 1 second, you could put the following into your OnTimer event:
                  Code:
                  tbl = table.current()
                  var->field_tot = tbl.Field1 + tbl.Field2 + tbl.Field3 + tbl.Field4 + tbl.Field5
                  if var->field_tot > some_constant
                       '<your code here>
                  
                       '(refresh screen here if necessary)
                  end if
                  By using a conditional if statement, you can avoid having much code executed every second. It will only execute when warranted. This is just one of many approaches to get what you need.

                  Steve

                  Comment


                    #10
                    Re: Script to fire depending on value in a field

                    Hi Steve: clever approach; I wondered what the OnTimer event was for and how to use it. Thanks for sharing.

                    Comment


                      #11
                      Re: Script to fire depending on value in a field

                      Since it is defined as a user entry event it would be against it's own definition to fire when the system changes the value......
                      Al - IMO it should not be classed as a user entry event. When exactly does the user enter data into it? It is calculated using an expression. The user doesen't enter the data directly into the calculated field. This means it is unlikely to ever get focus for the onchange event to fire when it loses focus. The logical time for a calculated field to fire an onchange event is after a calculation has been made that causes the value to change.

                      Comment


                        #12
                        Re: Script to fire depending on value in a field

                        Originally posted by gmeredith17 View Post
                        Al - IMO it should not be classed as a user entry event. When exactly does the user enter data into it? It is calculated using an expression. The user doesen't enter the data directly into the calculated field. This means it is unlikely to ever get focus for the onchange event to fire when it loses focus. The logical time for a calculated field to fire an onchange event is after a calculation has been made that causes the value to change.
                        I understand what you are saying, but you're missing the point. The onchange event wasn't meant to fire on a calculated field. If anything is wrong, the event shouldn't show for a calculated field...... or should be greyed out...
                        Al Buchholz
                        Bookwood Systems, LTD
                        Weekly QReportBuilder Webinars Thursday 1 pm CST

                        Occam's Razor - KISS
                        Normalize till it hurts - De-normalize till it works.
                        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                        When we triage a problem it is much easier to read sample systems than to read a mind.
                        "Make it as simple as possible, but not simpler."
                        Albert Einstein

                        http://www.iadn.com/images/media/iadn_member.png

                        Comment


                          #13
                          Re: Script to fire depending on value in a field

                          The onchange event wasn't meant to fire on a calculated field
                          hmm maybe. Now its there though lets get it working in a useful way as I described. Not pushing it for V9 as there are enough problems to deal with at the moment but maybe a later version.

                          Comment

                          Working...
                          X