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 help

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

    Script help

    I am having illegal operations with the following script - I believe it occurs if the "Postcode" index is corrupt can a trp be put in to warn the index needs fixing to avoid the illegal ops. If so what are the script lines?

    dim flag as l
    flag = key_exist("Postcode",var->pcde)
    IF flag = .t. THEN
    PARENTFORM.close()
    :Form.view("SQPOSTCODE")
    ELSE
    flag = exist(var->pcde,"Shopas","Postcode")
    IF flag = .t. THEN
    PARENTFORM.close()
    :Form.view("SHOPASPOSTCODE")
    ELSE
    PARENTFORM.new_record()
    END IF
    END IF
    end

    Thanks
    Terry

    #2
    RE: Script help

    Terry:

    Flag is a logical field. Is var->pcde logical?
    then you are trying to put text into the flag field. this is probably where the error is.

    run with debug and test.

    I hope this helps.

    bob adler

    Comment


      #3
      RE: Script help

      key_exist returns a logical result so i do not think this is the problem. The script will work for hours and then suddenly give the ilegal ops. If the indexs are rebuilt the illegal ops cease.

      Terry

      Comment


        #4
        RE: Script help

        What's the context in which you have put this script? Usually key_exist() would be put in a field rule for a table, but I doubt that is the context in which you have the script. Is this a button script, a form-level event, a table-level event, a field rule? What is the current table? Is var->pcde guaranteed to be defined and non-null in all cases?

        Comment


          #5
          RE: Script help

          Peter
          Nice to have your help
          this is a button script working on the current table.
          I have 14 identical buttons which work fine on the smaller tables but on the larger tables where indexes are inevitably less stable it gives the illegal ops.
          Thanks
          Terry

          Comment


            #6
            RE: Script help

            Terry,

            I notice that in your script the parentform is closed before another form is opened. In my own work I steer clear of such constructs. I don't want the current form to ever close if other commands remain to be executed in the script being run from that form, or an object on that form. So, what I do is to reverse the sequence. Open the new form, then close the current one.

            I have no clue whether this is or may be related to the issue you're addressing, but thought I'd mention it since it's the only thing I see that struck me as a bit odd.

            -- tom

            Comment


              #7
              RE: Script help

              Terry,

              Now, on to your question.

              Have you tried putting an error trap on either side of the key_exist() line? If the error is trapped you could branch to a subroutine that rebuilds the index and invites the user to try again.

              A larger question to me is why are your indexes getting corrupted? In normal usage this should not be happening unless you're experiencing power outages or network hardware glitches.

              What version of Alpha Five are you running?

              Are you using filtered indexes? Do the filter expressions rely on values that are not found in the current table? i.e. on global variables, or values in other tables...

              -- tom

              Comment


                #8
                RE: Script help

                Tom
                Will an error trap fire to stop an illegal operation - if so what lines of script are required?
                Indexes have always been a problem, so much so that I have structured things so there are now only two indexes required, each of which is based on a field value with no filters.
                I am running v4.50
                can you help me further?
                Terry

                Comment


                  #9
                  RE: Script help

                  Peter
                  Is it safer to use exist with a pointer to the current table rather than key_exist.
                  Terry

                  Comment


                    #10
                    RE: Script help

                    Terry,

                    The discussion of 'On Error GoTo' in Chapter 9 of the Xbasic Reference Manual is pretty straightforward, and includes examples. My thought is that you'd put an 'On Error Goto' command statement at the top of your script, and then add some errorhandler commands at the end. The errorhandler would simply popup a message box telling the user to reindex the files and try again.

                    I can't test your script without corrupted indexes to trigger the error.

                    -- tom

                    Comment


                      #11
                      RE: Script help

                      Having put the error traps in I have now established that illegal operations have and are still occuring as soon as the button is pressed.
                      The action script attached to the button first runs a global script the code for which is as follows:-

                      ON ERROR GOTO error_handler
                      goto selection
                      selection:
                      tmppcde = ui_get_text("POSTCODE SEARCH","Enter the FULL POSTCODE for the PREMISES","","l&&&&&&&")
                      var->pcde = upper(remspecial(tmppcde))
                      IF var->pcde = ""
                      end
                      ELSEIF LEN(var->pcde)pcde)>8
                      ui_msg_box("INVALID POSTCODE","The Postcode you have entered is too long !", 48)
                      goto selection
                      end
                      ELSE
                      var->pcde1 = if(len(var->pcde)>=7,left(var->pcde,4),if(len(var->pcde)=5,left(var->pcde,2),left(var->pcde,3)))
                      var->pcde2 = right(var->pcde,3)
                      END IF
                      end
                      error_handler:
                      err = error_code_get()
                      msg = error_text_get(err)
                      ui_msg_box("Error report to TRM & run a FIX IT", msg)
                      END

                      Is there an obvious problem with this script or does anyone have any refinement suggestions.

                      Thanks
                      Terry

                      Comment


                        #12
                        RE: Script help

                        it sounds as though the problem occurs with key_exist() or exist() when your index gets corrupted. although there is no way i know of for alpha to report a corrupted index, you can prevent the crash by avoiding key_exist() as follows:

                        t=table.current()
                        t.index_primary_put("postcode")
                        rec=t.fetch_find(pcde)
                        if rec

                        Comment


                          #13
                          RE: Script help

                          Terry, I don't see anything at first glance. If your script uses the variable you get from the user to do a find by key against your table, the index key you use must match the type of variable you are using. So, for example, if your index key is numeric, and you use your var (which is character) each attempt to do a find by key will fail.

                          If that's not the issue, how about posting a working model ofyour database here, so we can see the complete picture? (include a text file of instructions describing which form, and which button, you're working on, and what it is that you're trying to accomplish with the button push)

                          -- tom

                          Comment


                            #14
                            RE: Script help



                            Terry:
                            I don't see anything that would trigger an error here. The script you
                            posted can be thinned out a bit, though. Below is the same script without
                            the goto selection (not needed) and the templete on the ui_get_text obliterates
                            the need for the other elseif. I'll try to format this... Craig
                            ON ERROR GOTO error_handler

                            selection:
                            tmppcde = ui_get_text("POSTCODE SEARCH","Enter the FULL POSTCODE for the PREMISES","","l&&&&&&&")
                            var->pcde = upper(remspecial(tmppcde))

                            if var->pcde = ""
                            end

                            else if len(var->pcde)"5
                            ui_msg_box("INVALID POSTCODE","The Postcode you have entered is too short !", 48)
                            goto selection

                            else
                            var->pcde1 = if(len(var->pcde)>=7,left(var->pcde,4),

                            if(len(var->pcde)=5,left(var->pcde,2),

                            left(var->pcde,3)))

                            var->pcde2 = right(var->pcde,3)

                            end if

                            end

                            error_handler:
                            err = error_code_get()
                            msg = error_text_get(err)
                            ui_msg_box("Error report to TRM & run a FIX IT", msg)
                            END



                            Comment


                              #15
                              RE: Script help

                              Terry:

                              Well, as usual, I forgot to do something and this board swallowed some characters!

                              There needs to be a forward slash at the end of every line in the else statement to continue the line in XBasic (If you choose to format it as shown...).

                              Craig

                              Comment

                              Working...
                              X