a) what Is the meaning of For example "this." command -> here "this.mytext" in a Class oop example And where/when To use it?
it's a kind of a pointer?
b) when I should use operators?
If you have another example To study For me I am glad To see..
thanks in advance, löwenherz
Code: Select all
TYPE mysample
mytext AS STRING
DECLARE CONSTRUCTOR ()
DECLARE CONSTRUCTOR ( a AS INTEGER )
DECLARE CONSTRUCTOR ( a AS SINGLE )
DECLARE CONSTRUCTOR ( a AS STRING, b AS BYTE )
DECLARE OPERATOR CAST () AS STRING
END TYPE
CONSTRUCTOR mysample ()
PRINT "constructor mysample ()"
PRINT
THIS.mytext = "empty"
END CONSTRUCTOR
CONSTRUCTOR mysample ( a AS INTEGER )
PRINT "constructor mysample ( a As Integer )"
PRINT " a = "; a
PRINT
THIS.mytext = STR(a)
END CONSTRUCTOR
CONSTRUCTOR mysample ( a AS SINGLE )
PRINT "constructor mysample ( a As Single )"
PRINT " a = "; a
PRINT
THIS.mytext = STR(a)
END CONSTRUCTOR
CONSTRUCTOR mysample ( a AS STRING, b AS BYTE )
PRINT "constructor mysample ( a As String, b As Byte )"
PRINT " a = "; a
PRINT " b = "; b
PRINT
THIS.mytext = a & "," & b
END CONSTRUCTOR
OPERATOR mysample.CAST () AS STRING
RETURN THIS.mytext
END OPERATOR
PRINT "build x1"
DIM x1 AS mysample
PRINT "build x2"
DIM x2 AS mysample = 1
PRINT "build x3"
DIM x3 AS mysample = 99.9
PRINT "build x4"
DIM x4 AS mysample = mysample( "aaa", 1 )
PRINT "values:"
PRINT " x1 = "; x1
PRINT " x2 = "; x2
PRINT " x3 = "; x3
PRINT " x4 = "; x4
SLEEP