Jump to content

Recommended Posts

Posted

Hello,

I'm using an object in different functions.

The object is created with:

$objVideo = ObjCreate("wmplayer.ocx")

Now I want to use this object in another function and tried:

$objVideo = ObjGet("wmplayer.ocx")

But this is not working.

How can I use the same object in different function without giving the object variable as parameter in function name such as:

Func NextFunction($objVideo)

Thanks for assistance.

Cheers mike

Posted
2 hours ago, Danp2 said:

I think you've got the syntax wrong. Try this --

$objVideo = ObjGet("", "wmplayer.ocx")

 

Thanks Danp2.

This would have been my prefered solution, but unfortunately it does not work.

Cheers mike

Posted
1 hour ago, KaFu said:

Define $objVideo as Global at the beginning of your script.

Global $objVideo = ObjCreate("wmplayer.ocx")
; Outside of functions

Thanks Kafu,

this works.

Although I do not like very much to work with Global variables, cause my functions are in libraries.

Cheers mike

Posted

If it's an "include" library you can also define the Global variable at the top of the include file itself.

GDIPlus.au3 does something similar with $__g_hGDIPDll.

Aalso you could test the variable with isobj() at the beginning of the single functions, and throw an error when false.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...