Application object restrictions in VBScript

slowlight

New Member
I have to modify a page that is using VBScript.I have a problem to set local variable to Application object in a function. The code below, in the \[code\]getObjectSchema\[/code\] function, generates an error:\[code\]Set LocalSchema = Application("ObjectSchema")\[/code\]While the code below, in the main body (outside of any functions) works absolutely fine:\[code\]Set Schema = Application("ObjectSchema")\[/code\]Does anybody knows what is wrong? Are there any limitations for access to Application objects from a function?Here is the complete code\[code\]<!DOCTYPE html><html><head><title></title><style type="text/css"> .style1 { width: 87px; }</style></head><body> <script type="text/vbscript"> Option Explicit Dim ObjectSchema Dim strXML Dim strXML1 Dim sUserId On Error Resume Next Function GetUserID() GetUserID = "{3450E0D8-EE30-48EE-B63F-486506AD1D97}" End Function Function getObjectSchema() Dim LocalSchema Set LocalSchema = Application("ObjectSchema") If LocalSchema Is Nothing Then Set LocalSchema = CreateObject("Scripting.Dictionary") End if If LocalSchema.Exists(sUserId) Then strXML = LocalSchema.Item(sUserId) Else strXML = "<head><title>Title</title></head><head1><title1>Title1</title1></head1>" LocalSchema.Add sUserId, strXML Set Application("ObjectSchema") = LocalSchema End if getObjectSchema = strXML End Function sUserId = GetUserID() strXML = "" strXML1 = "" strXML = getObjectSchema() strXML1 = getObjectSchema() strXML = getObjectSchema() strXML1 = getObjectSchema() Dim Schema Set Schema = Application("ObjectSchema") If Schema Is Nothing Then Set Schema = CreateObject("Scripting.Dictionary") End if If Schema.Exists(sUserId) Then strXML = LocalSchema.Item(sUserId) Else strXML = "<head><title>Title</title></head><head1><title1>Title1</title1></head1>" Schema.Add sUserId, strXML Set Application("ObjectSchema") = Schema End if strXML1 = strXML </script></body></html>\[/code\]
 
Back
Top