I'm planning on writting some new code for a legacy ASP application in Python, and I ran into some odd behavior. If I write a function in python I can easily call it from a VBScript block. However, if I try to call a function defined in VBScript from python, I get an error:
Python ActiveX Scripting Engine error '80020009'
Traceback (most recent call last): File "<Script Block >", line 3, in <module> PrintVBS() NameError: name 'PrintVBS' is not defined
/test.asp, line 20
Here is a quick example demonstrating the problem:
<script language="Python" runat="server">
def PrintPython():
Response.Write( "I'm from python<br>" )
</script>
<script language="vbscript" runat="server">
Sub PrintVBS()
Response.Write( "I'm from VBScript<br>" )
End Sub
</script>
<script language="vbscript" runat="server">
PrintVBS()
PrintPython()
</script>
<script language="python" runat="server">
PrintPython() # code is fine up to here,
PrintVBS() # no error if you comment this line
</script>
Does anyone have any insight into this behavior? Any workarounds?
Note, I am aware that I could throw my vbscript code in a WSC file, but I find them a royal pain to work with, and I'd like to avoid that if at all possible.