Announcement

Collapse
No announcement yet.

Help with string pointers please

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

  • Semen Matusovski
    replied
    Mark --
    When you execute @, compiler, of course, adds Nul after the last symbol.
    Be careful.
    Code:
       #Compile Exe
       #Register None
       #Include "win32api.inc"
    
       Type cmark
          well As String * 4
          table As String * 4
          row As Long
          rr As Long
       End Type
    
       Function PbMain As Long
          Dim mark As cmark
          Dim buff As Asciiz Ptr
          buff = VarPtr(mark)
          mark.rr = &H0101
          MsgBox Format$(mark.rr)
          @buff = "AAAABBBBCCCC"
          MsgBox Format$(mark.rr)
       End Function
    ------------------
    E-MAIL: [email protected]

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Hello again,

    Ok so I got this to work but I dont understand how. How does the
    compiler know how long to make the ASCIIZ? Because I used an ASCIIZ,
    does the compiler try to put a zero at the end of the ASCIIZ? thus
    writting past the size of the TYPE by one byte (0)? or does the
    compiler assume that there is a zero already because it is being
    used as a pointer to a ASCIIZ?

    Code:
    #compile exe
    #include "win32api.inc"
    
    
    type cmark
        well as string * 4
        table as string * 4
        row as long
    end type
    
    
    function pbmain as long
        dim mark as cmark
        dim buff as asciiz ptr
    
        buff = varptr(mark)
        @buff = "AAAABBBBCCCC"
        
        msgbox @buff & $CRLF & mark.well & $CRLF & mark.table & $CRLF & hex$(mark.row)
    end function
    ------------------
    Cheers

    [This message has been edited by mark smit (edited September 21, 2000).]

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Help with string pointers please

    Help with string pointers please

    Hello All,

    I was wondering how I can make a string pointer, point to a UDT?

    Code:
    type mark
      well as long
      table as long
      row as long
    end type
    
    function pbmain as long
      dim buff as string ptr
      dim record as mark
    
      buff = varptr(record)
    
      @buff = "random data in here"
    end function
    Thank you in advance!

    ------------------
    Cheers
Working...
X