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

problem with A_FIELD_VALUE

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

    problem with A_FIELD_VALUE

    Things are almost working, but for one problem. I have a test table called "Junk" with a character field "Anothername." I am looking up names in another table ("names") using a field "Reversenam." This script is attached to the CanWriteField field-rule event for "Anothername."

    The idea here is to type in a few letters and look up in "names" for any items that match. If there are none, the write is cancelled. If there is only one match, that name is simply assigned to FoundItem. If there is more than one match, the form "NameLook" is called as a dialog, which displays the query selected records in a browse item and sets the global variable "FoundItem" on exit according to the selected record.

    So far so good. Now I want to assign FoundItem to A_FIELD_VALUE. Notice that this is possible before calling the dialog, but after the dialog is closed, setting A_FIELD_VALUE causes the program to crash (i.e. stop responding).

    Why? Is there a workaround?

    --------------

    'Set two global variables
    '
    SearchText = A_FIELD_VALUE
    FoundItem = Junk->Anothername

    'Run rest of script only if user has changed the value in Anothername
    '
    IF SearchText FoundItem THEN

    'Select records which begin with SearchText
    '
    filter = "LEFT(Reversenam," + LTRIM(STR(LEN(SearchText))) + ") = " + chr(34) + SearchText + chr(34)
    trace.writeln(filter)

    tbl = table.open("names")
    query.filter = filter
    query.order = "Reversenam"
    indx = tbl.query_create()

    'Find how many records satisfy the query
    '
    count = indx.records_get()
    FoundItem = tbl.Reversenam
    tbl.close()

    trace.writeln("Count: " + str(count))

    ****This instance of setting A_FIELD_VALUE works; however FoundItem contains only the first matching record

    A_FIELD_VALUE = FoundItem

    'Depending on how many records found
    IF count = 0 THEN
    FoundItem = ""
    cancel()
    ELSEIF count > 1 THEN
    :form.dialog("NameLook")
    END IF

    trace.writeln("F: " + FoundItem)

    ****This instance of setting A_FIELD_VALUE causes a crash if count is > 1 (that is, the dialog has been invoked)

    A_FIELD_VALUE = FoundItem

    END IF

    #2
    RE: problem with A_FIELD_VALUE

    A_Field_value is defines in the xbasic manual as

    "Assigned while in Enter or Change mode, this variable is the value entered into a field before either the cursor leaves the field or the record is saved. Use this variable in a script attached to a field rule event."

    The problem occurs as soon as the field loses focus (the cursor leaves the field), which is what happens when you open a lookup or other form. Then the variable has no context. Since you seem to want to put a returned value back into a field, there is a much better method. If the field object name is "anothername", this will put the returned value into the field on the form

    parentform:anothername.value = founditem
    parentform:anothername.refresh()

    Incidentally, I would suggest using field names with 10 characters or less. Longer names are saved in the data dictionaries which can be corrupted during a crash and the long name could be lost. This will create many problems.

    Jerry

    Comment


      #3
      RE: problem with A_FIELD_VALUE

      Jerry -

      Thanks for the suggestion. I tried it, but got an error message "can't find parentform." I suspect that is because the dialog is called from a Field-Rule event, not directly from another form.

      I have solved the problem, though the solution is a bit clunky. By invoking cancel() before calling the dialog, you prevent the focus from leaving the field (at least, the OnWrote event doesn't fire). Setting A_FIELD_VALUE after the dialog then works, but you don't see this until you exit the field, so I used sys_send_keys() to dump the value of FoundItem into the active control, which after closing the dialog is, in fact, Anothername. Pressing ENTER now causes the CanWrite event to fire again, so I use a flag to allow the second pass to pass the found value through.

      After all this struggle, I discovered that you can do essentially the same thing without any Xbasic at all, by defining a lookup to the names table, and setting the following filter expression:

      LEFT(Reversenam, LEN(A_FIELD_VALUE)) = A_FIELD_VALUE

      Now, Is there a way to make the combo box pop up without reaching for the mouse? Is there a keyboard shortcut for this?

      Thanks for your help.

      Henry

      Comment


        #4
        RE: problem with A_FIELD_VALUE

        Parentform is a relative reference, which doesn't always work with a dialog. Normally with a dialog, I use the actual form name.

        If you have a lookup expression defined, the lookup will pop up only in enter mode. If the form is in change mode, you will need the mouse to get to the lookup.

        Jerry

        Comment


          #5
          RE: problem with A_FIELD_VALUE


          Henry, I believe the keyboard shortcut for the table lookup will be Alt-Dn, once the field has focus of course. Check the user's guide at about pg 25 for the section called 'Navigating Within a Form'.

          -- tom

          Comment


            #6
            RE: problem with A_FIELD_VALUE

            Tom,

            Good catch. That is one shortcut I never found.

            Jerry

            Comment


              #7
              RE: problem with A_FIELD_VALUE

              Henry,

              I hate the Alt-Down_arrow method so I use an OnKey event to have the F8 key do a Sys_send_key("{alt-DOWN}").

              This disables the default use of F8 (I think it is the switch to browse) but I prefer that my users not have that ability by default. If they need that 'default' ability I will give them a button on the form or toolbar.

              Comment


                #8
                RE: problem with A_FIELD_VALUE

                Cal, Jerrry, Tom -

                Lots of good suggestions. I found ALT{DN} by trying everything on the keyboard! Not the best documentation, I would say.

                Thanks.

                Henry

                Comment


                  #9
                  RE: problem with A_FIELD_VALUE


                  Henry, there's much that could be improved in the docs, but this is NOT one of them. The index to the User's guide contains a specific entry for 'Keyboard Equivalents' that leads right to the solution.

                  -- tom

                  Comment


                    #10
                    RE: problem with A_FIELD_VALUE

                    I apologize. I'm an old fashioned guy who likes books, and am still getting used to trying to read and digest manuals in .pdf format onscreen. I missed the whole topic.

                    One suggestion for the Alpha team - it sure would be nice if you could click on the page numbers in the Index and go right to the page in question, rather than having to type it in. The .pdf manual for the Finale music writing program does this, and it's really handy.

                    Henry Gibbons

                    Comment


                      #11
                      RE: problem with A_FIELD_VALUE


                      Henry, we share the same trait. I've printed out my PDF files and have them in large notebooks. Acrobat will let you print the front sides, and then the back sides, so two sided sheets are easily possible. -- tom

                      Comment

                      Working...
                      X