URL Handler (In-Process CGI routine) that modifies the values of specified global (Public) variables in loaded GPL projects and optionally returns a web page.
/wrtgpl
Prerequisites
None
Parameters
None
URL Query String Parameters
GPLProj
A required string that specifies the name of the GPL project that contains the global variables to be modified and defines the context in which the assigned values are evaluated. If the project name is not specified (""), all projects loaded into memory are searched to locate the specified global variables. Note, searching for the variables does consume processor execution time.
nGVar
A required numeric integer value that specifies the number of global variables to be modified.
GVar1 to GVarn
nGVar required global variable specifications sequentially named GVar1, GVar2, ... Each specification can be an explicit name of a numeric or string global variable or array element or an expression. If an expression is utilized to specify a variable, it is evaluated in the context of GPLProj. For example, an array element can be specified as "a(index+1)" where "index" is a global variable and "a" is a global array.
GVal1 to GValn
nGVar required expressions sequentially named GVal1, GVal2, ... GVal1 defines the new value to be set for GVar1. GVal2 corresponds to GVar2, etc. Each GVal_ can be a general expression that consists of constants, system functions and methods, and global variables. Expressions are evaluated in the context of GPLProj.
Redirect
A required string value that specifies the URL for the web page to be returned after all of the values have been modified. If no web page is to be returned, this value should be "".
Remarks
This URL handler (In-Process CGI routine) provides a general means for changing the values of global (Public) variables defined within loaded GPL projects. When this special URL address is received by the web server, rather than fetching a standard disk file, it sets the GVar_ global variables to their new values specified by the GVal_ values. After all of the values have been updated, a new web page defined by Redirect is return if specified.
The GVar_ and GVal_ values are processed sequentially based upon their sequence number (from 1 to nGVar) rather than based upon their order of appearance in the URL Query String. Symbolically, the following process is performed:
For ii = 1 To nGVar
GVarii = GValii
Next iiThis permits the GVar_ and GVal_ values to be displayed on the web page in any desired sequence while still maintaining a strict order in which the values are updated.
In a non-embedded web server, the /wrtgpl operation would be performed by an independent task that was implemented using CGI (Common Gateway Interface) technology. In the controller's embedded web server, this task is performed by a special function built into the web server to minimize system overhead.
Examples
The following is a simple GPL project that defines a global (Public) variable "aa" and outputs a message whenever its value is changed. When used with the HTML code below, this illustrates how a web page can read and write global variables. Copy and save this project as "Aspgpl_test".
Module GPL
Public aa As Double ' Define global accessed by web page
Public Sub MAIN
Dim aa_copy As Double
aa = 3.14159 ' Any initial value
aa_copy = aa
While (True) ' Loop testing for new value
If (aa <> aa_copy) Then
Console.WriteLine("aa changed: " & CStr(aa))
aa_copy = aa
End If
Thread.Sleep (500)
End While
End Sub
End ModuleThe following is a minimal ASP file that displays the value of the global "aa" variable in the Aspgpl_test project and permits the value to be changed. Save this sequence in a controller flash file name /flash/appweb/test_aspgpl.asp.
<html>
<body>
<p><form action="/wrtgpl" method="post">
<input name='GPLProj' type='hidden' value='Aspgpl_test'>
<input name='nGVar' type='hidden' value='1'>
<input name='GVar1' type='hidden' value='aa'>
GPL global variable aa:
<input name='GVal1' type='text'
value='<% aspGPL("Aspgpl_test","aa",0); %>' size='20'>
<br><br>
<input name='Redirect' type='hidden' value='/flash/appweb/test_aspgpl.asp'>
<input type="submit" value="Set aa to new value">
</form></p>
</body>
</html>Load and execute the Aspgpl_test project and display the test_aspgpl.asp page by specifying its address in a browser. Edit the value of aa and press the button to modify its value in the GPL project.
See Also