Results 1 to 10 of 10

Thread: Type pointer var not supported by WITH?

  1. #1
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    51
    Posts
    3,283
    Blog Entries
    2
    Rep Power
    340

    Type pointer var not supported by WITH?

    Hi Eros,

    I'm sure if it is a bug or just a feature. Does the WITH command not support Pointer variables?

    Michael
    Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200.

  2. #2
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    51
    Posts
    3,283
    Blog Entries
    2
    Rep Power
    340

    Re: Type pointer var not supported by WITH?

    Nevermind, it works. Was again a stupid mistake by me.
    Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200.

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

    Re: Type pointer var not supported by WITH?

    Hi Mike,

    how do you create pointer variable? :-[


    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

  4. #4
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    51
    Posts
    3,283
    Blog Entries
    2
    Rep Power
    340

    Re: Type pointer var not supported by WITH?

    Hi Petr,

    here is some code:

    [code=thinbasic]' Empty ThinBASIC GUI file template

    type testtype
    id as long
    end type


    dim mytype as testtype
    dim ptype as testtype ptr

    dim ptype2 as testtype ptr

    setat(ptype, varptr(mytype))

    mytype.id = 1
    msgbox(0,"mytype.id = " & mytype.id)

    ptype.id = 2
    msgbox(0,"mytype.id = " & mytype.id)

    with pType
    .id = 3
    end with
    msgbox(0,"mytype.id = " & mytype.id)

    pType2 = heap_alloc(sizeof(testtype))
    pType2.id = 40
    msgbox(0,"pType2.id = " & pType2.id)

    with pType2
    .id = 50
    end with
    msgbox(0,"pType2.id = " & pType2.id)

    myfunc()

    heap_free(pType2)


    function myfunc() as long
    with pType2
    .id = 60
    end with
    msgbox(0,"pType2.id = " & pType2.id)
    end function[/code]
    Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200.

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

    Re: Type pointer var not supported by WITH?

    Hi Mike,

    thanks
    I think the pointers to other than UDTs are not supported now as "data type" ( but you can use DWORDs to store values of VARPTR ).
    I think referencing UDT variable without parameter returns pointer as well, maybe Eros will put more light on this.


    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

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,224
    Blog Entries
    2
    Rep Power
    10

    Re: Type pointer var not supported by WITH?

    Unfortunately pointers are partially handled by thinBasic.

    The best and most secure way for the moment is to define LONG variables to be used as pointers and allocate memory. That use DIM ... AT to allocate dynamic virtual structures at some location. At that point vitual variables will be like standard variables and you will be able to use WITH clause.

    I do not think I will have enough time to improve current situation for the next thinBasic release.

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  7. #7
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    51
    Posts
    3,283
    Blog Entries
    2
    Rep Power
    340

    Re: Type pointer var not supported by WITH?

    There is nothing wrong Eros. I had made a mistake and thought the WITH command didn't support PTR variables to UDT's. But it does and so everything is fine.
    Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200.

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,224
    Blog Entries
    2
    Rep Power
    10

    Re: Type pointer var not supported by WITH?

    I'm happy Michael
    But I know I have to improve PTR a lot
    I have thinCore code under my eyes every day ...
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  9. #9
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    51
    Posts
    3,283
    Blog Entries
    2
    Rep Power
    340

    Re: Type pointer var not supported by WITH?

    Right now I'm really twisting and turning UDT's with allocated memory and Linked Lists inside out. That is why I need the pointer. One thing is AStar path finding and the other one is a OpenGL GUI. So far everything works fine. Linked lists could be faster but it is still a good performance.
    Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200.

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,224
    Blog Entries
    2
    Rep Power
    10

    Re: Type pointer var not supported by WITH?

    Michael,

    I'm currently rewriting LL module from scratch keeping the same syntax
    I'm adding a 2 layer system in such a way there will never problems when deleting LL elements. I hope to be able to add also more speed. Some LL functions uses serial searching. I was thinking to create a LL with hash table to be able to find elements much faster but I'm not sure so far. I will keep you updated.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Similar Threads

  1. Pointer methods
    By Richard in forum Real world situations and solutions using thinBasic
    Replies: 1
    Last Post: 05-02-2010, 00: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
  •