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

No global variables on the application server?

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

  • No global variables on the application server?

    I have a logical global variable that works when I use it on the application server built into A5 development software but does not work on the stand-alone application server. The logical global variable is set from the view menu -> global variables when editing code on the code tab of the control panel. I tried using the application global variables set in the project properties (the ones with a AppVar prefix) but they are read-only. Is there any way to use a global variable on the application server? I am thinking at this point I will have to use a temporary file as the logic variable, if file present flag is set, if not flag is not set.

    Every night when a scheduled update of many databases from a legacy system is running I want to lock out users from logging on. I created a global variable flag that I set when the update process is running and cleared when it is finished. When users login or tries to do any critical task that pulls data from the databases being updated this flag is checked. The only problem is it does not work now that I have moved it over to the stand-alone app server. It pops up a 500 error, variable not found.

  • #2
    Re: No global variables on the application server?

    How about you put it into the Autoexec and restart the application?
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

    Comment


    • #3
      Re: No global variables on the application server?

      The equivalent of a desktop global variable on the application server would be a session variable. These can be set in the project properties area of the web control panel.
      Glen Schild



      My Blog

      Comment


      • #4
        Re: No global variables on the application server?

        Thanks for the responses.

        Originally posted by Keith Hubert View Post
        How about you put it into the Autoexec and restart the application?
        I just tried defining a global var in the autoexec with the code below but that did not work; it is still not found. Also if I try to define a global variable using the below code it is not accessable globally, only within the scope of the function or a5w page it was declared in.
        Code:
         DIM GLOBAL lGV_DB_CRITIAL_TASK_RUNNING AS L = .F.
        I was looking at the A5_DEFINE_GLOBAL_VARS() function but it can only be used in desktop applications.



        Originally posted by glenschild View Post
        The equivalent of a desktop global variable on the application server would be a session variable. These can be set in the project properties area of the web control panel.
        Session variables do not have a global scope, they are only global to the current logged in user not all users.
        Last edited by LukeS; 06-06-2012, 01:29 PM.

        Comment


        • #5
          Re: No global variables on the application server?

          Hi Luke

          As in my first post

          These can be set in the project properties area of the web control panel
          See attached image
          Glen Schild



          My Blog

          Comment


          • #6
            Re: No global variables on the application server?

            Thanks for the suggestion Glen. I mentioned this in my first post but probably did not go into enough detail. The problem with the application global variables, AppVar variables, is they are read only. The "AppVar." variables can be set locally but changes are not made globally. What they are initialized to in the project properties is what they stay set as.

            From the A5 wiki page on application global variables:
            You can not persistently modify the value of an Application Global Variable in your code. On the next page request, the Application Global Variable will revert to its original value.

            Comment


            • #7
              Re: No global variables on the application server?

              Hi Luke, yep re-read your original post....

              A value set in a small table that is checked at login should achieve this for you. This could be tested via an included header file on each page of the site or at least the "critical" pages.
              Glen Schild



              My Blog

              Comment


              • #8
                Re: No global variables on the application server?

                I ended up using a file as a marker, a field in a table is a really good idea though. If the global var was anything other then a boolean value I would go that route.

                Here's how I did it; I created a global helper function to set and clear the "variable" (file) and a global helper function to check its state
                Function to set the state of the "global variable"
                Code:
                'Date Created: 05-Jun-2012 07:48:53 PM
                'Last Updated: 06-Jun-2012 02:36:15 PM
                'Created By  : Luke
                'Updated By  : Luke
                ' ---== Global Xbasic Helper Function, Set or clear global variable marker for DB critical task running ==---
                '---------------------------------------------------------------------------------------------------------
                ' A5 does not have a method to create global variables on the application server so a temporary file will
                ' be uses as boolean variable (L).  If the temp file is present the var is set, if the file does not exist
                ' then the var is cleared.  This function creates a file to store the state of a boolean \ logical flag. 
                '---------------------------------------------------------------------------------------------------------
                FUNCTION Gh_lSet_DB_Critical_Task AS V (lState AS L )
                	
                	ON ERROR GOTO ERR_HANDLER
                	
                	DIM cTMPmarkerFile	AS C
                	IF variable_exists("AppVar.cGav_Path_DB_CRITICAL_TASK") then
                		'Variable defined in the web project control panel -> project properties -> application global variables
                		cTMPmarkerFile = filename_decode(AppVar.cGav_Path_DB_CRITICAL_TASK)
                	else
                		'Else just dump the file on the c drive
                		cTMPmarkerFile = filename_decode("c:\a5v11\DB_CRITICAL_TASK_RUNNING.txt")
                	end if
                	
                	
                	'If setting state of DB critical task running to true, create file as marker
                	IF lState THEN
                		'If file does not exist, create it
                		IF (.NOT. file.exists(cTMPmarkerFile)) THEN
                			FILE.APPEND_LINE(cTMPmarkerFile, "TRUE")
                		END IF
                	ELSE 'If clearing state of DB critical task running to false, delete temp marker file
                		'If file exist, delete it
                		IF file.exists(cTMPmarkerFile) then
                			file.remove(cTMPmarkerFile)
                		END IF
                	END IF
                	
                	
                	GOTO CONTINUE_1
                	'-----------------------------------
                	' - Error handler
                	'-----------------------------------
                	ERR_HANDLER:
                		ON ERROR GOTO 0
                
                		' ==== Setup Error handling file ====
                		Dim Error_Log_File as C
                		IF variable_exists("AppVar.cGav_Path_GeneralError_log") then
                			'Variable defined in the web project control panel -> project properties -> application global variables
                			Error_Log_File = filename_decode(AppVar.cGav_Path_GeneralError_log)
                		else
                			'Else just dump the file on the d drive
                			Error_Log_File = filename_decode("C:\a5v11\Error_Log.txt")
                		end if
                		' ====
                		
                		File.Append_Line(Error_Log_File, now() + " ---- Error running Gh_lSet_DB_Critical_Task ----" )
                		File.Append_Line(Error_Log_File, "Error text: " + error_text_get() )
                		File.Append_Line(Error_Log_File, "Error code: " + error_code_get() )
                		File.Append_Line(Error_Log_File, "Error script: " + error_script_get() )
                		File.Append_Line(Error_Log_File, "Error line: " + error_line_number_get() )
                		
                		END
                	'-----------------------------------
                	' - END Error handler
                	'-----------------------------------
                	CONTINUE_1:
                
                END FUNCTION
                Function that is used to check the state of the global variable, if returns a logical value so it can be used in a IF statement in place of a actual global variable.
                Code:
                ' ---== Global Xbasic Helper Function, Get state of global variable marker for DB critical task running ==---
                '---------------------------------------------------------------------------------------------------------
                ' A5 does not have a method to create global variables on the application server so a temporary file will
                ' be uses as boolean variable (L).  If the temp file is present the var is set, if the file does not exist
                ' then the var is cleared.  This function checks for the presence of this temporary marker file and returns
                ' true if it is present, false if it is not.
                '---------------------------------------------------------------------------------------------------------
                FUNCTION Gh_isDBCriticalTaskActiv AS L ( )
                	DIM cTMPmarkerFile	AS C
                	IF variable_exists("AppVar.cGav_Path_DB_CRITICAL_TASK") then
                		'Variable defined in the web project control panel -> project properties -> application global variables
                		cTMPmarkerFile = filename_decode(AppVar.cGav_Path_DB_CRITICAL_TASK)
                	else
                		'Else just dump the file on the c drive
                		cTMPmarkerFile = filename_decode("c:\a5v11\DB_CRITICAL_TASK_RUNNING.txt")
                	end if
                	
                	Gh_isDBCriticalTaskActiv = file.exists(cTMPmarkerFile)
                
                END FUNCTION

                Comment

                Working...
                X