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

Hot Key for changing the value of a variable

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

  • Hot Key for changing the value of a variable

    I'm a new user to alpha 5. I've set up a form that has a field in which the end users needs to enter a number between 0 and 9. To make it easy for the user I've been able successfully and easily to set up a lookup with the field rules so that the user can pick the number without having to enter it manually.

    I also have a button on the form that has the label "F1= Change #". If the user clicks on the button the field with the number between 1 and 9 changes one by one. Once the number reaches 9 it goes back to 0 after the next click on the button. For this I used the event on push route, I was able to use the Script Genie: Set Field Values. I set up an expressions If(field name<10,field name +1,0).

    What I also want to do but can't figure out is that I would like the field to change by one if the user just hits the F1 key. Every time the user hits the F1 key it would add 1 to the number that appears in the field. In essence I need the hot key F1 to change the value of a variable. I have tried to use the SYS_KEY_DOWN() function without any luck. First I'm not exactly sure what event I would need to access and second what function to use.

    Because I am in the learning process I would appreciate learning how to do this in more than one way although I would be happy with the easiest way. Any help is appreciated.

  • #2
    Re: Hot Key for changing the value of a variable

    Check the documentation for onkey().
    There can be only one.

    Comment


    • #3
      Re: Hot Key for changing the value of a variable

      I've found what I probably need the "OnKey Events on Forms". I'm not exactly sure how to use it. I noticed that the events change when you right click on the buttons as opposed to right clicking on the form. The Onkey event only appears when you right click on the form and not on the button.

      I also read the help file associated with the onkey event and examed the macro sample application but I still can't figure out how to do it.

      Comment


      • #4
        Re: Hot Key for changing the value of a variable

        Okay the onkey event. I'm trying to use the F1 key to make the field =3. The name of the field is exemptions. When I use the example in the help field and put the following in the expression builder I get "invalid or incomplete expression"

        if a_user.key.value = "{F1}" then
        a_user.key.handled = .T.
        if a_user.key.event = "down" then

        exemptions=3

        END IF

        END IF

        This is exactly the way the help files indicates.

        Comment


        • #5
          Re: Hot Key for changing the value of a variable

          Onkey event for your form.....

          Code:
          IF a_user.key.value = "{F1}" THEN
              a_user.key.handled = .T.
              IF a_user.key.event = "down" THEN
                   If([COLOR="Red"]field name[/COLOR]<10,[COLOR="red"]field name[/COLOR] +1,0)
              END IF
          END IF
          Did you try this? Has nothing to do with your button.
          There can be only one.

          Comment


          • #6
            Re: Hot Key for changing the value of a variable

            When I use the example in the help field and put the following in the expression builder I get "invalid or incomplete expression"
            What expression builder?

            You right click on the form background, choose Events, choose Onkey, enter the code there.

            Since your expression was entered in the action scripting genie you will probably have to use

            If(expressions.value<10,expressions.value +1,0)

            as the line in the event code.
            There can be only one.

            Comment


            • #7
              Re: Hot Key for changing the value of a variable

              Yes I tried your suggestion. I had actually tried it before you suggested it with the same results. The results are "invalid or incomplete expression" "Expression does not evaluate to a numeric value"

              Comment


              • #8
                Re: Hot Key for changing the value of a variable

                After I right click on the form background, choose Events, choose Onkey I am presented with "create action scripting" or "create using "xbasic". I choose "create action scripting". I am then shown the code editor. I click on add new action. I am shown two columns. On the left is the category column and on the right is the action column. I choose set value property of field from the right column. I click on the green plus sign it opens a select control window. I select the field that I want to change (exemption) I asked how will you specify the value property? I choose select an expression that evaluates the value. I click on expression and I am presented the expression builder. This is where I enter the information and get an error.

                Comment


                • #9
                  Re: Hot Key for changing the value of a variable

                  Originally posted by taxschool View Post
                  After I right click on the form background, choose Events, choose Onkey I am presented with "create action scripting" or "create using "xbasic". I choose "create action scripting". I am then shown the code editor. I click on add new action. I am shown two columns. On the left is the category column and on the right is the action column. I choose set value property of field from the right column.
                  No.

                  At this point choose Xbasic, then inline xbasic, then put the code there.
                  There can be only one.

                  Comment


                  • #10
                    Re: Hot Key for changing the value of a variable

                    I tried it and it still doesn't work. I think the problem has to do with the code. I know that it is the same code that appears in the help file for the onkey event but still nothing. When I hit the F4 key in the inline xbasic it tells me that it compiled it succesfully but when I try to run the database and use the hotkey nothing. Of course I make sure that it saves this code and after failing to run it I check to see if the code is still there.

                    I have gone as far as to create a new database with only one table and only one field. I've tried to use the onkey event several ways with this new database and nothing. I've changed the hot key to different keys other than F1 just in case this key is reserved and nothing. I've changed the code several ways and even changed the name of the field and types of field and nothing. Each time I've been careful to make sure that the code agrees exactly with the name of the fields, type of fields, etc.

                    On a previous reply the onkey event code is given with only the field name needed and I put in my field name (exemptions) and nothing.

                    Comment


                    • #11
                      Re: Hot Key for changing the value of a variable

                      My bad and sloppy.

                      The event code should be something like.

                      Code:
                      IF exemptions.value > 99 'handles uninitialized numeric field
                      	exemptions.value = 0
                      END IF
                      IF a_user.key.value = "{F1}" THEN
                      	a_user.key.handled = .T.
                      	IF a_user.key.event = "down" THEN
                      		IF exemptions.value < 10
                      			exemptions.value = exemptions.value +1
                      		ELSE
                      			exemptions.value = 0
                      		END IF
                      	END IF
                      END IF
                      I say something like because in my testing this is firing twice per press of the F1 key.
                      There can be only one.

                      Comment


                      • #12
                        Re: Hot Key for changing the value of a variable

                        I can't figure out why the following code always adds 2 instead of 1 to exemptions.value after pressing the F1 key. I tried to do it a different way by using the SELECT ... CASE but in this case it also added 2 to the exemptions.value. Any suggestions?

                        Code:
                        IF exemptions.value > 99 'handles uninitialized numeric field
                        exemptions.value = 0
                        END IF
                        IF a_user.key.value = "{F1}" THEN
                        a_user.key.handled = .T.
                        IF a_user.key.event = "down" THEN
                        IF exemptions.value < 10
                        exemptions.value = exemptions.value +1
                        ELSE
                        exemptions.value = 0
                        END IF
                        END IF
                        END IF

                        Comment


                        • #13
                          Re: Hot Key for changing the value of a variable

                          Originally posted by taxschool View Post
                          I can't figure out why the following code always adds 2 instead of 1 to exemptions.value after pressing the F1 key.
                          In my testing this is firing twice per press of the F1 key. Hope someone can tell us why.

                          Stick a debug(1) as the first line of the code and walk through the multiple iterations.
                          There can be only one.

                          Comment


                          • #14
                            Re: Hot Key for changing the value of a variable

                            Stan

                            I found the same thing that the F1 key is firing twice - if you use any of the other "F" keys there is no problem.

                            Couldn't find anything in the help that F1 is reserved.

                            Tom Baker

                            Comment


                            • #15
                              Re: Hot Key for changing the value of a variable

                              Confirmed here. Thanks for the insight.
                              There can be only one.

                              Comment

                              Working...
                              X