Results 1 to 4 of 4

Thread: ASSIGN error in UDT

  1. #1
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55

    Exclamation ASSIGN error in UDT

    ' Minimal example
    
    type ttest
    
      myvar as Single
      myvar2 as single
      
      function _Create()
      	MsgBox 0, str$(assign(1.5, me.myvar)) ' error
      	'me.myvar2 = assign(2.5, me.myvar) ' error
      End Function
    
    End Type
    
    dim testVar as ttest
    
    unless I'm mistaken this is not reported in the list of known issues, so

    who can confirm this code is correct ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  2. #2
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55

    Exclamation

    ' Minimal example
    
    type ttest
    
      myvar as Single
      myvar2 as single
      
      function _Create()
      	MsgBox 0, str$(assign2(1.5, me.myvar)) ' error
      	'me.myvar2 = assign2(2.5, me.myvar) ' error
      End Function
    
    End Type
    
    dim testVar as ttest
    
    function Assign2(what as number, byref where as Number) as number 'error
    	where = what
    	Return where
    End Function
    
    My attempt to circumvent my problem is not working either. Can't I pass me.myvar by ref ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

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

    the issue is related to ME/UDT variable in general - it has a special handling and multiple cases are "to be implemented".

    In all cases, the memory overlay DIM .. AT is the workaround which can be used:
    type ttest
     
      myvar as Single
      myvar2 as single
       
      function _Create()
        dim help_myvar as single at varptr(me.myvar)
        assign(1.5, help_myvar)
        
        MsgBox 0, me.myvar
      End Function
     
    End Type
     
    dim testVar as ttest
    
    We will have a look how we can make ME to be treated the same way as other variables / UDTs.


    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
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55
    Quote Originally Posted by Petr Schreiber View Post

    We will have a look how we can make ME to be treated the same way as other variables / UDTs.


    Petr
    Thanks Petr, thanks Eros.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

Similar Threads

  1. typo in Assign help page
    By DirectuX in forum Fixed or cleared errors in help material
    Replies: 2
    Last Post: 14-12-2020, 22:00
  2. Help File: Assign
    By catventure in forum Fixed or cleared errors in help material
    Replies: 1
    Last Post: 23-10-2011, 12:58
  3. Error$
    By Michael Clease in forum thinBasic General
    Replies: 2
    Last Post: 19-06-2010, 12:09

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
  •