Jump to content
Sign in to follow this  
steve8tch

File Handles - local scope

Recommended Posts

steve8tch

If a handle is declared locally - should it be destroyed when that particular fuction call ends.

I have posted code here to illustrate the issue.

;open handles - local scope
$counter = 0
ProgressOn("OpenHandleInLocalScope test","Number of handles open  ", $counter, -1,-1,16)
While 1
    $counter += 1
    ProgressSet(0,$counter)
    OpenHandleInLocalScope()
    sleep(50)
WEnd

Func OpenHandleInLocalScope()
    local $h_x = FileOpen("C:\OpenHandleInLocalScope.txt",1)
EndFunc

At present the handle does NOT get destroyed on function exit, but should it?

Share this post


Link to post
Share on other sites
Valik

It would be a lot of work because it would require making a new "type" inside the Variant. Also, AutoIt isn't an object-oriented language so I'm not so sure how an RAII concept would fit.

Share this post


Link to post
Share on other sites
jpm

It would be a lot of work because it would require making a new "type" inside the Variant. Also, AutoIt isn't an object-oriented language so I'm not so sure how an RAII concept would fit.

Just curiosity what is RAII?

Share this post


Link to post
Share on other sites
Richard Robertson

That does seem complicated. I'm still working on figuring out how to manage variables for global and local calls. Declaring and referencing variables by string name is quite complicated to figure out for one's self.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.