'-- class example two times
'
'---------------------- //
class myZooClass
pApe as long
method ABC(value as long)
pApe = value
end method
method ABC() as long
method = pApe
end method
end class
'test it
dim zoo as myZooClass
zoo.ABC = 6
print zoo.ABC ' 6
'---------------------- //
class AnimalClass
tiger as long
method paw(claws as long)
tiger= claws
end method
method paw() as long
method = tiger
end method
end class
'test it
dim cat as AnimalClass
cat.paw = 5
print "catpaw " +cat.paw ' 5
'
' two function examples, factorial, quattro
' -- example 1
Function factorial(x As Integer) As Integer
' This is a recursive function
' to find the factorial of an integer
If x = 1 Then
return 1
Else
return x * factorial(x-1)
End If
End Function
printy factorial(4) ' 24
pim num As Integer
num = 3
Printy "The factorial of " + num + " is " + str(factorial(num) )
' -- example 2
function quattro(i as pro) as pro
return i*4
end function
printy quattro(4) ' 16
' -- expl 1
' -- for...next
'
dim i as integer, height as integer
height = 5
FOR i = 1 to height
printy string(i, "*")
next
printy "after loop the value i has value " + i
'
'-- expl 2 do...loop
'
dim n as integer, even as integer
Do
n += 1
If n > 7 Then Exit Do
If n Mod 2 Then Continue Do
even += 1
Loop
Printy "even number: " + even
' simple calculation 2
' legend :
' dim = pim, dword = pro
' printy = print
' pstring = string
'
pim a,b,c,d as pro
a= 10 : b=20 : c=40 : d=a*b
printy a
printy d
pstring s = "Hello Batman " + a ' 10
printy s
pstring st = "Hello Spiderman " + d ' 200
printy st
pim k as float
k=2345.67 '2345.6699
printy k
Page created in 0.135 seconds with 15 queries.