Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global.asa jscript and vbscript together ?

Status
Not open for further replies.

Webflex

Technical User
Apr 20, 2001
101
0
0
GB
I have a Global.asa that contains this....

Code:
<SCRIPT LANGUAGE=&quot;JScript&quot; RUNAT=Server> 

function Session_OnStart()
{
	Session(&quot;AppAnnuaireDatabase&quot;) = &quot;/Application/asp/Annuaire/annuaire.mdb&quot;;
	Session(&quot;AppAnnuairePermission&quot;) = &quot;/Application/asp/Annuaire/ManageAnnuaire.asp&quot;;
	Session(&quot;AppFichesDatabase&quot;) = &quot;/Application/asp/fiches/remarques.mdb&quot;;
	Session(&quot;AppFichesPermission&quot;) = &quot;/Application/asp/fiches/ManageFiche.asp&quot;;
	Session(&quot;AppProjectDatabase&quot;) = &quot;/Application/asp/Project/Project.mdb&quot;;
	Session(&quot;AppProjectPermission&quot;) = &quot;/Application/asp/Project/ManageProject.asp&quot;;
	Session(&quot;AppVendorsDatabase&quot;) = &quot;/Application/asp/vendors/avl.mdb&quot;;
	Session(&quot;AppTerminologyDatabase&quot;) = &quot;/Application/asp/terminology/Terminology.mdb&quot;;
	Session(&quot;AppNNTPStatDatabase&quot;) = &quot;/Application/asp/MCR/MCR.mdb&quot;;
}
</SCRIPT>

Which works fine

I can also use a Global.asa with this...

Code:
<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>

Sub Application_OnStart
	' Set our user count to 0 when we start the server
	Application(&quot;ActiveUsers&quot;) = 0
End Sub

Sub Session_OnStart
	' Change Session Timeout to 20 minutes (if you need to)
	Session.Timeout = 20
	' Set a Session Start Time
	' This is only important to assure we start a session
	Session(&quot;Start&quot;) = Now
	' Increase the active visitors count when we start the session
	Application.Lock
		Application(&quot;ActiveUsers&quot;) = Application(&quot;ActiveUsers&quot;) + 1
	Application.UnLock
End Sub

Sub Session_OnEnd
	' Decrease the active visitors count when the session ends.
	Application.Lock
		Application(&quot;ActiveUsers&quot;) = Application(&quot;ActiveUsers&quot;) - 1
	Application.UnLock
End Sub

</SCRIPT>

for an active user counter. However if I put both in the same global.asa I get problems.

Is there a way to combine the jscript and vbscript so they will both run ?

Any help appreciated.

TIA
 
Your problem is in the VB part of code because u override the Session_OnStart function witch is declared in Java part
U have to declare only once a function not twice (In VB and Java), u decide witch function reside in Java and witch reside in VB.
Hope this solve your problem...

 
Thanks, I'm quite new to this, I understand what you say about the Session_OnStart being declared in both the jscript and the vbscript but I'm not sure how to get around this, can I sustitute Session_OnStart with something else that will have the desired outcome ?

TIA
 
Yes u have. U must put in other sub your vb code and then call it from java


<SCRIPT LANGUAGE=&quot;JScript&quot; RUNAT=Server>

function Session_OnStart()
{
Session(&quot;AppAnnuaireDatabase&quot;) = &quot;/Application/asp/Annuaire/annuaire.mdb&quot;;
Session(&quot;AppAnnuairePermission&quot;) = &quot;/Application/asp/Annuaire/ManageAnnuaire.asp&quot;;
Session(&quot;AppFichesDatabase&quot;) = &quot;/Application/asp/fiches/remarques.mdb&quot;;
Session(&quot;AppFichesPermission&quot;) = &quot;/Application/asp/fiches/ManageFiche.asp&quot;;
Session(&quot;AppProjectDatabase&quot;) = &quot;/Application/asp/Project/Project.mdb&quot;;
Session(&quot;AppProjectPermission&quot;) = &quot;/Application/asp/Project/ManageProject.asp&quot;;
Session(&quot;AppVendorsDatabase&quot;) = &quot;/Application/asp/vendors/avl.mdb&quot;;
Session(&quot;AppTerminologyDatabase&quot;) = &quot;/Application/asp/terminology/Terminology.mdb&quot;;
Session(&quot;AppNNTPStatDatabase&quot;) = &quot;/Application/asp/MCR/MCR.mdb&quot;;

MyVbInitialization();
}
</SCRIPT>

<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>

Sub Application_OnStart
' Set our user count to 0 when we start the server
Application(&quot;ActiveUsers&quot;) = 0
End Sub

Sub MyVbInitialization
' Change Session Timeout to 20 minutes (if you need to)
Session.Timeout = 20
' Set a Session Start Time
' This is only important to assure we start a session
Session(&quot;Start&quot;) = Now
' Increase the active visitors count when we start the session
Application.Lock
Application(&quot;ActiveUsers&quot;) = Application(&quot;ActiveUsers&quot;) + 1
Application.UnLock
End Sub

Sub Session_OnEnd
' Decrease the active visitors count when the session ends.
Application.Lock
Application(&quot;ActiveUsers&quot;) = Application(&quot;ActiveUsers&quot;) - 1
Application.UnLock
End Sub

</SCRIPT>


Hope this works
 
Excellent, many thanks it works a treat.
 
I am a relative newbie, so forgive any obvious errors.

If it is possible I am looking for a way to call a vbscript function from jscript.

I have a number of .asp forms (written using FP2K, running on an IIS 5.0 W2K managed site where scripting is enabled).

Each form has a confirmation number that is unique to the form, retained on-site within a text-file counter.

To update a form's confirmation number I have been using the following vbscript ahead of the HTML:

Code:
<%
Response.Buffer = true 
Response.Expires = 0
response.addheader &quot;Pragma&quot;, &quot;No-Cache&quot;
dim strName, strCNumber, strFullPath
strFullPath = &quot;D:/ { IP address } / { file-path } &quot;
const ForReading = 1, TristateUseDefault = -2
Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
set objFile = objFSO.GetFile(strFullPath)
set objFTS = objFile.OpenAsTextStream(ForReading, TristateUseDefault)
	strFTS = objFTS.ReadLine
	strFTS2 = strFTS +1
objFTS.close
Set a = objFSO.CreateTextFile(strFullPath, True)
a.WriteLine(strFTS2)
a.Close
%>
<HTML etc ....>

... and later I use this value in a hidden field:
<input type=&quot;hidden&quot; name=&quot;Conf_num&quot; value=&quot;<%= strFTS %>&quot;>

This works OK, but there is a drawback, since the update occurs only when the form is loaded; use of the browser back-arrow plus re-submission leads to a duplicate confirmation number.

I have intercepted the submit button action in order to stall the impatient user; I would like to increment the counter at this point and lock up the counter file until submission is launched.

Is it possible to re-write my vbscript as a function that is callable from Jscript?

Thanks in advance for your help,

JimHH
 
It is possible tu call an vbscript function from javascript

<SCRIPT LANGUAGE=&quot;JScript&quot; RUNAT=Server>
...
MyVbInitialization();
...
</SCRIPT>

<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>
...
Sub MyVbInitialization
' Change Session Timeout to 20 minutes (if you need to)
Session.Timeout = 20
' Set a Session Start Time
' This is only important to assure we start a session
Session(&quot;Start&quot;) = Now
' Increase the active visitors count when we start the session
Application.Lock
Application(&quot;ActiveUsers&quot;) = Application(&quot;ActiveUsers&quot;) + 1
Application.UnLock
End Sub
....
</SCRIPT>




________

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top