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 variable to persist from database to database?

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

    Need a variable to persist from database to database?

    Is there a variable declaration that will persist when opening a new database?

    I am creating it in one database as a global variable, changing it in another database, but when I come back to the original database, it appears that the variable did not persist.
    John J. Fatte', CPA
    PRO-WARE, LLC
    Omaha, NE 68137

    #2
    Re: Need a variable to persist from database to database?

    I suppose there's a reason you don't want to use the help files?

    Variable
    -----Scope


    Note the description of Addin variables

    Also the "tutorial", Thanks Tom Henkel
    There can be only one.

    Comment


      #3
      Re: Need a variable to persist from database to database?

      After reviewing the documentation, I see that the Global variable only persists until the database is closed.

      What is the recommended solution to pass a value back and forth when changing databases?

      Can you pass a parameter to the autoexec script?
      John J. Fatte', CPA
      PRO-WARE, LLC
      Omaha, NE 68137

      Comment


        #4
        Re: Need a variable to persist from database to database?

        Originally posted by Stan Mathews View Post
        I suppose there's a reason you don't want to use the help files?

        Variable
        -----Scope


        Note the description of Addin variables
        Found it. Thanks for pointing my nose in the right direction.

        If this forum wasn't so good, I'd probably rely on the help file a lot more. But I can typically post a question on here and get a response long before I can find it in the help file.
        John J. Fatte', CPA
        PRO-WARE, LLC
        Omaha, NE 68137

        Comment


          #5
          Re: Need a variable to persist from database to database?

          John,

          If this forum wasn't so good, I'd probably rely on the help file a lot more. But I can typically post a question on here and get a response long before I can find it in the help file.
          Like most things, there is a learning curve to using the Help files, and after you use them and get used to using them, you will find it becomes significantly faster. For me, I forget most of what I learn and have to relearn it through re-looking up in the help files...... all the time! :(
          Mike W
          __________________________
          "I rebel in at least small things to express to the world that I have not completely surrendered"

          Comment


            #6
            Re: Need a variable to persist from database to database?

            Originally posted by Stan Mathews View Post
            I suppose there's a reason you don't want to use the help files?

            Variable
            -----Scope


            Note the description of Addin variables

            Also the "tutorial", Thanks Tom Henkel
            I've run into another problem:

            When the application starts and database 1 is opened, the following code is executed in the autoexec script:

            dim c_do_what as P
            c_do_what = addin.variables()
            c_do_what.varname = "Startup"

            I then change to database 2 and execute the following before returning to the 1st database:

            dim c_do_what as P
            c_do_what = addin.variables()
            c_do_what.varname = "Relocate"


            When I return to database 1, the c_do_what.varname has been successfully chanaged to "Relocate".

            The problem is this. When the 1st database is opened, I only want to execute the line "c_do_what.varname = "Startup" if c_do_what.varname does NOT have a value; otherwise, I will change the value to Startup every time I return to database 1.

            How do I evaluate c_do_what.varname to see if it has a value?

            I tried eval_valid() and it errors out if it does not have a value, but has been dimensioned as a pointer variable.
            John J. Fatte', CPA
            PRO-WARE, LLC
            Omaha, NE 68137

            Comment


              #7
              Re: Need a variable to persist from database to database?

              John:
              You lost me!
              Seems like you are leaving out another peice of information.

              1-When you open DB 1 you set c_do_what.varname to "Startup"
              2-Then you go to DB 2 and set c_do_what.varname to "Relocate"
              3-Then you go back to DB 1 where c_do_what.varname = "Relocate"
              The question is, why didn't you set c_do_what.varname in DB 1 to "Relocate" in the first place?
              Are you doing something in between?

              But regardless, what you should do in DB 1 is:
              Code:
              if c_do_what.varname="" '[COLOR="Blue"]I don't see how this could happen 
              unless as I said you are doing something in between.[/COLOR]
              dim c_do_what as P
              c_do_what = addin.variables()
              c_do_what.varname = "Startup"
              end if

              Comment


                #8
                Re: Need a variable to persist from database to database?

                Originally posted by G Gabriel View Post
                John:
                You lost me!
                Seems like you are leaving out another peice of information.

                1-When you open DB 1 you set c_do_what.varname to "Startup"
                2-Then you go to DB 2 and set c_do_what.varname to "Relocate"
                3-Then you go back to DB 1 where c_do_what.varname = "Relocate"
                The question is, why didn't you set c_do_what.varname in DB 1 to "Relocate" in the first place?
                Are you doing something in between?

                But regardless, what you should do in DB 1 is:
                Code:
                if c_do_what.varname="" '[COLOR="Blue"]I don't see how this could happen 
                unless as I said you are doing something in between.[/COLOR]
                dim c_do_what as P
                c_do_what = addin.variables()
                c_do_what.varname = "Startup"
                end if
                Database 1 is a loader database that does some housekeeping functions when requested by database 2.

                So when database 1 the first time, all it does is change to database 2 and the application runs.

                Database 2 will have an option to re-locate the database (#2) to a new location. To accomplish this programmatically, it will be handled by database 1, but I need to send a message to database 1 to do that. That's why I'm changing the variable to "Relocate" and that's why I need to know in database 1 if the "c_do_what" variable has been previously declared and not to change it.
                John J. Fatte', CPA
                PRO-WARE, LLC
                Omaha, NE 68137

                Comment


                  #9
                  Re: Need a variable to persist from database to database?

                  Gabe, John is trying to deal with a scenario where when the app is on a users site, and they maybe change the folder name how to deal with it.

                  Correct, John?

                  I would have a table in the master adb that contained folder locations
                  if the user opts to change the folder location at startup, save the change, and then by default it would always know the location until changed again
                  Cole Custom Programming - Terrell, Texas
                  972 524 8714
                  [email protected]

                  ____________________
                  "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                  Comment


                    #10
                    Re: Need a variable to persist from database to database?

                    John
                    By definition, addin variables will persist between databases,i.e. they will not go away unless you intentionally and explicitly delete them hence there is no need to use eval_valid() in this case.
                    The question is not whether it was declared. Once you dim this variable, it will be there, indefinitely, until you delete it. The question is what's its value? Is it "Startup"? Or "Relocate"? And what do you want it to be? and when and where?

                    Comment


                      #11
                      Re: Need a variable to persist from database to database?

                      I'm not sure if using addins is the way to accomplish what you want. I use them to set the user name, rights, etc.

                      If I understand, all you want to do is have their choice point to the correct folder where the apps is installed - correct?
                      Cole Custom Programming - Terrell, Texas
                      972 524 8714
                      [email protected]

                      ____________________
                      "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                      Comment


                        #12
                        Re: Need a variable to persist from database to database?

                        Originally posted by G Gabriel View Post
                        John
                        By definition, addin variables will persist between databases,i.e. they will not go away unless you intentionally and explicitly delete them hence there is no need to use eval_valid() in this case.
                        The question is not whether it was declared. Once you dim this variable, it will be there, indefinitely, until you delete it. The question is what's its value? Is it "Startup"? Or "Relocate"? And what do you want it to be? and when and where?
                        Garbriel

                        When the first database (the loader) gets loader, I have to use eval_valid() to see if the addin variable exists. And this works fine. Since it doesn't exist, it correctly dim's the variable and initializes the value to "Startup".

                        This is the initial code in the autoexec of the 1st database:

                        if not eval_valid("c_do_what.varname")

                        dim the variable
                        c_do_what = addin.variables()
                        c_do_what = "Startup"

                        end if

                        then a5.load the 2nd database.

                        When the second database gets loaded, if they select the option to "relocate the database" it does this.

                        c_do_what = addin.variables
                        c_do_what = "Relocate"
                        a5.load the 1st database

                        When it comes back to the 1st database, when it gets to the line

                        if not eval_valid("c_do_what.varname")

                        it always returns false and the c_do_what variable gets set back to Startup so the case statement just jumps back to the 1st database.

                        Does this make it any clearer?
                        John J. Fatte', CPA
                        PRO-WARE, LLC
                        Omaha, NE 68137

                        Comment


                          #13
                          Re: Need a variable to persist from database to database?

                          John,
                          Just tell us what is supposed to happen--using the different scenarios that are possible--I just read the entire thread and don't really see a specific question / problem anymore!

                          As a side note---seeing as how even the addin variables do not exist when Alpha Five closes, if you want them to still persist then a simple text file read/write would get you there as far as retaining values.
                          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


                            #14
                            Re: Need a variable to persist from database to database?

                            John:
                            Again, you only need to dim the addin variable ONCE. I t will live in the stratosphere of your application until you kill it. Closing and re-opening the database does not kill it. So if you dimmed it yesterday or this morning, it will forever be there and that's why:
                            if not eval_valid("c_do_what.varname") will and forever be false that's until you intentionally delete this variable.

                            Sounds to me that you want:
                            1-c_do_what.varname to be set to "Startup" only and only when DB 1 is opened for the first time
                            2-Then c_do_what.varname will be set by the user in DB 2
                            3-Then when you go back to DB 1 c_do_what.varname stays at what the user set it in DB 2

                            So the real question is:
                            How to set c_do_what.varname to "Startup" when DB 1 is first opened then let the user set it afterwards?
                            Right?
                            If so, this should do it.
                            Code:
                            if eval_valid(c_do_what.varname)=.f.
                            dim c_do_what as P
                            c_do_what = addin.variables()
                            c_do_what.varname = "Startup"
                            end if
                            Last edited by G Gabriel; 12-17-2009, 02:26 PM.

                            Comment


                              #15
                              Re: Need a variable to persist from database to database?

                              Originally posted by G Gabriel View Post
                              John:
                              Again, you only need to dim the addin variable ONCE. I t will live in the stratosphere of your application until you kill it. Closing and re-opening the database does not kill it. So if you dimmed it yesterday or this morning, it will forever be there and that's why:
                              if not eval_valid("c_do_what.varname") will and forever be false that's until you intentionally delete this variable.

                              Sounds to me that you want:
                              1-c_do_what.varname to be set to "Startup" only and only when DB 1 is opened for the first time
                              2-Then c_do_what.varname will be set by the user in DB 2
                              3-Then when you go back to DB 1 c_do_what.varname stays at what the user set it in DB 2

                              So the real question is:
                              How to set c_do_what.varname to "Startup" when DB 1 is first opened then let the user set it afterwards?
                              Right?
                              If so, this should do it.
                              Code:
                              if eval_valid(c_do_what.varname)=.f.
                              dim c_do_what as P
                              c_do_what = addin.variables()
                              c_do_what.varname = "Startup"
                              end if
                              Gabriel

                              You have 100% grasped the idea of what I'm trying to do; however, the problem is that your code (which is the same as my code) ALWAYS returns false - when DB 1 is loaded for the first time as well as when DB 1 is loaded from DB 2.

                              There in lies the whole problem. I can't NOT tell whether I'm running DB 1 for the first time (actually I can, because the eval_valid("c_do_what.varname") properly returns false), but when it returns from DB 2, it still returns false.

                              I would be happy to provide you with some code, DB's, etc. if that will help.

                              I believe you can also test this by just using the interactive mode in each database.
                              John J. Fatte', CPA
                              PRO-WARE, LLC
                              Omaha, NE 68137

                              Comment

                              Working...
                              X