Results 1 to 3 of 3

Thread: UDT.and.numbers

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

    UDT.and.numbers

    I have a simple question

    take this

    shapes(1).box1.pos.x

    I want to change box1 in a for next, can it be done. The example below is just to show what I mean.

    [code=thinbasic]For n = 1 to 4
    shapes(1).box+STR$(n).pos.x
    NEXT[/code]
    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

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

    Re: UDT.and.numbers

    Making box member array of 4 seems the most straightforward way for me in this case

    Like:
    [code=thinbasic]
    TYPE TXYZ
    x AS DOUBLE
    y AS DOUBLE
    z AS DOUBLE
    END TYPE

    TYPE TTransform
    pos AS TXYZ
    END TYPE

    TYPE TBoxStuff
    box(4) AS TTransform
    END TYPE

    DIM shapes(4) as TBoxStuff
    DIM n as long

    %something = 1
    For n as long = 1 to 4
    shapes(1).box(n).pos.x = %something
    NEXT
    [/code]

    I think dynamic variable name evaluation ( like the one for function calls ) is not implemented.


    Petr
    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
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Blog Entries
    1
    Rep Power
    153

    Re: UDT.and.numbers

    Thanks Petr

    I thought that this problem had come up before and Eros suggested something but it was a long time ago but it does matter if I use another array.

    thanks again.

    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

Posting Permissions

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