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 Corrupts Product Table

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

    Script Corrupts Product Table

    Not sure why, but when I run this script, it totally corrupts my product file. It is identical to another script I run and yet, it does not corrupt. I know that the table is closed from a previous script, but jus do not see why this one keeps corrupting this file.....

    Here's the script:

    'Date Created: 13-Mar-2009 02:26:53 AM
    'Last Updated: 26-Jun-2009 08:35:25 PM
    'Created By : Ryland
    'Updated By : Ryland

    DIM global_var_A as c
    DIM GLOBAL user as C
    DIM GLOBAL pword as C
    DIM GLOBAL level as C
    DIM GLOBAL varC_result as C
    dim global try as n
    dim global way as c
    dim ans as n
    dim time_in as c
    dim tbl as p
    dim tbl_1 as p
    dim qry as p
    dim qry_1 as p
    dim recs as n
    dim recs_1 as n
    dim global user_level as c
    DIM global v_personnel as c
    dim XDialogStyle as p


    tbl_1=table.open("Product")
    query.filter="Next_calibration_date <= date() + 15"
    query.order=""
    query.options="T"
    qry_1=tbl_1.query_create()
    recs_1=qry_1.records_get()


    if recs_1 > 0 then
    'msgbox(tbl_1.product_id)
    BUTTON18.fill.style = "solid"
    BUTTON18.fill.color = "Red"
    end if


    if recs_1 = 0 then

    BUTTON18.fill.style = "solid"
    BUTTON18.fill.color = "Green"
    end if

    tbl_1.close()
    end

    Thanks for the eyes, Ryland

    #2
    Re: Script Corrupts Product Table

    You don't have

    tbl_1.close()

    within

    Code:
    if recs_1 > 0 then 
    'msgbox(tbl_1.product_id)
    BUTTON18.fill.style = "solid"
    BUTTON18.fill.color = "Red" 
    end if
    but that probably isn't the issue.
    There can be only one.

    Comment


      #3
      Re: Script Corrupts Product Table

      Let me try that. I was hoping my end script at the bottom would take care of it, but maybe it's leaving the table open.

      Will try now.

      Thanks Stan,

      Ryland

      Comment


        #4
        Re: Script Corrupts Product Table

        Stan,

        As usual you are correct. I placed the close tables above, but I soon as I touch that button (with the tbl.close moved into each conditional). it corrupts the product table immediately.....really werid.

        I'll keep digging, but it does not appear to be in script....

        Ryland

        Comment


          #5
          Re: Script Corrupts Product Table

          Yeah, the product file is toast. Packing and rebuliding the indexes, even though appeared to fix it would not export, since it stops on record 100 ot so.

          I'm going to purge the file and rebuild... Ryland

          Comment


            #6
            Re: Script Corrupts Product Table

            Nah, no luck.Thought the table was corrupt, but for some reason when I run the above routine, it just kills that table. Does not make sense unless I have a bad key structure...Going to completely delete the table and redefine the 100 fields, and try again.......

            Nope, table is correct. It is almost like the file pointer is getting lost. If I exit out of Alpha and come back in then all of the Product records appear fine. So it must have something with a "Pointer" getting lost. I've repeated this several times, so definitely there's something flaky going on.

            Ryland
            Last edited by [email protected]; 06-27-2009, 12:58 AM.

            Comment


              #7
              Re: Script Corrupts Product Table

              Ryland,

              I have several ideas for you.

              1. The most important is that you don't have to run a query to determine if a single record exists in your table with a "next_calibration_date" field value meeting your criteria. The approach you are taking will result in a count of all matching records. You don't need to know the count, you just need to know if there's one, right? Define an ascending index on the "next_calibration_date" field. Then in your script open an instance of the table, set the index primary, fetch the first record and check the field value. Make sense?

              2. If you want to run a query against a date field your query filter syntax needs to be tested and corrected. Here are some examples I've prepared for you using the Invoice_header table from AlphaSports. Notice how the syntax changes as you move from a literal date, to a variable containing a date.

              Code:
              t = table.open("invoice_header")
              query.filter = "date < ( [COLOR="Red"]{[/COLOR]01/11/2007[COLOR="red"]}[/COLOR] + 5 )"  [COLOR="darkorange"]'literal date value. Do you see the braces?[/COLOR]
              qry = t.query_create()
              ?qry.records_get()
              = 11
              t.close()
              
              dim mydate as D = {01/11/2007}
              t = table.open("invoice_header")
              query.filter = "date < ( {" + dtoc(mydate) + "} + 5 )" [COLOR="darkorange"] 'old fashioned syntax
                                                   'Notice the quote marks and the string concatenation[/COLOR]
              qry = t.query_create()
              ?qry.records_get()
              = 11
              t.close()
              
              
              dim mydate as D = {01/11/2007}
              t = table.open("invoice_header")
              query.filter = "date < " + s_quote(mydate + 5) [COLOR="DarkOrange"]'same thing, using newer s_quote() fn[/COLOR]
              qry = t.query_create()
              ?qry.records_get()
              = 11
              t.close()
              Last edited by Tom Cone Jr; 06-27-2009, 07:07 AM.

              Comment


                #8
                Re: Script Corrupts Product Table

                Thanks Tom,

                I will give this a try. Certainly makes sense the way you explained it, and will let ya'll know. Ryland

                Comment


                  #9
                  Re: Script Corrupts Product Table

                  Hi Tom,

                  Also, I think I see the problem when I run the Query. When I execute the Query, I am setting on a Dumy Form. What I noticed is that I saw Alpha change to openning the product table, but while I am still setting on the Dummy form (which is a menu). Then when I click on the "Products" buttom to bring the form up, the records display, etc on that Form is all screwed up.

                  So it looks like the culprit is that I'm assuming that you cannot run a standalone Query on a dummy form without messing up the primary form itself. One would think that by closing the table that would take care of it, but I guess not....so I'm stumped now on how to handle since I need my menu's on the Dummy Menu to be touch sensitive (no mouse) for selections.

                  Comment


                    #10
                    Re: Script Corrupts Product Table

                    Tom, and Gang

                    I found the problem, just do not know how to fix it. What is happening on the Menu as referenced above, is that after I find that first record, if it is available, I automatically run a Query on Product. That is what is locking up my Product screen when I depress the Menu button for it. The Product form is set to Query Mode...duhh for me...That is why when I leave Alpha and come back in, it is reset.

                    I'm trying to figure out the Query.Drop, in order to place it into the script to release the form but just cannot get the syntax right.

                    Well at least I know now to pay attention to the right hand bottm of the screen and look at the status. Just need now to know how to get out of it..

                    Hope this helps someone as well. as by adding qry.drop() did the trick in the script

                    Thanks,

                    Ryland
                    Last edited by [email protected]; 06-27-2009, 03:49 PM. Reason: Update it Works Yeah

                    Comment


                      #11
                      Re: Script Corrupts Product Table

                      Final Note:

                      As Tom stated earlier the Fetch first is more efficient, and do not have to worry about dropping the qry.drop() in the script:

                      'Date Created: 13-Mar-2009 02:26:53 AM
                      'Last Updated: 27-Jun-2009 07:36:49 PM
                      'Created By : Ryland
                      'Updated By : Ryland
                      DIM global_var_A as c
                      DIM GLOBAL user as C
                      DIM GLOBAL pword as C
                      DIM GLOBAL level as C
                      DIM GLOBAL varC_result as C
                      dim tbl as P
                      dim indx as P
                      dim count as N
                      '__________________________________________________

                      'a5.command("VIEW_TRACE")
                      tbl = table.open("Product")
                      query.filter = "Next_calibration_date <= date() + 15"
                      indx = tbl.query_create()
                      count = indx.records_get()
                      tbl.fetch_first()
                      '____________________________________________________

                      'while .NOT. tbl.fetch_eof()
                      ' trace.writeln(tbl.Next_calibration_date)
                      ' tbl.fetch_next()
                      'end while
                      '____________________________________________________

                      if count > 0 then
                      'msgbox(tbl_1.product_id)
                      BUTTON18.fill.style = "solid"
                      BUTTON18.fill.color = "Red"
                      end if


                      if count = 0 then
                      BUTTON18.fill.style = "solid"
                      BUTTON18.fill.color = "Green"
                      end if
                      indx.close()
                      tbl.close()
                      ui_msg_box("Record Count", "" + count)
                      end

                      Comment

                      Working...
                      X