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

Deleting scratch tables

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

  • Deleting scratch tables

    I made an application that creates scratch tables (does a couple of cross tabs and combines them, etc.) The code I use for this is:
    Code:
    '----------------------------------------------------------------------------
    'THE CODE BELOW REMOVES THE SCRATCH TABLES FROM
    'THE DATABASE. THEY MUST BE ERASED AND THEN REMOVED FROM THE LISTING
    '----------------------------------------------------------------------------
    'xtabcost
    'xtabunit
    'xtabcostunit
    'xtabcostunitar
    'error_costwithoutar
    '
    'Designating the file names with exact locations.
    	fileremname1 = dbfdir+"xtabcost"+".dbf"
    	fileremname2 = dbfdir+"xtabunit"+".dbf"
    	fileremname3 = dbfdir+"xtabcostunit"+".dbf"
    	fileremname4 = dbfdir+"xtabcostunitar"+".dbf"	
    	fileremname5 = dbfdir+"error_costwithoutar"+".dbf"	
    
    'The code stops running if for some reason the first file name doesn't exist
    	if fileremname1 = "" then
    	    end
    	end if
    'Erase the first file
    	table.erase(fileremname1, .T.)
    'Sets a variable to see if the erase of costxtab was successful
    	result = file.exists(fileremname1)
    'If the was erased successfully then the table is dropped from the database.
    'If not then an error pops up.
    	if result = .F. then
    	    FILE_DROP_FROM_DB(fileremname1)
    	else
    	    ui_msg_box("Erase:Error", fileremname1 + "Erase failed.")
    	end if
    'The code stops running if for some reason the second file does not exist
    	if fileremname2 = "" then
    	    end
    	end if
    'Erase the second file
    	table.erase(fileremname2, .T.)
    'Sets a variable to see if the erase of lbrxtab was successful
    	result = file.exists(fileremname2)
    'If the was erased successfully then the table is dropped from the database.
    'If not then an error pops up.
    	if result = .F. then
    	    FILE_DROP_FROM_DB(fileremname2)
    	else
    	    ui_msg_box("Erase:Error", fileremname2 + "Erase failed.")
    	end if
    'Erase the third file
    	table.erase(fileremname3, .T.)
    'Sets a variable to see if the erase of lbrxtab was successful
    	result = file.exists(fileremname3)
    'If the was erased successfully then the table is dropped from the database.
    'If not then an error pops up.
    	if result = .F. then
    	    FILE_DROP_FROM_DB(fileremname3)
    	else
    	    ui_msg_box("Erase:Error", fileremname3 + "Erase failed.")
    	end if
    'Erase the fourth file
    	table.erase(fileremname4, .T.)
    'Sets a variable to see if the erase of lbrxtab was successful
    	result = file.exists(fileremname4)
    'If the was erased successfully then the table is dropped from the database.
    'If not then an error pops up.
    	if result = .F. then
    	    FILE_DROP_FROM_DB(fileremname4)
    	else
    	    ui_msg_box("Erase:Error", fileremname4 + "Erase failed.")
    	end if
    'Erase the fifth file
    	table.erase(fileremname5, .T.)
    'Sets a variable to see if the erase of lbrxtab was successful
    	result = file.exists(fileremname5)
    'If the was erased successfully then the table is dropped from the database.
    'If not then an error pops up.
    	if result = .F. then
    	    FILE_DROP_FROM_DB(fileremname5)
    	else
    	    ui_msg_box("Erase:Error", fileremname5 + "Erase failed.")
    	end if
    
    ui_dlg_box("Files erased and dropped from the database",fileremname1+crlf()+fileremname2+crlf()+fileremname3+crlf()+fileremname4+crlf()+fileremname5+crlf(2)+"Browse the data to make sure you've done it correct"+crlf()+"Please backup this data!")
    The tables are erased and dropped from the database when I run this from the developer version but when I run it from the runtime I get a strange thing happening. The tables seem to be erased but still show up with an error (apparently not dropped.) It looks like this (see attachment):

    You can't delete tables while accessing the database from the runtime. Is this the problem? Is there some workaround that I can do to make these tables disappear?

    Thanks,
    Larry

  • #2
    Re: Deleting scratch tables

    I think I would avoid adding these scratch tables to the database. Any operations accessing them can be converted to xbasic and any xbasic referencing them can reference them by full path.

    I think you are right that FILE_DROP_FROM_DB(fileremname1) is not a valid command in the runtime.
    There can be only one.

    Comment


    • #3
      Re: Deleting scratch tables

      How can I use them if they aren't added to the database? As you see above, I already reference them from xbasic. Should I just create them in a scratch sub directory by changing the variable "dbfdir"? I didn't realize that if you created a table outside the directory where the database is located then it isn't a part of the database. If I'm not mistaken, I believe this is impossible in Access. Another reason to love Alpha 5.

      BTW I know my "if..else..end if" routine could be more compact and cleaner but I had to finish this thing in a matter of hours.
      Thanks,
      Larry

      Comment


      • #4
        Re: Deleting scratch tables

        I didn't realize that if you created a table outside the directory where the database is located then it isn't a part of the database.
        You can create a table anywhere that Alpha can reference including the database directory, drop that table from the database, then reference it via xbasic. The only need for a table to be part of a database is if the database definition needs to know its location. This would be for such things as tables in a set, tables used in saved operations, etc.

        If you create a summarize operation, for instance, the summarization genie assumes that the result table should be generally accessible to the database and adds it. If you look at the raw xbasic behind a summarize operation you will note that you have to supply the current table name and there is no code to add the table to the database. If you look at the processed xbasic all the "finer" points are filled in and the file_add_to_db() line is included.

        So long as your subsequent xbasic references the result table explicitly, that line is not necessary.

        Table.Open("sometablename") is shorthand which you can use if Alpha knows where sometablename is.

        Table.Open("d:\somedirectory\anotherdirectory\sometablename") is just as valid whether or not Alpha knows that sometablename resides in d:\somedirectory\anotherdirectory so long as it does.
        There can be only one.

        Comment


        • #5
          Re: Deleting scratch tables

          Attachment is a rather simplistic example of a database with no tables in the controlpanel. An autoexec script asks which of two forms to open (ages or names). Cancelling or choosing an invalid form name drops the user to the controlpanel. There are two tables in the directory with the adb but they are not part of the database.

          Since the autoexec has to refer to the tables by explicit path, to examine this you must place the files in

          c:\tempdb\tableless\
          There can be only one.

          Comment


          • #6
            Re: Deleting scratch tables

            These scratch tables are the result of crosstab operations and joins. All of that is done in xbasic as well. Does this make a difference?

            Comment


            • #7
              Re: Deleting scratch tables

              <<I think you are right that FILE_DROP_FROM_DB(fileremname1) is not a valid command in the runtime.>>

              Perhaps there's a bug in V9 (I don't have the V9 runtime to check it) but you've got to be able to add and drop files programatically with xbasic.

              If the file_drop_from_db command doesn't work in the runtime, there will be a lot of broken applications out there.
              Finian

              Comment


              • #8
                Re: Deleting scratch tables

                Finian,

                I took the poster's word for the behavior and did not confirm it. I have neither v9 or its runtime to test. Just suggesting a workaround.
                There can be only one.

                Comment

                Working...
                X