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

Display date() as a global variable

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

    Display date() as a global variable

    Some months ago I launched an inventory runtime application to my first customer. A standalone desktop app. A5 V8. It all functioned as planned, including a global date variable acting as a date stamp for new records ( new or changed) in various tables. The variable is visible in the main menu when the application starts. It is a fixed date: 01.01.2007. As the user creates new records, she can alter that date to any date, and the global date variable stamps new records with the new value until she changes it again.
    But now she wants that fixed date prefered to show today's date initially on the main menu. Simple I thought, but I am stuck. The autoexec script maybe, but the variable does not show up on the main menu initially, and if I define the variable in design mode for the menu form, it only takes a fixed date value.

    #2
    Re: Display date() as a global variable

    how about an xdialog fired on start up or main menu initiation?

    Code:
    DIM global vgdStamp as D
    vgdStamp = date()
    
    dbxR = ui_dlg_box("DATE SET",<<%dlg%
    {lf=.5};
    {region}
    {lf};
    {justify=center,center}[.20vgdStamp];
    {endregion};
    {line=1,1}
    {region}
    {lf};
    {justify=center,center}
    <*10OK!OK> <10Cancel!Cancel> 
    {endregion}
    %dlg%)
    
    	SELECT
    		CASE dbxR = "OK"
    			msgbox(dtoc(vgdStamp))
    		CASE dbxR = "Cancel"
    			end			
    	END SELECT
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

    Comment


      #3
      Re: Display date() as a global variable

      Put a calc field in the main menu:
      today_date=date()

      Comment


        #4
        Re: Display date() as a global variable

        Mike, thank you, for that dialog box idea. It worked! Actually you made me realize a very simple solution:
        First; design mode for the startup application menu: Define New Variables, Global Variables:
        Bdato = { . . }
        Second, regarding Event for that menu form, I now have two:
        OnInit: Bdato = date()
        OnActivate: Refresh Objects (action)
        That�s all I need.
        You see, I have a Type-In Field on that menu form containing that global variable Bdato and it needs to be refreshed when the user returns from a table and back to the menu.
        But I need to investigate why that autoexec script did not pass the date() value initially. I added two actions to the script, DIM variables and �set a variable to a constant�. No luck, so I need to find some debug function in order to see the actual value of the variable.
        Gabriel, I take that Calc Field idea as well, showing today�s date on the menu.
        Thanks for involving in my learning progress :)

        Comment


          #5
          Re: Display date() as a global variable

          Why won't it work from the autoexec? It's done all the time unless I missed something in the request.

          DIM GLOBAL vgdStamp as D
          vgdStamp = date()

          Once that is defined in the autoexec - which runs before any forms are opened - any future references to it will show today's date until someone changes it to something else.

          In the main menu, define the variable as global and leave it blank - or set it to anything you want. That particular value will only be set IF the variable hasn't already been set. Once the variable has been set (i.e., 'exists'), the definition in the layout will not override it.

          Comment


            #6
            Re: Display date() as a global variable

            And why in the autoexec? why not in the OnInit or OnActivate event of the main menu?

            Comment


              #7
              Re: Display date() as a global variable

              Hans if you are using a global variable then be sure to dim it as global everywhere you want to use else your script may be referencing a variable of a different scope.
              Robin

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

              Comment


                #8
                Re: Display date() as a global variable

                Originally posted by G Gabriel View Post
                And why in the autoexec? why not in the OnInit or OnActivate event of the main menu?
                No special reason. I was just addressing the concern stated in the last sentence of the original post about putting it in the autoexec. Personally, I prefer the autoexec only because, in my opinion, it's a bit more "obvious" if I'm looking for it a year later or if for some reason I decide to use a different form for startup. (Changing to a different form is certainly unusual but it has happened.)

                If Hans actually tried to set a global variable in the autoexec then display it on the main menu and it didn't work, he must have done something wrong. Defining global variables in the autoexec and displaying them on the main menu is something I've done, and seen done by others, on a regular basis. I consider it standard practice and take it for granted that the process will work. Perhaps he forgot to define it as a global variable and/or to run the autoexec first in order to initialize the variable before placing it on the main menu. (Yes, there are also other ways to initialize the variable. The point is that it must be initialized before it will show up on the form.)

                Although it isn't necessary, I often define the variable in the form also. Doing that for normal use of the app has no value because the variable should have already been defined before the menu was opened. However, there are sometimes situations during development where I've bypassed the autoexec and then opening the form generates errors. Others have expressed the opposite opinion - NOT defining it in the form will cause an error for the user in case something was wrong. (But I never make mistakes so I don't worry about that.)

                Comment


                  #9
                  Re: Display date() as a global variable

                  Originally posted by CALocklin View Post

                  If Hans actually tried to set a global variable in the autoexec then display it on the main menu and it didn't work, he must have done something wrong.
                  Yes, I did something wrong, because I trusted the Alpha Genie (Action Scripting).
                  Action called �DIM variables� does not have an option for GLOBAL variables, it has to be declared in the Variable name field together with the name itself. Now the autoexec script works as intended:

                  'DIM variables
                  DIM Global Bdato AS D
                  'Set the value of one or more variables.
                  Bdato = date()

                  Comment


                    #10
                    Re: Display date() as a global variable

                    Originally posted by MoGrace View Post
                    be sure to dim it as global everywhere you want to use else your script may be referencing a variable of a different scope.
                    Is this really necessary or is it just in case?

                    When I declare the Global variable in the autoexec script, isn�t that valid for that Database all through the session?

                    The way I keep control of the global variable is in the field rules of the tables. The datefield that is �stamped� has a default value = VAR->Bdato. If the user changes the date for a certain record, then the global variable get that new value from the Events tab sheet of the Field rules definition. Creating a browse window based on the same table does not need a new �DIM Global Bdato AS D� (design mode of browse table).

                    Comment


                      #11
                      Re: Display date() as a global variable

                      For me I guess it is just in case. You are right in that if its inital scope is global then you ought to be able to call it without dimming it again. I have been working at changing my global variables to shared so I can use them with more versatility. For shared you definitely need to dim them each time.
                      Robin

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

                      Comment

                      Working...
                      X