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

How do you close table/set sessions with Xbasic?

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

  • How do you close table/set sessions with Xbasic?

    Hi folks,

    I was testing some standalone Xbasic which included...
    t = table.open_session(tblname)
    ...but in which I hadn't got as far as putting in a t.close(). I now have a rather unhealthy number of table sessions open.

    Obviously I could close them by closing A5, but that seems to be a hammer to crack a nut. Given how extensive A5's capabilities are, I'd be surprised if there isn't a way to close them with Xbasic but I've searched and searched and can't find anything. Anyone have any thoughts/tips?

    Thanks.

    Regards,
    Trevor

  • #2
    RE: How do you close table/set sessions with Xbasi

    Trevor,

    The following X-Basic opens the "tbl_Customer_Contacts" table, creates a new record, writes the value held in vc_new_title to the "Title" field, saves the record and closes the table.

    Is this what you were looking for?


    dim tbl as p
    tbl = table.open("tbl_customer_contacts",FILE_RW_SHARED)
    tbl.enter_begin()
    tbl.TITLE = convert_type(vc_new_title,"Character")
    tbl.enter_end(.t.)
    tbl.close()


    Louis Nickerson
    ASMIAP! Software

    Comment


    • #3
      RE: How do you close table/set sessions with Xbasi

      If you are thinking of a clean-up function that closes all open tables, you could create one, starting with Ta ble.Enum_Open().

      Comment


      • #4
        RE: How do you close table/set sessions with Xbasi

        Or use A5_FORCECLOSETABLES().

        Comment


        • #5
          RE: How do you close table/set sessions with Xbasi

          Hello Trevor,

          ""t = table.open_session(tblname)""

          Louis gave you the solution, t.close(), but I'm curious why you are using the table.open_session() method instead of table.open()?

          Alpha does a good job of cleaning up after itself. When a session is closed, Alpha attempts to close all table pointers opened in the session. I'm not sure how that would work when using the table.open_session() method. I've never used it myself.

          Jim

          Comment


          • #6
            RE: How do you close table/set sessions with Xbasi

            Hi folks,

            thanks for your responses. The code I have looks like this. Note that the line t.close() is missing...

            t = table.open_session("contacts")
            redim global ar[5] as P
            i=1
            For i = 1 to n
            ar[i].Firstname = t.firstname
            ar[i].Lastname = t.lastname
            t.fetch_next()
            next i


            I was testing it and ran it a number of times. I realised that there must be a load of table sessions open somewhere and, sure enough, when I looked in the Xbasic Explorer, there they were. The problem was, I was unable to see any way to determine what session I was currently "in," or any way to switch sessions or close the excess ones. I realised that even if you have the t.close() line, if your code fails to reach it for some reason, then you could end up opening more and more sessions until eventually A5 falls over.

            I tried running...
            ? table.enum_session_open("F"+crlf())
            and
            ? table.enum_open("F"+crlf())
            ...but all these told me was that the only database open was null.dbf so I'm not sure A5_FORCECLOSETABLES() would help (it's also not listed in the Feb 2 .chm).


            Ed, a few points:
            1. it is unfortunate that the word "session" applies to both the whole A5 session and to individual instances of a table being open, as this does create a little confusion. Would it be possible change the terminology so you have session and tablesession, or session and instance?
            2. I do not see the difference between what table.enum_session_open("F"+crlf()) and table.enum_open("F"+crlf()) do. Could the manual have an example highlighting the difference?
            3. As for solving the main problem above, I guess what I need are some functions along the lines of...
            session.tableinstances_enum()
            session.tableinstances_activate()
            session.tableinstances_close()

            Regards,
            Trevor

            Comment


            • #7
              RE: How do you close table/set sessions with Xbasi

              Trevor,

              I hope somebody comes up with an answer. My solution has always been to (1) swear at myself for screwing up again, (2) close alpha, (3) swear at myself for screwing up again, (4) restart alpha, (5) swear at myself for screwing up again, (6) try to get back to whatever I was doing before, and finally, (7) swear at myself for screwing up again.

              Computer - the great leveler.

              Cal Locklin
              www.aimsdc.net

              Comment


              • #8
                Re: How do you close table/set sessions with Xbasic?

                Was looking for this same solution so I bumped it.

                If I define a table pointer as
                tmp = table.open_session("mytemp")

                and I want to test if that table closed properly I can use

                if tmp.enum_session_open() = "mytemp" then
                tmp.close()
                end if

                Because if the table is not open in its session, then the return value for this function is 'NUL' otherwise it returns the table name. And I do not have to concern myself with any of the other tables that may be open in other sessions.

                Nor can you use:
                table.isopen("mytemp") or table.isopen(tmp.name_get()) because both will return .F. as they are not looking to the correct session
                and table.in_use("mytemp") with not help either if the table is opened more than once because you will get a false positive for the session you are concerned with.

                BTW in the Wiki is says to get a list of tables by using the table.enum_open() method and then set a pointer using table.get() to close a table. This will only return 'no such table'. You need to have your pointer already defined else you cannot close the table any other way.

                Opening a table (again) in its own session allows you to use ptr.enum_session_open() when all else may fail - especially in a multiuser environment.

                Edit: There may be more than one table in the list if the pointer is to a table in a set so I tried this in my script and it seems to work better

                Code:
                CLOSETBLS:
                	lst1 = crlf_to_comma(tmp.Enum_Session_Open())
                	if inlist2(tmp.name_get(),lst1) then
                		tmp.close()
                	end if
                	lst2 = crlf_to_comma(thf.Enum_Session_Open())
                	if inlist2(thf.name_get(),lst2) then
                		thf.close()
                	end if
                Last edited by MoGrace; 02-15-2018, 02:36 PM. Reason: correction
                Robin

                Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                Comment

                Working...
                X