Extends as Help

Tonight I thought I’d try my hand at Extends … as to solve a number of problems with one stone. I want to extend SpecialFolder so that I can use SpecialFolder.Resources which is easier to write, and neatens my code; and I wanted to share it as a module that has all of the options noted in <https://xojo.com/issue/6306> since it doesn’t look like this will be implemented in Xojo anytime soon.

So hum-de-dum I’m trudging along using the docs and AnimationKit as an example, and I think what I’ve got should work. But the IDE says “This item does not exist” Which stumps me, because it code-suggested it. I’ve been flipping back and forth between docs.xojo, AnimationKit, and my project; and I just can’t figure it out.

Can anyone take a look and help me figure out what’s wrong?
SpecialFolders.xojo_binary_project.zip (5kb)

It looks like it would need to be a Shared Method, as SpecialFolder (and FolderItem) are classes, not instances. And I don’t see any way of making an “extends” routine a shared method, so I think you might be out of luck. Maybe someone can prove me wrong?

I think you’d either need to write your own class (call it TPSpecialFolder or whatever) and have a shared Resource method on that. Or, just have a ResourceFolderItem method that would return it directly.

Right, Extends needs to be fed an instance of a class and SpecialFolder is probably a module, not a class at all.

Did you think about extending the Application object? Seems resources, frameworks, etc are all relative to the executable, and there’s always an app instance.
app.Resources
app.Frameworks
etc…

I spent the afternoon extending the Application object, and it worked well in the project I used to separate the module from my current in-development project. But once I imported into my in-dev project it failed to work. I’m assuming it has something to do with the main App having methods already.

Since I got it to work, I’ve at least succeeded in understanding Extend; but I’ve given up on using it as a way to make these special folder locations feel native to Xojo.

Thank you all for your help!

I did finish the Module, but you have to use it as TPSpecialFolders.[folder]; it does however clear up #target pragmas, and supports some nifty Libs folder tracking for Windows. It defaults to how Xojo names the Libs folder for Windows, but if you rename it to just “Libs” the module will return your renamed Libs folder.

I may give it a proper release with a more permanent url, but at the moment it’s not my high concern.

For those interested in the module: http://timi.me/.misc/TPSpecialFolders.xojo_binary_code