Help me merge two global.asa files.

Can you help me merge these two global.asa files:

First one:


Sub Session_OnStart
'Set session variable for virtual-directory test
Session("ChatInitialised")=True
End Sub

Sub Session_OnEnd
Dim vChatName, vChatUsers, vChatMoods, vUserCount
Dim vRoomNo
Dim m, n

vRoomNo = Session("RoomNo")
vChatName = "" & Session("ChatName")
If vChatName <> "" Then
Application.Lock
vUserCount = CLng(Application("UserCount" & vRoomNo))
If vUserCount < 2 Then
vChatUsers = ""
vChatMoods = ""
vUserCount = 0
Else
vChatUsers = Application("ChatUsers" & vRoomNo)
vChatMoods = Application("ChatMoods" & vRoomNo)
For n = 0 To vUserCount - 1
If vChatUsers(n) = vChatName Then
For m = n To vUserCount - 2
vChatUsers(m) = vChatUsers(m+1)
vChatMoods(m) = vChatMoods(m+1)
Next
vUserCount = vUserCount - 1
Redim Preserve vChatUsers(vUserCount)
Redim Preserve vChatMoods(vUserCount)
Exit For
End If
Next
End If
Application("ChatUsers" & vRoomNo) = vChatUsers
Application("ChatMoods" & vRoomNo) = vChatMoods
Application("UserCount" & vRoomNo) = vUserCount
AddLineToChat vRoomNo, "**" & vChatName & " has left (timed out)**"
Session("ChatName") = ""
If vUserCount = 0 Then
Application("ChatLines" & vRoomNo) = ""
Application("ChatLineCount" & vRoomNo) = 0
Application("ChatMaxLines" & vRoomNo) = 0
End If
Application.Unlock
End If

End Sub

Sub AddLineToChat (ByVal vRoomNo, ByVal vNewLine)

Dim vCurrentLine, vChatLines, vMaxLines

vCurrentLine = Application("ChatLineCount" & vRoomNo)
vChatLines = Application("ChatLines" & vRoomNo)
vMaxLines = Application("ChatMaxLines" & vRoomNo)
vCurrentLine = vCurrentLine + 1
If vCurrentLine > vMaxLines Then
vMaxLines = vMaxLines + 500
If vCurrentLine = 1 Then
Redim vChatLines(vMaxLines)
Else
Redim Preserve vChatLines(vMaxLines)
End If
Application("ChatMaxLines" & vRoomNo) = vMaxLines
End If
vChatLines(vCurrentLine - 1) = vNewLine
Application("ChatLines" & vRoomNo) = vChatLines
Application("ChatLineCount" & vRoomNo) = vCurrentLine

End Sub



Second one:



Sub Application_OnStart

'Create an ActiveUsersNumber variable with Application scope and set it to 0
Application("intActiveUserNumber") = 0

End Sub




Sub Session_OnStart

Session.Timeout = 20

Application.Lock

'The Application ActiveUserNumber variable is incremented by 1
Application("intActiveUserNumber") = Application("intActiveUserNumber") + 1

'The application is now unlocked
Application.UnLock

End Sub




Sub Session_OnEnd

Application.Lock

Application("intActiveUserNumber") = Application("intActiveUserNumber") - 1

Application.UnLock

End Sub





Thanks,
David

Comments

  • Can't you just copy paste the second into the appropriate subs ?
    tried that ?

    Faustine
    ---------

    : Can you help me merge these two global.asa files:
    :
    : First one:
    :
    :
    : Sub Session_OnStart
    : 'Set session variable for virtual-directory test
    : Session("ChatInitialised")=True
    : End Sub
    :
    : Sub Session_OnEnd
    : Dim vChatName, vChatUsers, vChatMoods, vUserCount
    : Dim vRoomNo
    : Dim m, n
    :
    : vRoomNo = Session("RoomNo")
    : vChatName = "" & Session("ChatName")
    : If vChatName <> "" Then
    : Application.Lock
    : vUserCount = CLng(Application("UserCount" & vRoomNo))
    : If vUserCount < 2 Then
    : vChatUsers = ""
    : vChatMoods = ""
    : vUserCount = 0
    : Else
    : vChatUsers = Application("ChatUsers" & vRoomNo)
    : vChatMoods = Application("ChatMoods" & vRoomNo)
    : For n = 0 To vUserCount - 1
    : If vChatUsers(n) = vChatName Then
    : For m = n To vUserCount - 2
    : vChatUsers(m) = vChatUsers(m+1)
    : vChatMoods(m) = vChatMoods(m+1)
    : Next
    : vUserCount = vUserCount - 1
    : Redim Preserve vChatUsers(vUserCount)
    : Redim Preserve vChatMoods(vUserCount)
    : Exit For
    : End If
    : Next
    : End If
    : Application("ChatUsers" & vRoomNo) = vChatUsers
    : Application("ChatMoods" & vRoomNo) = vChatMoods
    : Application("UserCount" & vRoomNo) = vUserCount
    : AddLineToChat vRoomNo, "**" & vChatName & " has left (timed out)**"
    : Session("ChatName") = ""
    : If vUserCount = 0 Then
    : Application("ChatLines" & vRoomNo) = ""
    : Application("ChatLineCount" & vRoomNo) = 0
    : Application("ChatMaxLines" & vRoomNo) = 0
    : End If
    : Application.Unlock
    : End If
    :
    : End Sub
    :
    : Sub AddLineToChat (ByVal vRoomNo, ByVal vNewLine)
    :
    : Dim vCurrentLine, vChatLines, vMaxLines
    :
    : vCurrentLine = Application("ChatLineCount" & vRoomNo)
    : vChatLines = Application("ChatLines" & vRoomNo)
    : vMaxLines = Application("ChatMaxLines" & vRoomNo)
    : vCurrentLine = vCurrentLine + 1
    : If vCurrentLine > vMaxLines Then
    : vMaxLines = vMaxLines + 500
    : If vCurrentLine = 1 Then
    : Redim vChatLines(vMaxLines)
    : Else
    : Redim Preserve vChatLines(vMaxLines)
    : End If
    : Application("ChatMaxLines" & vRoomNo) = vMaxLines
    : End If
    : vChatLines(vCurrentLine - 1) = vNewLine
    : Application("ChatLines" & vRoomNo) = vChatLines
    : Application("ChatLineCount" & vRoomNo) = vCurrentLine
    :
    : End Sub
    :
    :
    :
    : Second one:
    :
    :
    :
    : Sub Application_OnStart
    :
    : 'Create an ActiveUsersNumber variable with Application scope and set it to 0
    : Application("intActiveUserNumber") = 0
    :
    : End Sub
    :
    :
    :
    :
    : Sub Session_OnStart
    :
    : Session.Timeout = 20
    :
    : Application.Lock
    :
    : 'The Application ActiveUserNumber variable is incremented by 1
    : Application("intActiveUserNumber") = Application("intActiveUserNumber") + 1
    :
    : 'The application is now unlocked
    : Application.UnLock
    :
    : End Sub
    :
    :
    :
    :
    : Sub Session_OnEnd
    :
    : Application.Lock
    :
    : Application("intActiveUserNumber") = Application("intActiveUserNumber") - 1
    :
    : Application.UnLock
    :
    : End Sub
    :
    :
    :
    :
    :
    : Thanks,
    : David
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion