Results 1 to 5 of 5

Thread: STAT_CLONEARRAY and UDT

  1. #1

    Question STAT_CLONEARRAY and UDT

    Capture2.JPG

    STAT_CLONEARRAY and UDT , aren't they compatible ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,814
    Rep Power
    10
    No, I'm sorry
    It works only on numeric arrays

    In general STAT module was intended to work with numeric arrays
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735
    Hi Sebastian,

    I think you can perform duplicate for example this way:
    uses "Console"
    
    type Vector3D
      x as float32
      y as float32
    end type
    
    dim arr(3) as Vector3D
    dim arr_copy(3) as Vector3D
    
    int32 i
    
    for i = 1 to ubound(arr)
      arr(i).x = i
      arr(i).y = i
    next
    
    ' This is like "copy bytes from start of the array, of total length calculated like number-of-elements * size-of-element and store them to string"
    ' VarPtr is "variable pointer"
    string binary = peek$(varptr(arr(1)), CountOf(arr(1))*SizeOf(arr(1)))
    
    ' This is like - "paste the binary string at place starting at beginning of arr_copy"
    poke$(varptr(arr_copy(1)), binary)
    
    printl "Source array:"
    for i = 1 to ubound(arr)
      printl arr(i).x, arr(i).y
    next
    
    
    printl
    
    
    printl "Copied array:"
    for i = 1 to ubound(arr)
      printl arr_copy(i).x, arr_copy(i).y
    next
    
    
    waitkey
    

    Petr
    Last edited by Petr Schreiber; 24-10-2019 at 23:21.
    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

  4. #4
    Thanks both,

    Eros I think the core ARRAY series functions may benefit of such ARRAY COPY and ARRAY CLONE functions.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735
    That would be nice!


    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

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

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