Announcement

Collapse
No announcement yet.

String Ptr members in UDT's

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

  • String Ptr members in UDT's

    Hi, I was under the impression that the following would work, but i get a page fault every time i run it.

    Code:
    #COMPILE EXE
    #DIM ALL
    #REGISTER NONE
    
    TYPE test
         l AS LONG
         sPtr AS STRING PTR
    END TYPE
    
    FUNCTION PBMAIN()
       DIM t AS TEST
       
       t.l = 2
       [email protected] = "Test"
       
    END FUNCTION
    Is there no way to use variable length strings in a UDT?

    -Mike


    ------------------

  • #2
    after a bit more searching i came across the thread at
    http://www.powerbasic.com/support/pb...ead.php?t=2357

    which answers my question. so nevermind
    -mike

    ------------------

    Comment


    • #3
      Hi Mike
      Another way to skin the cat is (your code modified)

      Code:
      #COMPILE EXE
       #DIM ALL
       #REGISTER NONE
      
       TYPE test
            l AS LONG
            sPtr AS DWORD
       END TYPE
      
       FUNCTION PBMAIN()
          DIM t AS TEST, A$
          DIM x AS ASCIIZ PTR
          t.l = 2
          A$ = "TEST"
          t.sPtr = STRPTR(A$)
          x = t.sPtr
          MSGBOX @x
       END FUNCTION
      I've used this in the past where I wanted a scratch UDT that could be used differently in
      different procedures.

      ------------------
      The most exasperating part of the "rat race" is how often the rats are in the lead!

      Comment

      Working...
      X