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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript compilation error

Status
Not open for further replies.

Joelo

MIS
Sep 27, 2003
61
I am run Win2000 server
Please could anyone tell me what I am doing wrong....I keep getting the following error message:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/maintenance/compliance/class_3D.asp, line 36

Public Default Function item ( k1,k2,k3)
-------------^


This is Code here:
<%
Class clsD3Dictionary
Private D3Dict
Private DebugFlag

' Initialize class
Private Sub Class_Initialize()
Set D3Dict = CreateObject(&quot;Scripting.Dictionary&quot;)
End Sub

' Add the key value &quot;key&quot; to given dictionary
Private Function addIndex(key,dict)
If Not dict.Exists(key) Then
dict.Add key, dict.Count
End if
End Function

Private Function getIndex(key,dict)
If Not dict.Exists(key) Then
dict.Add key, dict.Count
End If
getIndex = dict(key)
End Function

' Add to dictionary
Public Function Add( k1,k2,k3,v)
Dim i1,i2,i3,k
k = k1 & Chr(03) & k2 & Chr(03) & k3
If D3Dict.Exists(k) Then
D3Dict(k)= v
Else
D3Dict.Add k,v
End If
End Function

Public Default Function item ( k1,k2,k3)
Dim i1,i2,i3,k,v
k = k1 & Chr(03) & k2 & Chr(03) & k3
If D3Dict.Exists(k) Then
v=D3Dict(k)
Else
v=&quot;&quot;
End If
Item = v
End Function


' Check if the key exists
Public Function Exists( k1,k2,k3)
Dim i1,i2,i3,k,v
k = k1 & Chr(03) & k2 & Chr(03) & k3
Exists = D3Dict.Exists(k)
End Function

' data inferred with key and key number
Public Function Keys(k1,n)
Dim v,ky
keys = D3Dict.Keys
For Each key In Keys
v = Null
ky = split(key,chr(03))
If isArray(ky) Then
If n = 1 Then
v = ky(0)
ElseIf ky(0) = k1 Then
if n = 2 And Ubound(ky) >= 2 Then
v = ky(1)
Else
If n = 3 And Ubound(ky) >= 2 Then
v = ky(2)
End If
End If
End If
End If
If Not IsNull(v) And Instr(1,kx & Chr(03), v & Chr(03),1) <= 0 Then
If kx <> &quot;&quot; Then kx = kx & Chr(03)
kx = kx & v
End If
Next
Keys = Split(kx, Chr(03))
End Function

End Class
%>

 
Hello Joelo,

Just a quick note before I call my day.
[1] Make sure vbscript version 5 up. (I don't think you have lower, but just to make sure.)
[2] With your ISM, make sure you uncheck &quot;Enable ASP server-side debugging&quot;.

regards - tsuji

PS Your Add has no return value, may be make it a sub?
 
Thanx for response
I am still getting the same Error Message

 
For info, I've pasted your code in a .VBS file, added a WScript.Echo. No error on execution.
Seems to be an ASP or IIS problem ?
Just my 2 cents.

Hope This Help
PH.
 
Joelo,

Hope you did the point [2] as said.

Further note:
[3] Implement as well the class_terminate()
Code:
     Private Sub Class_Terminate()
          Set D3Dict = Nothing
     End Sub
During your testing, you might create a lot of orphan classes in the memory (memory leak), that might pose a problem.

- tsuji
 
Forget to mention
[4] In your function keys(...), the variable kx comes out of nowhere. Hope it is what you want.

- tsuji
 
I still can't get it to work, I keep getting same error message

Please Somebody..!!.......anybody...!!! help me out

Thanx
 
Hello.
Look at line: k = k1 & Chr(03) & k2 & Chr(03) & k3
Try first without k3.
I would suggest that you make sure that the variable k3 is not containing any rubbish. Can you check ?
Regards Jon.

 
Still....did not work

My Problem is

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/maintenance/compliance/class_3D.asp, line 36

Public Default Function item ( k1,k2,k3)
---------------^

line is

Public Default Function item ( k1,k2,k3)

I have tried all I know.....I don't know what to do
 
not that it helps you but i had similar problems with classes in vbscript and found that the error statements of the type you describe actually lied about the location of the error, ie line 36
 
Is There any other way to rewrite the following lines?:
Because that's where I am having problem with... Running it on win2000 server

Public Default Function item ( k1,k2,k3)
Dim i1,i2,i3,k,v
k = k1 & Chr(03) & k2 & Chr(03) & k3
If D3Dict.Exists(k) Then
v=D3Dict(k)
Else
v=&quot;&quot;
End If
Item = v
End Function
 
Hello again.
I haven't found the error but I would make a suggestion.
Use statement Option Explicit as the first statement in your code and work it out from there.
Is this all the code running as server asp?
Regards Jon.

 
I do have some othe codes too and they work fine except for this ....with error
 
Have you removed the space between &quot;item ( k1,k2,k3)&quot;? Your other functions don't have a space before the &quot;()&quot;.

My books don't mention &quot;Default&quot; as a keyword with functions. Of course, I haven't used functions much, so maybe it is okay.
 
I am running IIS and don't really know which release of Vbscript is on it.

Which release of Vbscript do U suggest ?

 
Joelo,

... So you had not verified what I proposed up there, [1] and [2] afterall !!!

Make a simple vbs with the line
Code:
wscript.echo ScriptEngineMajorVersion & &quot;.&quot; & ScriptEngineMinorVersion
and run it on the server. What does it show?

- tsuji
 
I run the simple vbs :

wscript.echo ScriptEngineMajorVersion & &quot;.&quot; & ScriptEngineMinorVersion

and it displayed : 5.6

I pasted my script in a .vbs and ran it....:
it displayed the following error:

Line: 2
Char: 1
Error: Expected statement
code: 800A0400
Source: Microsoft Vbscript Compilation Error


Please is there any suggestions....help me
 
Cannot be serious by putting <% %> in a vbs hosted by wsh?

I suggest you review your own class again. It is terribly written, if I may say so. Make up a testing asp or get rid of <% %> in order to put into a .vbs for testing.

As PHV advised you up there, the class itself as such is passing no problem in the compilation stage. I have made some test on the functionality, it performs somehow.

Post your testing asp. You got good advice all along, but we can guess what you have behind the screen.

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top