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
System
CHAIN
COMMAND
CWD
DELAY
ENV
ENV
EXEC
EXPORT
FRE
HOME
IMPORT
INCLUDE
MAXINT
NIL
OPTION
PAUSE
PI
PROGLINE
RANDOMIZE
RUN
SBVER
SELF
STKDUMP
TROFF
TRON
UNIT
If there is insufficient information on this page and you wish learn more about SELF,
please send an email to smallbasic@gmail.com. You can help to improve information about
SELF by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.