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

Loosing Global Variables

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

    #31
    Re: Loosing Global Variables

    but the statement, if followed, would eventually lead to everyone leaving the room, ostensibly forever in search of a room in which they were not the smartest.
    Possibly. I've never been in such a situation.
    There can be only one.

    Comment


      #32
      Re: Loosing Global Variables

      So, Stan - you're never alone? ;)

      Being the smartest person in the room has its own difficulties...
      Robin

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

      Comment


        #33
        Re: Loosing Global Variables

        There were cases in 4.5 where, when you were using stuff like query.filter=, unless you dimmed a variable (even though it was a global variable) the query would fail - not sure if that is still the case

        but if you "dim global vdate as d=date()" in the autoexec
        in a script you can say
        dim global vdate as d
        and it will not change the value of vdate
        then, when writing the script, the variable is in the autofill/find when writing the script
        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


          #34
          Re: Loosing Global Variables

          Bringing up an old thread that came to mind last night and maybe help someone in the future.

          Trying to dim a variable as global when it already was did NOT work. Once I realized it was already there, I played with it a bit. If I created it again and supplied a new vaue, it would work within the script with the assigned value. Once out of the script, the original value cam to life.

          variable name is vxaddress and is dimmed in a main for to be used constantly from the application. I globally dimmed the same name, tried to open a form and fill a fill a field with the contents to find the contents wrong.

          When I figured it all out. I simply gave the existing global variable a new value and all was well.

          My point: Do not dim a global variable a second time since the results can come out way wrong. Just give it a new value! Pretty much what Martin above and several of us have said in this thread
          Dave Mason
          [email protected]
          Skype is dave.mason46

          Comment


            #35
            Re: Loosing Global Variables

            dave,
            if you say dim global xxx as c="xxx"
            and it was already declared previously as global, it won't work
            but if you say dim global xxx as c; xxx="xxx", it will work, and persist. It has always been this way, as far as I know.
            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


              #36
              Re: Loosing Global Variables

              it was dimmed as dim global vxaddress = "" which is how I dim my variables. Then a value of "123 main st" was inserted by var->vxaddress = "123 Main St"
              in another part of the form where I would open a form with one field on it the variable would be read into it oninit. I mistakenly dim the variable as global again with a different address. I still got "123 main st", no matter what the new one was.
              The view global variables showed the old address as well. It never changed.
              Once I did not dim again and just did var->vxaddress = "3985 Wilson st" it worked fine.

              Possibly, how you dim is part of it?
              dim global sss as c = "abd"
              may be different than
              dim global sss as c
              var->sss = "abd"

              Do not know.

              I (for 1) always keep variables as the same type. If it starts as c, it stays a c

              Note: This is being done in v12, but it is the same in v11.
              Last edited by DaveM; 04-23-2015, 10:13 PM.
              Dave Mason
              [email protected]
              Skype is dave.mason46

              Comment


                #37
                Re: Loosing Global Variables

                Originally posted by martinwcole View Post
                dave,
                if you say dim global xxx as c="xxx"
                and it was already declared previously as global, it won't work
                but if you say dim global xxx as c; xxx="xxx", it will work, and persist. It has always been this way, as far as I know.
                Always been that way? and where did you discover that? Usually if I dim a global var in a script it's because the calling script has set the value already. Now I'll have to check if I do the dim and = thing as part of the dim statement.

                Man, just what I needed - something else to worry about....

                Btw, its not loosing, its losing
                Robin

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

                Comment


                  #38
                  Re: Loosing Global Variables

                  way back when - maybe ver 5, don't remember
                  the documentation said that they had added a new feature
                  that you could say dim global varname as c="somevalue" (giving it an initial value)
                  BUT
                  once you say that, you cannot use the same syntax a second time somewhere else

                  for example:
                  in the autoexec script you say
                  dim global varname as c="xxx" (you have dimmed it and given it an initial value)

                  now, in a later script you say
                  dim global varname as c="yyy"
                  it will not override and persist

                  BUT
                  if you say dim global varname as c
                  varname="yyy"
                  it will override and persist

                  NOTE: you DO NOT NEED to dim it again once it is initially dimmed - it's value will not change, and it will not go away.
                  to change it's value, you DO NOT need to dim it again (unless you are using option strict, requiring all variables to be dimmed in all scripts) - just say varname="yyy"
                  because iti was initially dimmed as global it will remain in memory until you close the app.
                  Last edited by martinwcole; 04-24-2015, 08:16 AM.
                  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


                    #39
                    Re: Loosing Global Variables

                    Agreed 100% Martin, with the slight variation that I always try to include dim statements in other scripts to establish the variable being referenced. Generally I dim and set the initial variable value in a form's Define New Variables dialog. Then the scripts of any buttons on the form include a simple dim <scope> varname as C (or other type).

                    As you say, probably not necessary but when editing such a button script at a later time I can at least see the scope of the variables referenced and that they were initialized somewhere earlier.
                    There can be only one.

                    Comment


                      #40
                      Re: Loosing Global Variables

                      Ok, I think I've got it.

                      dim scope var as c = "xxx"

                      can be used to initially create the var but once created, shouldn't be used that way again.

                      Instead the 'old' way is how to dim an existing var and populate it:

                      dim scope var as c
                      var = 'xxx'

                      This is where having a book to review these basics is better than the online wiki search, IMO. I have reviewed variable scoping, and never ran across this one before.
                      Robin

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

                      Comment


                        #41
                        Re: Loosing Global Variables

                        Stan,
                        I frequently redim the global variables, too, as it makes them available in the auto populate thingy when writing the script

                        Mo,
                        Lots of stuff is in the release notes, but/and never gets to the documentation
                        I think the original reason for the "initial" declaration process was for use in functions

                        if you say dim global xxx as c
                        and then xxx="xxx"

                        you will never go wrong and never have a problem with global variables
                        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


                          #42
                          Re: Loosing Global Variables

                          Hi Martin,
                          Problem is I am easily impressed with the scripting of others here and have used the 'new' method quite often without apparently understanding what I was doing! And some of my scripts have had some trouble gathering the info I expected to retrieve - at least now I have a clue as to why that might be.

                          probably a good time to pull out the Aims App Analyzer and review my udf's...
                          Robin

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

                          Comment


                            #43
                            Re: Loosing Global Variables

                            exerpts from an autoexec

                            dim global compadd as c
                            dim global compadd2 as c

                            var->compadd = tbl.addr1
                            var->compadd2 = tbl.addr2

                            as opposed to

                            dim global compadd as c = tbl.addr1
                            dim global compadd2 as c = tbl.addr2

                            When you do this in a form, you have to give a value of some kind because the type is determined by that value. Earlier versions were not quite the same.
                            It could be suggested that form declared variables be set in xbasic using the oninit of that form as I am going to do in the future.
                            Dave Mason
                            [email protected]
                            Skype is dave.mason46

                            Comment


                              #44
                              Re: Loosing Global Variables

                              When you do this in a form, you have to give a value of some kind because the type is determined by that value.
                              When you do it in the oninit or any other script the dim statement assigns a value. Just personal preference.

                              dim global compadd as c
                              ? compadd
                              = ""

                              dim global nompadd as N
                              ?nompadd
                              = 0

                              dim global lompadd as L
                              ? lompadd
                              = .F.

                              dim global dompadd as D
                              ? dompadd
                              = { / / }
                              There can be only one.

                              Comment


                                #45
                                Re: Loosing Global Variables

                                Originally posted by DaveM View Post
                                Trying to dim a variable as global when it already was did NOT work.
                                What do you mean, "did not work"? What messge do you get?
                                Originally posted by DaveM View Post
                                If I created it again
                                I thought it "didn't work" !

                                Comment

                                Working...
                                X