Announcement

Collapse
No announcement yet.

Compatibility Issues wish list

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compatibility Issues wish list

    Up until now I have never had a problem converting VB. Basically the problems I am having come about with user defined types. Specifically, VB supports Dynamic strings in UDT, objects in VB.NET are basically user defined types as well. The second problem is that you can not return UDT from a function.

    So it would be nice to have these features added in the next version, Please

  • #2
    This is not an official venue for New Feature Suggestions.

    Send NFSs to [email protected]
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Use Malloc

      You can use a string array or malloc to do this. At minimum you would need a separate function to handle the assignment of the string.

      Code:
      TYPE MYADDRESS
        FirstName as STRING PTR
        LastName as STRING PTR
        Age as INTEGER
      END TYPE
      
      GLOBAL MyList() as string
      
      FUNCTION SetString(inText$)
        REDIM PRESERVE MyList(UBOUND(MyList()+1) as GLOBAL STRING
      
        MyList(UBOUND(MyList()) = inText$
      
        'Now here you can return the POINTER to the string on the INDEX of the array.
        FUNCTION = UBOUND(MyList())
      '  or
        FUNCTION = STRPTR(MyList(UBOUND(MyList()))
      END FUNCTION
      
      Sub Main()
         Dim MyUDT as MYADDRESS
      
         MyUDT.FirstName = SetString("Tony")
         MyUDT.LastName = SetString("Lawrence")
         MyUDT.Age = 33
      End Sub
      If you use the Index, you can print the name as

      PRINT MyList(MyUDT.FirstName)

      of you use the pointer:

      PRINT [email protected]

      Using a Malloc or HeapAlloc will only give you the use of the POINTER option. Arrays give you a little more flexibility and options for sorting and searching.


      Also... You can return an UDT from a function. Its just return within the parameter list. (And you can return it from a FUNCTION or a SUB.)

      Code:
      DIM MyUDT(200) as MYADDRESS
      
      Sub Get_MyUDT (index as long, destUDT as MYADDRESS)
        destUDT = MyUDT(index)
      End Sub
      You can use a FUNCTION to return a LONG value of errors or data type settings regarding the function request. Within VB you would say:

      destUDT = Get_MyUDT(index)

      in PB, you would accomplish this with the sub/function above and the following call

      CALL Get_MyUDT (index, destUDT)
      result = Get_MyUDT (index, destUDT) (where result could be error codes etc..)


      Hope this helps.


      Tye
      Last edited by Tyrone W. Lee; 4 Mar 2008, 08:09 AM.
      Explorations v9.10 RPG Development System
      http://www.explore-rpg.com

      Comment


      • #4
        If you don't need to spport $NUL characters in your strings, you can use
        Code:
        TYPE myType
          A  AS LONG
          B  AS SINGLE
          sz  AS ASCIIZ *%MAX_LENGTH_I_NEED_TO_SUPPORT
          ......
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment

        Working...
        X