largo_winch
31-01-2013, 19:31
this code example I've found from freebasic manual. I'm only asking if this example has to be translated as class/method ? or there's another way (oop like) to convert this example?
' Empty GUI script created on 01-31-2013 13:26:32 by (thinAir)
Uses "console"
Type sample
Texty 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 sample ()
Print "Konstruktor sample ()"
Print
THIS.Texty = "Leer"
End Constructor
Constructor sample ( a As Integer )
Print "Konstruktor sample ( a As Integer )"
Print " a = "; a
Print
THIS.Texty = Str(a)
End Constructor
Constructor sample ( a As Single )
Print "Konstruktor sample ( a As Single )"
Print " a = "; a
Print
THIS.Texty = Str(a)
End Constructor
Constructor sample ( a As String, b As Byte )
Print "Konstruktor sample ( a As String, b As Byte )"
Print " a = "; a
Print " b = "; b
Print
THIS.Texty = Str(a) + "," + Str(b)
End Constructor
Operator sample.Cast () As String
Return THIS.Texty
End Operator
Print "Erstelle x1" ' (build x1)
Dim x1 As sample
Print "Erstelle x2" ' (build x2)
Dim x2 As sample = 1
Print "Erstelle x3" ' (build x3)
Dim x3 As sample = 99.9
Print "Erstelle x4" ' (build x4)
Dim x4 As sample = sample( "aaa", 1 )
Print "Values:"
Print " x1 = "; x1
Print " x2 = "; x2
Print " x3 = "; x3
Print " x4 = "; x4
'Sleep
WaitKey
bye, largo
' Empty GUI script created on 01-31-2013 13:26:32 by (thinAir)
Uses "console"
Type sample
Texty 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 sample ()
Print "Konstruktor sample ()"
THIS.Texty = "Leer"
End Constructor
Constructor sample ( a As Integer )
Print "Konstruktor sample ( a As Integer )"
Print " a = "; a
THIS.Texty = Str(a)
End Constructor
Constructor sample ( a As Single )
Print "Konstruktor sample ( a As Single )"
Print " a = "; a
THIS.Texty = Str(a)
End Constructor
Constructor sample ( a As String, b As Byte )
Print "Konstruktor sample ( a As String, b As Byte )"
Print " a = "; a
Print " b = "; b
THIS.Texty = Str(a) + "," + Str(b)
End Constructor
Operator sample.Cast () As String
Return THIS.Texty
End Operator
Print "Erstelle x1" ' (build x1)
Dim x1 As sample
Print "Erstelle x2" ' (build x2)
Dim x2 As sample = 1
Print "Erstelle x3" ' (build x3)
Dim x3 As sample = 99.9
Print "Erstelle x4" ' (build x4)
Dim x4 As sample = sample( "aaa", 1 )
Print "Values:"
Print " x1 = "; x1
Print " x2 = "; x2
Print " x3 = "; x3
Print " x4 = "; x4
'Sleep
WaitKey
bye, largo