Lionheart008
15-07-2009, 19:08
hi dear thinbasic users,
I am very seldom use UDT's but in this case I tested it :) original I wanted to test my liongfx module with udt, but only to replace it for printl messages it doesn't satisfy me ;)
at the beginning of the script you will find some "1" and "2" trees... (why ?) I was suprised to see it, have made experiments with print and other things you can see between the lines...
perhaps somebody can check this script if this udt example works...
uses "console" '- , "liongfx"
printl "one little udt example.. :)"
printl
'----------------- part one :)
TYPE Apple
r as integer
s as integer
color as string
pants as string
END TYPE
TYPE Comix
batman as long
hulk as integer
spiderman as string
xmen as string
transmitter as Apple
startrek as Apple
END TYPE
TYPE Horror
jimmy as long
paula as string
thething(5) as comix
jake(10) as comix
END TYPE
dim monster(6) as Horror
dim lover(6) as Horror ' as Comix doesn't run ;)
dim k as long
%marvelhits = 1
For k as long = 1 to 5
monster(1).thething(k).transmitter = %marvelhits
printl monster(1)
NEXT
printl "jimi hendrix was the best guitar men forever :)"
'-- this second part is dangerous...!
'dim r as long
'%asterix = 2
'For r as long = 1 to 5
' lover(1).jake(r).startrek = %asterix
' printl lover(1)
'NEXT
'------- only an experiments ;)
function monsterli (byref tyrex as long) as long
dim v as long
v += 1
monster(10) = 400 + "Filippo"
monster(20) = 300 + "Sharky"
monster(30) = 300 + "Housewife"
monster(40) = 200 + "Tsunami"
monster(50) = 100 + "King Kong"
monster(60) = 500 + "Minotaurus"
tyrex(v) = 1200 + "Olga"
end function
printl
'----------------- part two :)
dim a,b,c as Apple
dim d,e,f as Apple
dim g,h,i as Comix
a.color = "red"
b.color = "green"
c.color = "blue"
d.pants = "jeans"
e.pants = "wranglers"
f.pants = "armani"
g.batman = 189
h.spiderman = "yes, next spiderman movie will come 2010"
i.xmen = "..what a surprise: woolverine has got new friends"
IF a.color = b.color THEN
printl "equal"
ELSE
printl "unequal"
end if
printl
sleep 1500
printl "first color: " + a.color
printl "another nice color: " + c.color
printl "third famous color: " + b.color
printl
printl "my first trousers: " + d.pants
printl "your second trousers: " + e.pants
printl
printl "her third trousers: " + f.pants
printl
printl "how much comic books I have?: " + g.batman
printl
printl "does peter parker will come back? " + h.spiderman
printl
printl "woolverine is unburstable and an alien, but.. " + i.xmen
printl
printl "press any key to exit"
waitkey
the problem was to use this one... will check, why it doesn't work... if you are using it you will get a gpf at the end of the script... sorry... have noticed this mistake after second test with my laptop...
dim r as long
%asterix = 2
For r as long = 1 to 5
lover(1).jake(r).startrek = %asterix
printl lover(1)
NEXT
the included dummy function is still a further try for part two of the script to use it ;) more to come.
best regards, nice evening, mr. experimento :)
I am very seldom use UDT's but in this case I tested it :) original I wanted to test my liongfx module with udt, but only to replace it for printl messages it doesn't satisfy me ;)
at the beginning of the script you will find some "1" and "2" trees... (why ?) I was suprised to see it, have made experiments with print and other things you can see between the lines...
perhaps somebody can check this script if this udt example works...
uses "console" '- , "liongfx"
printl "one little udt example.. :)"
printl
'----------------- part one :)
TYPE Apple
r as integer
s as integer
color as string
pants as string
END TYPE
TYPE Comix
batman as long
hulk as integer
spiderman as string
xmen as string
transmitter as Apple
startrek as Apple
END TYPE
TYPE Horror
jimmy as long
paula as string
thething(5) as comix
jake(10) as comix
END TYPE
dim monster(6) as Horror
dim lover(6) as Horror ' as Comix doesn't run ;)
dim k as long
%marvelhits = 1
For k as long = 1 to 5
monster(1).thething(k).transmitter = %marvelhits
printl monster(1)
NEXT
printl "jimi hendrix was the best guitar men forever :)"
'-- this second part is dangerous...!
'dim r as long
'%asterix = 2
'For r as long = 1 to 5
' lover(1).jake(r).startrek = %asterix
' printl lover(1)
'NEXT
'------- only an experiments ;)
function monsterli (byref tyrex as long) as long
dim v as long
v += 1
monster(10) = 400 + "Filippo"
monster(20) = 300 + "Sharky"
monster(30) = 300 + "Housewife"
monster(40) = 200 + "Tsunami"
monster(50) = 100 + "King Kong"
monster(60) = 500 + "Minotaurus"
tyrex(v) = 1200 + "Olga"
end function
printl
'----------------- part two :)
dim a,b,c as Apple
dim d,e,f as Apple
dim g,h,i as Comix
a.color = "red"
b.color = "green"
c.color = "blue"
d.pants = "jeans"
e.pants = "wranglers"
f.pants = "armani"
g.batman = 189
h.spiderman = "yes, next spiderman movie will come 2010"
i.xmen = "..what a surprise: woolverine has got new friends"
IF a.color = b.color THEN
printl "equal"
ELSE
printl "unequal"
end if
printl
sleep 1500
printl "first color: " + a.color
printl "another nice color: " + c.color
printl "third famous color: " + b.color
printl
printl "my first trousers: " + d.pants
printl "your second trousers: " + e.pants
printl
printl "her third trousers: " + f.pants
printl
printl "how much comic books I have?: " + g.batman
printl
printl "does peter parker will come back? " + h.spiderman
printl
printl "woolverine is unburstable and an alien, but.. " + i.xmen
printl
printl "press any key to exit"
waitkey
the problem was to use this one... will check, why it doesn't work... if you are using it you will get a gpf at the end of the script... sorry... have noticed this mistake after second test with my laptop...
dim r as long
%asterix = 2
For r as long = 1 to 5
lover(1).jake(r).startrek = %asterix
printl lover(1)
NEXT
the included dummy function is still a further try for part two of the script to use it ;) more to come.
best regards, nice evening, mr. experimento :)