Thanks for your reply.
In .wsf files scripts are executed in the order they appear.
<job>
<script language="VBScript">
WScript.Echo "I'm first.."
Public foo
</script>
<script language="JScript">
WScript.Echo("I'm second...");
print("foo = ", foo);
</script
<script language="Python">
print "foo = ",foo
</script>
</job>
The above snippet produces
I'm first...
I'm second...
traceback - undefined "foo"
My problem here is that "variable" exists in the vbscript and jscript
namespace but not in python.
The second part of my question is illustrated here.
# Use these commands in Python code to auto generate .py support
from win32com.client import gencache
gencache.EnsureModule('{095A053B-44E6-11CE-A609-00001D0898C6}', 0, 3, 0)
from win32com.client import Dispatch
sim = Dispatch("simmgr.Application")
sim.ShowWindow(0)
doc = sim.GetDocument
adm = doc.Admin
dataset = 0
# The following will fail with a type mismatch on the dataset variable.
# The GetDataSet method in the adm instance expects the dataset as a
# reference so it can modify the contents.
# Python does a pass by value passing 0 which will fail.
ret = adm.GetDataSet("172.16.145.16",dataset)
print dataset
Is there anyway to convince python to pass by ref?
--Carl Petersen
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Ryan
Sackenheim
Sent: Thursday, March 22, 2001 12:13 PM
To: Carl Petersen
Cc: [EMAIL PROTECTED]
Subject: Re: Scope question when using WHS and COM
I'm not sure about .wsf, but in ASP (which uses windows scripting) only one
interpreter runs at a time, so Python probably runs first before the
VBScript interpreter. This is why it is not generally recommended to mix
languages within one ASP page.
To pass by reference in Python, you assign the variables instead of passing
them as parameters. Also, once your script is written, you have to run the
script "makepy.py -i", and a prompt listing all the COM objects will
appear. You then select the COM you are using, and makepy creates a CLSID
that you use in your script.
For Example:
makepy generates something like this:
{2A1A4BD8-921D-11D3-8889-000629D0EE15}, lcid=0, major=3, minor=0
>>> # Use these commands in Python code to auto generate .py support
>>> from win32com.client import gencache
>>> gencache.EnsureModule('{2A1A4BD8-921D-11D3-8889-000629D0EE15}', 0, 3,
0)
so use this in your script:
from win32com.client import gencache
gencache.EnsureModule('{2A1A4BD8-921D-11D3-8889-000629D0EE15}', 0, 3, 0)
from win32com.client import Dispatch
com = Dispatch("Your.COM")
foo = com.bar()
You only have to call makepy when you need the CLSID, then you can use it
as long as its registered on your machine. I highly recommend "Python
Programming on Win32" from O'Reilly, if you don't already have it. There's
a whole section about this topic.
Good luck,
-Ryan
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython