On Thu, 22 Mar 2001 09:42:04 -0500,
"Carl Petersen" <[EMAIL PROTECTED]> wrote: 
 
>When combining VBscript, Jscript, and Python in a windows scripting file
>(.wsf) the python script sections ignore the globals declared in other
>script sections. Is there a way around this behavior?
> 
>Example test.wsf
><job>
><script language="VBScript">
>Public variable
></script>
><script language="Python">
>print "variable = ",variable            (when executed variable is
>undefined)
></script>
></job>
> 
>Also is there anyway around pythons inability to interface with com
objects
>whose methods pass parameters by reference? VBScript defaults to pass by
ref
>so it works and I would like create a wrapper in vbscript which could be
>called from python. This does not seem to work because of the above
global
>scope issue.

Hi Carl,

Mark Hammond discussed the WSH problem on this mailing list
last year (29 Nov 2000). So, if the mailing list archives are working,
you might want to read his message. Basically, references to global
variables and procedures in other script blocks have to be prefixed
with "globals." as I have in the following version of test.wsf.

<job>
    <script language="VBScript">
Public variable
variable = "Testing..."
    </script>
    <script language="JScript">
function echo(string) {
    WScript.Echo(string);
}
    </script>
    <script language="Python">
globals.echo("variable = " + globals.variable)
    </script>
</job>

Note that I used "WScript.Echo" instead of "print". This ensures
that output will be generated whether you run your script from
the GUI (WScript.exe)  or the command line (CScript.exe).

HTH,
Jonathan D Johnston
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython

Reply via email to