Results 1 to 3 of 3

Thread: UDT.and.numbers

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    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
    7,128
    Rep Power
    732

    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 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    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

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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