Results 1 to 10 of 10

Thread: Type pointer var not supported by WITH?

  1. #1

    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

  2. #2

    Re: Type pointer var not supported by WITH?

    Nevermind, it works. Was again a stupid mistake by me.

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

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

  4. #4

    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]

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

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

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    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/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    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.

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    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/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  9. #9

    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.

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    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/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

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

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
  •