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

Global Variables??

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

    Global Variables??

    I must be confused about Global Variables. A couple of questions:
    1. I thought a global variable, once defined, should be available in any layout. I only have them available in the layout in which they were created.

    2. Is there any to view all global variables from the control panel?

    Thanks for any clarification.

    #2
    RE: Global Variables??

    Becky....

    Create your global variables from the drop-down toolbar when in the Control Panel with no forms, tables,etc. open.

    Comment


      #3
      RE: Global Variables??

      Becky,

      Yes they are.

      No matter where you declare them they can be viewed elsewhere but *the must be declared in the second place as well*.

      So if you have a script which includes the lines:
      dim global firstname as c
      firstname = "Becky"
      to see this variable in a second script it would also need to include the line
      dim global firstname as c
      in which case the line
      trace.writeln(firstname)
      would write "Becky" to the trace window.

      In a layout, you would declare the variable in the variable definition dropdown which you access from design mode.

      I also declare them in scripts attached to layout events but I cannot swear this is absolutely necessary.

      Bill
      Bill Hanigsberg

      Comment


        #4
        RE: Global Variables??

        Becky, et al,

        I just reworked a PO database, and I was trying to figure out a way to deal with all the global variables. I had two main problems:

        1) I had to declare the variable wherever I wanted to use it (and could not always remember the exact variable name)

        2) I wasn't sure of the best way to keep certain variables up-to-date.

        I solved both problems by declaring the variables in my autoexec script. All global variables are thereby declared independently of any form, browse, report, label, letter, and so on. I also use the autoexec to set variables that need setting.

        E.g., I always want the startdate variable to be the first day of the current fiscal year, and the enddate variable to be the last day of the current fiscal year. In my script, I have them assigned dynamically from the current date. Why not just put in the exact date? Because when we enter a new fiscal year, I would have to update my script.

        Here is how my script looks for just the startdate and enddate variables:

        dim global startdate as d
        dim global enddate as d

        [code]
        startdate = ctod(iif(month(date())
        Stephen Pilon
        Associate Librarian
        Christendom College

        Comment


          #5
          RE: Global Variables??

          sorry, I can't find the drop down toolbar. Could you be more specific, please?

          Comment


            #6
            RE: Global Variables??

            I still don't get it.

            I have 2 global variables (begin_date and end_date)which I defined on a form under the form:variables option on the toolbar. I've assigned default values but I need the user to be able to overwrite them. The fields appear on the form (which is a report menu)and the user accepts or changes the default value. Then when they choose a report to print, each report is filtered (under Report:detail properties) as

            date>=var->begin_date.and.dateend_date

            I want to use the same 2 variables in another form (attached to the same table). This time I want to use the variables as a filter defined on a operation to run from a button on the form. When I design the operation, these variables do not appear as choices in the expression builder. When I type them in, I get error messages. If they are global variables, why aren't they a choice on the "var" column of the expression builder? Thanks for any help.

            Comment


              #7
              RE: Global Variables??

              Becky,

              Try this. Declare the globals 'again' in the second form, just like you did with the first form. Then drop them on your form without using any code that will manipulate the value. Open first form, set the variables. Close form 1.
              Open form 2. The variables you see there should match.

              A less well known approach eliminates the need to declare and re-declare globals.

              1) Right click on your table in the control panel
              2) Select option to Edit Structure
              3) without changing table structure, choose Table
              from the top menu
              4) then choose Global Variables off the dropdown list

              Set your variables there and they're always in scope. I don't think you have re-declare them at form level thereafter, at least not while working with forms that are based on this table. (If I've got this wrong, someone should chime in and fix it. I don't use this approach myself, having gotten used to declaring globals whenever I need them! And yes, I know that sounds crazy... but habits are hard to break sometimes, right?)

              -- tom

              Comment


                #8
                RE: Global Variables??

                Tom-
                I did define the variables in the table's Edit Structure screen. It made me uncomfortable that they STILL don't appear as a choice on the filter expression screens, although it does accept them if I just type them in manually.

                Comment


                  #9
                  RE: Global Variables??

                  Becky, I would defintely NOT define global variables in a table's structure. Also, I would suggest edit the tables structe, and if they are still there, remove them. Use the advice to declare them in the autoexec 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


                    #10
                    RE: Global Variables??

                    Martin, could you tell us why you feel so strongly about this? I seldom define global variables in tables myself (no special reason) but I don't know why it would be an issue and am always ready to learn.

                    Comment


                      #11
                      RE: Global Variables??

                      Hi Martin and everyone,

                      I have had no trouble declaring globals in table structure. Mostly I use the auto exec method but when I want to use a variable in a field rule I find it is much easier if the declaration is in the table since the autoexec may not have run.

                      Bill
                      Bill Hanigsberg

                      Comment


                        #12
                        RE: Global Variables??

                        I think Pilon's example is G R E A T!

                        Why? Because I do it nearly the same way.

                        Declared in an autoexec as

                        dim global start_date as d
                        dm global end_date as d
                        start_date={01/01}'

                        Comment


                          #13
                          RE: Global Variables??

                          Cal - well - now that you mention it - i'm not sure why i felt so strongly, LOL - except that I had an inital reaction of fear of setting global variables in a table's structure - I think maybe I thought they would in some way be "different."

                          so, if its works, I retract my "strong reaction"

                          however - the autoexec is the first thing to fire when an app is opened, and global variables will therefore always be declared first, before the "opening form" opens.

                          So I always put my global variables there - with one exception - say its 3:30AM and I am hard coding away at something and need to name a new global variable, and am too weary to go to the autoexec, LOL, I create it on the fly. Although later I put it in the autoexec.
                          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


                            #14
                            RE: Global Variables??

                            This refers to Bill's earlier note but I didn't put it there because it might get 'buried'. This is also most appropriate for XBasic or In-Line XBasic.

                            Bill stated that, "No matter where you declare them they can be viewed elsewhere but *they must be declared in the second place as well*."

                            I'd like to add "if you are resetting the value."

                            If I simply use the global variable then it does not need to be declared again: (let's assume Start_date is my global variable)
                            End_datec = ui_get_date( "END DATE", "Enter date" )
                            End_date = ctod( End_datec )
                            Elapsed_days = End_date - Start_date
                            ui_msg_box( "DAYS", str( Elapsed_days ) )

                            BUT, if you want to reset the value then it must be declared:
                            DIM GLOBAL Start_date as d
                            Start_datec = ui_get_date( "START DATE", "Enter date" )
                            Start_date = ctod( Start_datec )
                            End_datec = ui_get_date( "END DATE", "Enter date" )
                            End_date = ctod( End_datec )
                            Elapsed_days = End_date - Start_date
                            ui_msg_box( "DAYS", str( Elapsed_days ) )

                            The reason for this is that each XBasic script will assume that any variable that is not specifically dimensioned and is being 'defined' in the script is a local variable. However, if the value isn't set in the local script, then the system goes out and looks for a matching global variable.

                            Having said that, let me also add that I still dimension (re-dimension?) my global variables in each script that uses them. This is basically because I'm lazy - if I do that when I first build the script then (a) I don't have to worry about it if I add a feature at a later date that resets the variable (and by then I may have forgotten that it was global), (b) I can run the script from the control panel without having to run something else to dimension the variable, and (c) sometimes it's helpful to just glance at the top of my script to see what variables are global. (ALL dimensioned variables are ALWAYS at the very beginning of the script - it's not necessary for XBasic but it is in some languages and it's good form. Again, I'm lazy, putting them all at the beginning is easy and it means I never have to worry about where the DIM statement is during editing.)

                            Comment


                              #15
                              RE: Global Variables??

                              Hi Cal,

                              I really appreciate the specificity of your discussion. I must admit that I never went so far as to realize that we have to declare variables to use them one way but not for another. Like you I always declare them because otherwise it's too difficult to keep track.

                              I suppose if you use option strict you just must always declare them. Period.

                              Thanks,
                              Bill
                              Bill Hanigsberg

                              Comment

                              Working...
                              X