Results 1 to 4 of 4

Thread: udt and experiments :)

  1. #1
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    45
    Posts
    914
    Rep Power
    101

    udt and experiments :)

    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...

    [code=thinbasic]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[/code]

    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...

    [code=thinbasic]
    dim r as long
    %asterix = 2
    For r as long = 1 to 5
    lover(1).jake(r).startrek = %asterix
    printl lover(1)
    NEXT[/code]

    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
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,817
    Blog Entries
    3
    Rep Power
    695

    Re: udt and experiments :)

    Frank,

    you catched yourself into own trap with following :
    [code=thinbasic]
    dim r as long
    %asterix = 2
    For r as long = 1 to 5
    lover(1).jake(r).startrek = %asterix
    printl lover(1)
    NEXT
    [/code]

    Lover is of type Horror. So it can have members: jimmy, paula, theThing(1 to 5) or jake(1 to 10).

    Lover(1).jake(r) => correct, if dotted further:

    jake() is of type comix, which can have members: batman, hulk, spiderman, xmen, transmitter, starttrek

    Lover(1).jake(r).startrek => correct, if dotted further:

    startrek is of type Apple, which can have members: r, s, color, pants

    but you did not listed any of these members.

    So you would have to type something like:
    [code=thinbasic]
    lover(1).jake(r).startrek.r = %asterix
    [/code]

    Your assignment:
    [code=thinbasic]
    lover(1).jake(r).startrek = %asterix
    [/code]
    would be possible for assigning variable of type Apple, not number.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    Senior Member Lionheart008's Avatar
    Join Date
    Sep 2008
    Location
    Germany, Bad Sooden-Allendorf
    Age
    45
    Posts
    914
    Rep Power
    101

    Re: udt and experiments :)

    good morning petr,

    thank you... I see my mistake... and have checked this early morning another part of going with

    [code=thinbasic]dim r as long
    %asterix = 2
    For r as long = 1 to 4
    lover(1).jake(r).startrek.weapon(4) = %asterix
    printl lover(1)
    NEXT
    [/code]

    and added for type apple weapon(4) ... tested it with r and s(1) too ... it works...

    TYPE Apple
    r as integer
    s(1) as integer
    color as string
    pants as string
    weapon(4) as long
    END TYPE
    your idea is very good with eg.

    dim r as long
    %asterix = 2
    For r as long = 1 to 5
    lover(1).jake(r).startrek.r = %asterix
    printl lover(1)
    NEXT
    I believe UDT's aren't my best friends no, no... just a joke...

    thank you for help..., nice day, I hope with a lot of sun bathing... or icecream...

    lionheart
    you can't always get what you want, but if you try sometimes you might find, you get what you need

  4. #4
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Blog Entries
    1
    Rep Power
    154

    Re: udt and experiments :)

    Quote Originally Posted by Lionheart008
    "woolverine"
    OIC. The new X-men character - Half Man Half Sheep. baaa
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

Similar Threads

  1. TBGL experiments 2007
    By kryton9 in forum TBGL Modelling, 3D, other SW integration
    Replies: 54
    Last Post: 19-02-2007, 19:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •