Server side Javascript procedure that inserts the value of a global (Public) GPL project variable or expression into an ASP file at the place in the file where the procedure is invoked.
<% aspGPL(GPL_project, GPL_expression, o_format); %>
Prerequisites
Must be contained within a file with a .ASP (Active Server Page) extension.
Parameters
GPL_project
A required string that specifies the name of the GPL project that defines the context for the expression evaluation or that contains the global variable. If the project name is not specified (""), all projects loaded into memory are tested until the expression is successfully evaluated. Note, evaluating the expression in the context of multiple projects does consume processor execution time.
GPL_expression
A required string that contains a GPL expression or global variable name whose value is evaluated and returned. This expression can contain constants, system functions and methods and global variables. Global variables can be numbers, strings, scalars or arrays with expressions as the array indices.
o_format
A required numeric value that specifies special output formatting for numeric values. This value is interpreted as follows:
o_format Description <0
The number is truncated to -o_format fractional digits
0
No special formatting. Should always be specified for strings.
1
Output "Yes" or "No" based upon numeric value
2
Output "On" or "Off" based upon numeric value
3
Output as 8 hexadecimal characters with leading "0"'s
URL Query String Parameters
None
Remarks
This procedure permits web pages to directly access global data in loaded GPL projects. When this Javascript procedure is encountered in an ASP file, the web server evaluates the GPL_expression in the global context of the GPL_project and inserts the resulting value into the ASP file at the point where the procedure was encountered in place of the procedure call. By substituting the computed value, this procedure dynamically alters the contents of a web page.
An unlimited number of these procedure calls can be contained in an ASP file although each call does consume a modest amount of CPU time.
The expression can return a numeric or string value.
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