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

set.open_session()

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

    set.open_session()

    I am trying to write a code snippet in XBasic to open a set, update the fields in a parent table (tbl) with calculations based on a field in a child table (ftbl).

    The code below fails with an endless loop, after displaying a message box saying that the set is in use. I am not running on a network and there are no files open that I can see. I sometimes will get an error message that the tbl.change_begin() instruction in line 11 failed because a file was in use. Doesn't the set.open_session() command start a completely new session, regardless of what else is going on?

    dim wset as p
    dim tbl as p
    dim ftbl as p
    wset = set.open_session("set_final")
    if wset.in_use("set_final") then
    ui_msg_box("error","set is in use")
    else
    ui_msg_box("ok","opening the set")
    end if
    tbl = wset.get_primary()
    ftbl = wset.followup

    tbl.change_begin()
    tbl.dof = ftbl.dof
    wks = tbl.wksfu
    select
    case wks < 4
    tbl.p2 = "c"
    interval = "2 weeks"
    case wks <= 7
    tbl.p6 = "c"
    interval = "6 weeks"
    case wks <=14
    tbl.p12 = "c"
    interval = "12 weeks"
    case wks <=30
    tbl.p26 = "c"
    interval = "26 weeks"
    case wks <= 60
    tbl.p52 = "c"
    interval = "52 weeks"
    case wks <= 120
    tbl.p104 = "c"
    interval = "2 years"
    case wks <= 162
    tbl.p156 = "c"
    interval = "3 years"
    case wks <= 215
    tbl.p208 = "c"
    interval = "4 years"
    case wks <= 270
    tbl.p260 = "c"
    interval = "5 years"
    text = "Weeks = " + wks + "Interval = " + interval
    ui_msg_box("Interval and Weeks",text)

    end select

    while .not. tbl.eof()
    while .not. ftbl.eof()

    tbl.dof = ftbl.dof
    wks = tbl.wksfu
    select
    case wks < 4
    tbl.p2 = "c"
    interval = "2 weeks"
    case wks <= 7
    tbl.p6 = "c"
    interval = "6 weeks"
    case wks <=14
    tbl.p12 = "c"
    interval = "12 weeks"
    case wks <=30
    tbl.p26 = "c"
    interval = "26 weeks"
    case wks <= 60
    tbl.p52 = "c"
    interval = "52 weeks"
    case wks <= 120
    tbl.p104 = "c"
    interval = "2 years"
    case wks <= 162
    tbl.p156 = "c"
    interval = "3 years"
    case wks <= 215
    tbl.p208 = "c"
    interval = "4 years"
    case wks <= 270
    tbl.p260 = "c"
    interval = "5 years"
    text = "Weeks = " + wks + "Interval = " + interval
    ui_msg_box("Interval and Weeks",text)

    end select
    end while
    end while
    tbl.change_end()
    David A. Volgas, MD

    #2
    Re: set.open_session()

    Not sure about your issues with an already open (or so Alpha thinks) SET but you need to modify the while loops as indicated.

    Code:
    WHILE .not. tbl.[COLOR="Red"]fetch_[/COLOR]eof()
    	WHILE .not. ftbl.[COLOR="red"]fetch_[/COLOR]eof()
    		[COLOR="red"]tbl.change_BEGIN()[/COLOR]
    		tbl.dof = ftbl.dof
    		wks = tbl.wksfu
    		SELECT
    			CASE wks < 4
    				tbl.p2 = "c"
    				interval = "2 weeks"
    			CASE wks <= 7
    				tbl.p6 = "c"
    				interval = "6 weeks"
    			CASE wks <=14
    				tbl.p12 = "c"
    				interval = "12 weeks"
    			CASE wks <=30
    				tbl.p26 = "c"
    				interval = "26 weeks"
    			CASE wks <= 60
    				tbl.p52 = "c"
    				interval = "52 weeks"
    			CASE wks <= 120
    				tbl.p104 = "c"
    				interval = "2 years"
    			CASE wks <= 162
    				tbl.p156 = "c"
    				interval = "3 years"
    			CASE wks <= 215
    				tbl.p208 = "c"
    				interval = "4 years"
    			CASE wks <= 270
    				tbl.p260 = "c"
    				interval = "5 years"
    				text = "Weeks = " + wks + "Interval = " + interval
    				ui_msg_box("Interval and Weeks",text)
    				
    		END SELECT
    		[COLOR="red"]tbl.change_end(.t.)
    		ftbl.fetch_next()[/COLOR]
    	END WHILE
    	[COLOR="red"]tbl.fetch_next()[/COLOR]
    END WHILE
    Last edited by Stan Mathews; 01-14-2009, 06:45 PM.
    There can be only one.

    Comment


      #3
      Re: set.open_session()

      Thanks!

      Now, I still get a "The process cannot access the file because another process has locked a portion of the file. demographics.dbf" error message at line 21.

      I really don't understand how to access fields in a set. I have read the help files, but ....

      dave
      David A. Volgas, MD

      Comment


        #4
        Re: set.open_session()

        David,
        I'm curious about
        ftbl = wset.followup
        Maybe just showing my ignorance (again!), but this seems to be trying to set a pointer (ftbl) to equal a set field called followup. Even if a set had a field and you created a pointer to represent this, then what would the following part of the script mean.
        Code:
        tbl.dof = [COLOR=Red]ftbl.dof[/COLOR]
        So if ftbl is now actually wset.followup it would make this be
        tbl.dof = wset.followup.dof

        I've looked at this a few times and have done similar things myself in working with sets, but obviously I'm missing something here! :)
        Mike
        __________________________________________
        It is only when we forget all our learning that we begin to know.
        It's not what you look at that matters, it's what you see.
        Henry David Thoreau
        __________________________________________



        Comment


          #5
          Re: set.open_session()

          Mike,

          I think he has that done correctly.

          wset = set.open_session("set_final") 'establish pointer to set
          if wset.in_use("set_final") then .....
          .....
          tbl = wset.get_primary() 'establish pointer to parent table of the set
          ftbl = wset.followup ' establish pointer to the "followup" table in the set
          There can be only one.

          Comment


            #6
            Re: set.open_session()

            I am not running on a network and there are no files open that I can see.
            By what means are you initiating the script? If you have a form based on the set or any of the tables in the set.....

            The <SET>.IN_USE() method returns .T. (TRUE) if any of the tables that comprise a set are in use; otherwise, it returns .F. (FALSE).
            There can be only one.

            Comment


              #7
              Re: set.open_session()

              If you open a set (or a table) via xbasic, the set is now in use making the if statment at the start of the script useless.
              .. didn't read much further..gotta go to work. Will play with this later.

              Comment


                #8
                Re: set.open_session()

                Thanks for clarifying Stan. Now to see what advantage there is to using that method of using a set's tables compared to how I have done it in the past...which would be a thread of its own if need be.
                Mike
                __________________________________________
                It is only when we forget all our learning that we begin to know.
                It's not what you look at that matters, it's what you see.
                Henry David Thoreau
                __________________________________________



                Comment


                  #9
                  Re: set.open_session()

                  never did get the set commands working ... using the current build. Maybe this is a bug????

                  Using a little different approach, this works fine:

                  'Date Created: 14-Jan-2009 05:21:24 PM
                  'Last Updated: 15-Jan-2009 08:18:04 AM
                  'Created By : Dave
                  'Updated By : davidv

                  dim tbl as p
                  dim ftbl as p
                  dim qry as p
                  tbl = table.open("demographics")
                  ftbl = table.open("followup")
                  tbl.fetch_first()
                  ftbl.fetch_first()
                  WHILE .not. tbl.fetch_eof()
                  currec = tbl.Mrn
                  tbl.change_begin()
                  tbl.dof = ftbl.dof
                  tbl.Dayssinceinjiry = date() - tbl.doi
                  tbl.wkspo = (date() - tbl.Dos_def)/7
                  tbl.p2 = ""
                  tbl.p6 = ""
                  tbl.p12 = ""
                  tbl.p26 = ""
                  tbl.p52 = ""
                  tbl.p104 = ""
                  tbl.p156 = ""
                  tbl.p208 = ""
                  tbl.p260 = ""
                  wks = tbl.wkspo
                  if wks >3 then
                  tbl.p2 = "m"
                  end if
                  if wks >7 then
                  tbl.p6 = "m"
                  end if
                  if wks >14 then
                  tbl.p12 = "m"
                  end if
                  if wks >30 then
                  tbl.p26 = "m"
                  end if
                  if wks >60 then
                  tbl.p52 = "m"
                  end if
                  if wks >120 then
                  tbl.p104 = "m"
                  end if
                  if wks >162 then
                  tbl.p156 = "m"
                  end if
                  if wks >215 then
                  tbl.p208 = "m"
                  end if
                  if wks >270 then
                  tbl.p260 = "m"
                  end if
                  tbl.change_end(.t.)
                  qry = ftbl.query_create("T","followup->mrn = " + s_quote(currec))

                  WHILE .not. ftbl.fetch_eof()
                  tbl.change_BEGIN()
                  wks = (ftbl.Dof - tbl.Dos_def)/7
                  if tbl.Wksfu < wks then
                  tbl.Wksfu = wks
                  end if

                  ftbl.change_begin()
                  ftbl.Wks = wks
                  ftbl.change_end(.t.)
                  SELECT
                  case between(wks,1,3)
                  tbl.p2 = "c"

                  case between(wks,5,7)
                  tbl.p6 = "c"

                  case between(wks,10,14)
                  tbl.p12 = "c"

                  case between(wks,20,30)
                  tbl.p26 = "c"

                  case between(wks,45,60)
                  tbl.p52 = "c"

                  case between(wks,90,120)
                  tbl.p104 = "c"

                  case between(wks,145,162)
                  tbl.p156 = "c"

                  case between(wks,200,215)
                  tbl.p208 = "c"

                  case between(wks,250,270)
                  tbl.p260 = "c"

                  END SELECT


                  tbl.change_end(.t.)

                  ftbl.fetch_next()
                  END WHILE
                  tbl.fetch_next()
                  END WHILE
                  ui_msg_box("Success","finished",UI_OK_CANCEL)
                  David A. Volgas, MD

                  Comment

                  Working...
                  X