SELF
SELF
Pseudo class instance variable
The SELF variable works with MAP variables. You can assign a reference to a FUNC or SUB to a MAP variable. When you call the SUB or FUNC the SELF variable provides access to values from the enclosing MAP variable. This provides pseudo class/object functionality.
Note: ‘MAP’ is the name given to the dictionary/hashmap variable variant.
Example 1: SELF and MAP variable
SUB hello
print "hello " + self.world
END
"world"
a.world =
a.foo = @hello a.foo()
Example 2: Simple Class
func SimpleClass(i)
sub Increment(i)
self.x = self.x + i
end
sub Decrement(i)
self.x = self.x - i
end
func GetX()
return self.x
end
local temp
temp.x = i
temp.Increment = @Increment
temp.Decrement = @Decrement
temp.GetX = @GetX
return temp
end
1)
A = SimpleClass(print A.GetX()
5) : print A.GetX()
A.Increment(4) : print A.GetX() A.Decrement(
Code samples using SELF
2048.bas
2048.bas
3d_torus.bas
3dtorus.bas
7gables.bas
betrayal: crows ii.bas
checkers.bas
checkers.bas
chess.bas
chess.bas
dogstar5.bas
eliza.bas
Eliza.bas
heap.bas
irc-bot.bas
klotski_solver.bas
klotski_solver.bas
lissajous2.bas
palm_cli.bas
palmcli.bas
scales132.bas
selfdefinedsymbols.bas
snake game v1.bas
snake.bas
startrek.bas
startrek.bas
xmas_tree.bas