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

need a script to pack 5 data bases

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

    need a script to pack 5 data bases

    i'm trying to write an xbasic script to pack 5 data bases with the one command; however i don't see anything but the ui_msg_box. Nothing happens to the files.
    the trace window remains blank both when operating the script and doing each file individually from tables/set tab.

    here is the script:
    ''XBasic
    response=ui_msg_box(" PACK THE DATA BASES", "ARE YOU SURE?",35)
    IF RESPONSE = 6 THEN:Table.Pack(Z:REWORKFILE.DBF)
    ELSEIF RESPONSE = 6 THEN:Table.Pack(Z:REWORKRWK1.DBF)
    ELSEIF RESPONSE = 6 THEN:Table.Pack(Z:REWORKRWKBRT.DBF)
    ELSEIF RESPONSE = 6 THEN:Table.Pack(Z:REWORKRWKNME.DBF)
    ELSEIF RESPONSE = 6 THEN:Table.Pack(Z:REWORKRWKRPT.DBF)
    END IF
    END
    what am i doing wrong?
    thanks in advance.

    #2
    RE: need a script to pack 5 data bases

    Dave,

    In ver 1 I wrote a routine to recursively zap tables (databases in a directory. It will need some minor modification, but for what its worth, here it is.


    dim files(400) as C
    direct = dir_get()
    for i = 1 to 400
    files(i) = file_find("*.dbf",i)
    if files(i) = ""
    file_count = i-1
    exit FOR
    end if
    next
    FOR j = 1 to file_count
    DB_NAME = direct+chr(92)+files(j)
    dbh = db_use(DB_NAME)
    ques=UI_MSG_BOX("ZAP this?",DB_NAME,35)
    if ques = 6 then
    'zap the file
    db_zap(dbh, .T.)
    elseif ques = 7
    'dont
    else
    end
    end if
    db_close(dbh)
    NEXT
    end


    hope it helps,

    tom

    Comment


      #3
      RE: need a script to pack 5 data bases

      Your problem appears to be that

      :Table.Pack(Z:REWORKFILE.DBF)

      is not a valid xbasic command. It resembles the xbasic syntax "tbl>.pack() command but it appears to be a cross between form methods and xbasic methods. I would suggest something like

      tbl = table.open("Z:\reworkfile.dbf")
      tbl.pack()
      tbl.close()
      There can be only one.

      Comment


        #4
        RE: need a script to pack 5 data bases

        As a duly deputized member of the grammar police, I call to your attention that a DBF table is not a database, at least as that term is used in Alpha Five's documentation. The database is a collection of tables and sets.

        -- Ignatious A. PickyPicky

        Comment


          #5
          RE: need a script to pack 5 data bases

          Another issue that needs addressed is the fact that a table must be opened in exclusive mode to pack. If it is already open, an error will be generated and must be trapped or the script will fail. Here is a script segment for a proven pack routine I use to pack an array of tables. In the example, I use two arrays. In one array, tblnames(i), I save the table name. In the other, tables(i), I save the table with path. Then I set the variable count to the number of array entires.

          Dim tblnames() as c
          Dim tables() as c
          Dim count as n

          tblnames(1) = �usertable1�
          tables(1) = �c:/data/usertable1.dbf�

          tblnames(2) = �usertable2�
          tables(2) = �c:/data/usertable2.dbf�

          ' and so on until all tables are in the array

          count = 2 'or the number of array entries

          on error goto error_msg

          no_error = .T.
          for i = 1 to count
          tbl = table.open(tables(i),FILE_RW_EXCLUSIVE)'//// Only pack if file is open exclusively
          if no_error
          tbl.pack()
          tbl.close()
          end if
          no_error = .T.
          next

          END

          error_msg:
          ui_msg_box("Remove Deleted Records","Deleted records could NOT be removed "
          +chr(13)+"from "+tblnames(i)+" file.",UI_INFORMATION_SYMBOL)
          no_error = .F.
          resume next
          end

          Using this script, only tables that open exclusively will pack. Others will generate a message to the user.

          Jerry

          Comment


            #6
            RE: need a script to pack 5 data bases

            Tom (aka I.A. P'P')

            I agree with your "The database is a collection of tables and sets." statement. However, he never spoke, nor typed, of databases. I wonder what "data bases" are.

            So there Mr I. A. PickyPicky

            PS for David -

            This is all tongue-in-cheek. We do this for fun, certainly not for pay, so we have fun with what we do.

            Stan
            There can be only one.

            Comment


              #7
              RE: need a script to pack 5 data bases

              thanks to Tom H. for his suggestions. I have a script which works.
              my main concern is: i'm using alpha five v4.03 build214
              and i drag the strange commands from the xbasic explorer - i.e :TABLE.PACK()
              have i got a bad or wrong edition of the xbasic explore?

              here is the script which appears to work for me now:
              thanks again Tom.
              ''XBasic
              DIM FILES(400) AS C
              DIR_PUT("Z:REWORK") ' INSERT DIRECTORY FOR DATA FILES WHERE THIS IS ATTACHED
              DIRECT=DIR_GET()
              FOR I=1 TO 400
              FILES(I)=FILE_FIND("*.DBF",I)
              IF FILES(I)=""
              FILE_COUNT=I-1
              EXIT FOR
              END IF
              NEXT
              MMM=" PACK "+STR(FILE_COUNT,2)+ " FILES" 'GIVES FILE COUNT ON MESSAGE BOX
              QUES=UI_MSG_BOX(MMM, "PACK THIS ?",35)
              FOR J=1 TO FILE_COUNT
              DB_NAME=DIRECT+CHR(92)+FILES(J)
              DBH=DB_USE(DB_NAME)' INSERT QUES AFTER THIS LINE TO SAY YES FOR EACH FILE PACK
              IF QUES=6 THEN 'ALSO CHANGE MMM TO DB_NAME IN UI_MSG_BOX
              DB_PACK(DBH)
              ELSEIF QUES=7 'DONT
              ELSE
              END
              END IF
              DB_CLOSE(DBH)
              NEXT
              END

              Comment


                #8
                RE: need a script to pack 5 data bases

                thanks, i enjoyed the banter.

                Comment


                  #9
                  RE: need a script to pack 5 data bases

                  >

                  hmmm...maybe the opposite of data acids??

                  Comment


                    #10
                    RE: need a script to pack 5 data bases

                    David,

                    Goes to show I can learn something. I found the

                    :Table.Pack() ----- in the xbasic explorer, still there in 4.5 build 266 - not in the documentation as far as I can see

                    contrast the syntax thus generated with dragging in another explorer command

                    :Table.Delete_Dups(C Dup_Key_Expression,C Filter_Expression)

                    This command takes two parameters, :table.pack() takes none (like :Table.close()).

                    Your usage

                    :Table.Pack(Z:\REWORKFILE.DBF) seems to be the problem. Since I wasn't aware of the method, I'm not familiar with how it should be used, but I will look into it.

                    Thanks,

                    Stan
                    There can be only one.

                    Comment


                      #11
                      RE: need a script to pack 5 data bases

                      Tried and tested. The :Table methods are parallels of the xbasic pointer methods I posted earlier.

                      :Table.Open("tablename")
                      :Table.Pack()
                      :Table.Close()

                      So your original script should be:

                      ''XBasic
                      response=ui_msg_box(" PACK THE DATA BASES", "ARE YOU SURE?",35)

                      IF RESPONSE = 6
                      :Table.OPEN("Z:\REWORKFILE.DBF")
                      :Table.Pack()
                      :table.close()

                      :Table.Open("Z:\REWORKRWK1.DBF")
                      :Table.Pack()
                      :table.close()

                      :Table.Open("Z:\REWORKRWKBRT.DBF")
                      :Table.Pack()
                      :table.close()

                      :Table.Open("Z:\REWORKRWKNME.DBF")
                      :Table.Pack()
                      :table.close()

                      :Table.Open("Z:\REWORKRWKRPT.DBF")
                      :Table.Pack()
                      :table.close()

                      END IF
                      END
                      There can be only one.

                      Comment

                      Working...
                      X