HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Boolexpr in structs [vJass]

12-28-2007, 11:56 AM#1
Silvenon
Hi everyone.

This question is pretty simple, I want to create a boolexpr from a struct method, is that possible? Example:

Collapse JASS:
struct MyStruct
    method MyStructFilter takes nothing returns boolean
        returns true
    endmethod
    static method create takes nothing returns MyStruct
        local MyStruct ms = MyStruct.allocate()
        local boolexpr b = Filter(function ms.MyStructFilter)
        // ...
        return ms
    endmethod
endstruct

Or:

Collapse JASS:
struct MyStruct
    method MyStructFilter takes nothing returns boolean
        returns true
    endmethod
    method MakeBoolExpr takes nothing returns nothing
        local boolexpr b = Filter(function .MyStructFilter)
    endmethod
endstruct

I know that these examples don't work and that the sintax is wrong, I just want you to see what I want to do.

So, any ideas? I know I can make a function outside a struct that will be used by that boolexpr, I'm just asking if it's possible to make a "methody" one.
12-28-2007, 01:05 PM#2
rain9441
static keyword is your friend.

make MyStructFilter static and it'll all work as you desire. Keep in mind this will not be accessible.
12-28-2007, 09:44 PM#3
Silvenon
Kewl.......but what keyword should I put? Method? Function?

Collapse JASS:
struct MyStruct
    static method MyStructFilter takes nothing returns boolean
        returns true
    endmethod
    static method create takes nothing returns MyStruct
        local MyStruct ms = MyStruct.allocate()
        local boolexpr b = Filter(method MyStruct.MyStructFilter)
        // ...
        return ms
    endmethod
endstruct

Like that?

Quote:
Keep in mind this will not be accessible.

Huh, what do you mean by that?
12-28-2007, 10:00 PM#4
rain9441
The keyword 'this' wont be acceptable. You won't be able to use this.MyVariable (unless MyVariable is also static) inside your MyStructFilter function.